1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
4 # @ECLASS: linux-mod.eclass
8 # John Mylchreest <johnm@gentoo.org>,
9 # Stefan Schweizer <genstef@gentoo.org>
10 # @BLURB: It provides the functionality required to install external modules against a kernel source tree.
12 # This eclass is used to interface with linux-info.eclass in such a way
13 # to provide the functionality and initial functions
14 # required to install external modules against a kernel source
17 # A Couple of env vars are available to effect usage of this eclass
18 # These are as follows:
20 # @ECLASS-VARIABLE: MODULES_OPTIONAL_USE
22 # A string containing the USE flag to use for making this eclass optional
23 # The recommended non-empty value is 'modules'
25 # @ECLASS-VARIABLE: MODULES_OPTIONAL_USE_IUSE_DEFAULT
27 # A boolean to control the IUSE default state for the MODULES_OPTIONAL_USE USE
28 # flag. Default value is unset (false). True represented by 1 or 'on', other
29 # values including unset treated as false.
31 # @ECLASS-VARIABLE: KERNEL_DIR
33 # A string containing the directory of the target kernel sources. The default value is
36 # @ECLASS-VARIABLE: ECONF_PARAMS
38 # It's a string containing the parameters to pass to econf.
39 # If this is not set, then econf isn't run.
41 # @ECLASS-VARIABLE: BUILD_PARAMS
43 # It's a string with the parameters to pass to emake.
45 # @ECLASS-VARIABLE: BUILD_TARGETS
47 # It's a string with the build targets to pass to make. The default value is "clean module"
49 # @ECLASS-VARIABLE: MODULE_NAMES
51 # It's a string containing the modules to be built automatically using the default
52 # src_compile/src_install. It will only make ${BUILD_TARGETS} once in any directory.
54 # The structure of each MODULE_NAMES entry is as follows:
56 # modulename(libdir:srcdir:objdir)
60 # modulename = name of the module file excluding the .ko
61 # libdir = place in system modules directory where module is installed (by default it's misc)
62 # srcdir = place for ebuild to cd to before running make (by default it's ${S})
63 # objdir = place the .ko and objects are located after make runs (by default it's set to srcdir)
65 # To get an idea of how these variables are used, here's a few lines
66 # of code from around line 540 in this eclass:
68 # einfo "Installing ${modulename} module"
69 # cd ${objdir} || die "${objdir} does not exist"
70 # insinto /lib/modules/${KV_FULL}/${libdir}
71 # doins ${modulename}.${KV_OBJ} || die "doins ${modulename}.${KV_OBJ} failed"
74 # MODULE_NAMES="module_pci(pci:${S}/pci:${S}) module_usb(usb:${S}/usb:${S})"
76 # what this would do is
79 # make ${BUILD_PARAMS} ${BUILD_TARGETS}
81 # insinto /lib/modules/${KV_FULL}/pci
82 # doins module_pci.${KV_OBJ}
85 # make ${BUILD_PARAMS} ${BUILD_TARGETS}
87 # insinto /lib/modules/${KV_FULL}/usb
88 # doins module_usb.${KV_OBJ}
90 # There is also support for automated modprobe.d file generation.
91 # This can be explicitly enabled by setting any of the following variables.
93 # @ECLASS-VARIABLE: MODULESD_<modulename>_ENABLED
95 # This is used to disable the modprobe.d file generation otherwise the file will be
96 # always generated (unless no MODULESD_<modulename>_* variable is provided). Set to "no" to disable
97 # the generation of the file and the installation of the documentation.
99 # @ECLASS-VARIABLE: MODULESD_<modulename>_EXAMPLES
101 # This is a bash array containing a list of examples which should
102 # be used. If you want us to try and take a guess set this to "guess".
104 # For each array_component it's added an options line in the modprobe.d file
106 # options array_component
108 # where array_component is "<modulename> options" (see modprobe.conf(5))
110 # @ECLASS-VARIABLE: MODULESD_<modulename>_ALIASES
112 # This is a bash array containing a list of associated aliases.
114 # For each array_component it's added an alias line in the modprobe.d file
116 # alias array_component
118 # where array_component is "wildcard <modulename>" (see modprobe.conf(5))
120 # @ECLASS-VARIABLE: MODULESD_<modulename>_ADDITIONS
122 # This is a bash array containing a list of additional things to
123 # add to the bottom of the file. This can be absolutely anything.
124 # Each entry is a new line.
126 # @ECLASS-VARIABLE: MODULESD_<modulename>_DOCS
128 # This is a string list which contains the full path to any associated
129 # documents for <modulename>. These files are installed in the live tree.
131 # @ECLASS-VARIABLE: KV_OBJ
133 # It's a read-only variable. It contains the extension of the kernel modules.
135 inherit eutils linux-info multilib
136 EXPORT_FUNCTIONS pkg_setup pkg_preinst pkg_postinst src_install src_compile pkg_postrm
138 case ${MODULES_OPTIONAL_USE_IUSE_DEFAULT:-n} in
139 [nNfF]*|[oO][fF]*|0|-) _modules_optional_use_iuse_default='' ;;
140 *) _modules_optional_use_iuse_default='+' ;;
143 [[ -n "${_modules_optional_use_iuse_default}" ]] && case ${EAPI:-0} in
144 0) die "EAPI=${EAPI} is not supported with MODULES_OPTIONAL_USE_IUSE_DEFAULT due to lack of IUSE defaults" ;;
147 IUSE="kernel_linux ${MODULES_OPTIONAL_USE:+${_modules_optional_use_iuse_default}}${MODULES_OPTIONAL_USE}"
149 RDEPEND="${MODULES_OPTIONAL_USE}${MODULES_OPTIONAL_USE:+? (} kernel_linux? ( virtual/modutils ) ${MODULES_OPTIONAL_USE:+)}"
151 ${MODULES_OPTIONAL_USE}${MODULES_OPTIONAL_USE:+? (}
153 kernel_linux? ( virtual/linux-sources virtual/libelf )
154 ${MODULES_OPTIONAL_USE:+)}"
157 # ----------------------------------
160 debug-print-function ${FUNCNAME} $*
162 local curr_gcc_ver=$(gcc -dumpversion)
163 local tmpfile old_chost old_gcc_ver result=0
164 [ -n "${MODULES_OPTIONAL_USE}" ] && use !${MODULES_OPTIONAL_USE} && return
166 tmpfile=`find "${KV_DIR}/" -iname "*.o.cmd" -exec grep usr/lib/gcc {} \; -quit`
167 tmpfile=${tmpfile//*usr/lib}
168 tmpfile=${tmpfile//\/include*}
169 old_chost=${tmpfile//*gcc\/}
170 old_chost=${old_chost//\/*}
171 old_gcc_ver=${tmpfile//*\/}
173 if [[ -z ${old_gcc_ver} || -z ${old_chost} ]]; then
175 ewarn "Unable to detect what version of GCC was used to compile"
176 ewarn "the kernel. Build will continue, but you may experience problems."
177 elif [[ ${curr_gcc_ver} != ${old_gcc_ver} ]]; then
179 ewarn "The version of GCC you are using (${curr_gcc_ver}) does"
180 ewarn "not match the version of GCC used to compile the"
181 ewarn "kernel (${old_gcc_ver})."
183 elif [[ ${CHOST} != ${old_chost} ]]; then
185 ewarn "The current CHOST (${CHOST}) does not match the chost"
186 ewarn "used when compiling the kernel (${old_chost})."
190 if [[ ${result} -gt 0 ]]; then
192 ewarn "Build will not continue, because you will experience problems."
193 ewarn "To fix this either change the version of GCC you wish to use"
194 ewarn "to match the kernel, or recompile the kernel first."
195 die "GCC Version Mismatch."
200 # @RETURN: true or false
202 # It checks if the kernel version is greater than 2.6.5.
204 debug-print-function ${FUNCNAME} $*
206 # if we haven't determined the version yet, we need too.
209 # if the kernel version is greater than 2.6.6 then we should use
210 # M= instead of SUBDIRS=
211 [ ${KV_MAJOR} -eq 3 ] && return 0
212 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -gt 5 -a ${KV_PATCH} -gt 5 ] && \
216 # @FUNCTION: convert_to_m
217 # @USAGE: /path/to/the/file
219 # It converts a file (e.g. a makefile) to use M= instead of SUBDIRS=
221 debug-print-function ${FUNCNAME} $*
226 die "convert_to_m() requires a filename as an argument"
227 ebegin "Converting ${1/${WORKDIR}\//} to use M= instead of SUBDIRS="
228 sed -i 's:SUBDIRS=:M=:g' "${1}"
235 # FUNCTION: update_depmod
237 # It updates the modules.dep file for the current kernel.
239 debug-print-function ${FUNCNAME} $*
241 # if we haven't determined the version yet, we need too.
244 ebegin "Updating module dependencies for ${KV_FULL}"
245 if [ -r "${KV_OUT_DIR}"/System.map ]
247 depmod -ae -F "${KV_OUT_DIR}"/System.map -b "${ROOT:-/}" ${KV_FULL}
251 ewarn "${KV_OUT_DIR}/System.map not found."
252 ewarn "You must manually update the kernel module dependencies using depmod."
260 # FUNCTION: move_old_moduledb
262 # It updates the location of the database used by the module-rebuild utility.
263 move_old_moduledb() {
264 debug-print-function ${FUNCNAME} $*
266 local OLDDIR="${ROOT%/}"/usr/share/module-rebuild
267 local NEWDIR="${ROOT%/}"/var/lib/module-rebuild
269 if [[ -f "${OLDDIR}"/moduledb ]]; then
270 [[ ! -d "${NEWDIR}" ]] && mkdir -p "${NEWDIR}"
271 [[ ! -f "${NEWDIR}"/moduledb ]] && \
272 mv "${OLDDIR}"/moduledb "${NEWDIR}"/moduledb
280 # FUNCTION: update_moduledb
282 # It adds the package to the /var/lib/module-rebuild/moduledb database used by the module-rebuild utility.
284 debug-print-function ${FUNCNAME} $*
286 local MODULEDB_DIR="${ROOT%/}"/var/lib/module-rebuild
289 if [[ ! -f "${MODULEDB_DIR}"/moduledb ]]; then
290 [[ ! -d "${MODULEDB_DIR}" ]] && mkdir -p "${MODULEDB_DIR}"
291 touch "${MODULEDB_DIR}"/moduledb
294 if ! grep -qs ${CATEGORY}/${PN}-${PVR} "${MODULEDB_DIR}"/moduledb ; then
295 einfo "Adding module to moduledb."
296 echo "a:1:${CATEGORY}/${PN}-${PVR}" >> "${MODULEDB_DIR}"/moduledb
302 # FUNCTION: remove_moduledb
304 # It removes the package from the /var/lib/module-rebuild/moduledb database used by
305 # the module-rebuild utility.
307 debug-print-function ${FUNCNAME} $*
309 local MODULEDB_DIR="${ROOT%/}"/var/lib/module-rebuild
312 if grep -qs ${CATEGORY}/${PN}-${PVR} "${MODULEDB_DIR}"/moduledb ; then
313 einfo "Removing ${CATEGORY}/${PN}-${PVR} from moduledb."
314 sed -i -e "/.*${CATEGORY}\/${PN}-${PVR}.*/d" "${MODULEDB_DIR}"/moduledb
318 # @FUNCTION: set_kvobj
320 # It sets the KV_OBJ variable.
322 debug-print-function ${FUNCNAME} $*
330 # Do we really need to know this?
332 # einfo "Using KV_OBJ=${KV_OBJ}"
336 debug-print-function ${FUNCNAME} $*
338 if [[ -n ${KERNEL_CC} ]] ; then
344 if [ -n "${KERNEL_ABI}" ]; then
345 # In future, an arch might want to define CC_$ABI
346 #kernel_cc="$(get_abi_CC)"
347 #[ -z "${kernel_cc}" ] &&
348 kernel_cc="$(tc-getCC $(ABI=${KERNEL_ABI} get_abi_CHOST))"
350 kernel_cc=$(tc-getCC)
358 # USAGE: /path/to/the/modulename_without_extension
359 # RETURN: A file in /etc/modprobe.d
361 # This function will generate and install the neccessary modprobe.d file from the
362 # information contained in the modules exported parms.
363 # (see the variables MODULESD_<modulename>_ENABLED, MODULESD_<modulename>_EXAMPLES,
364 # MODULESD_<modulename>_ALIASES, MODULESD_<modulename>_ADDITION and MODULESD_<modulename>_DOCS).
366 # At the end the documentation specified with MODULESD_<modulename>_DOCS is installed.
367 generate_modulesd() {
368 debug-print-function ${FUNCNAME} $*
369 [ -n "${MODULES_OPTIONAL_USE}" ] && use !${MODULES_OPTIONAL_USE} && return
371 local currm_path currm currm_t t myIFS myVAR
372 local module_docs module_enabled module_aliases \
373 module_additions module_examples module_modinfo module_opts
375 for currm_path in ${@}
377 currm=${currm_path//*\/}
378 currm=$(echo ${currm} | tr '[:lower:]' '[:upper:]')
380 while [[ -z ${currm_t//*-*} ]]; do
381 currm_t=${currm_t/-/_}
384 module_docs="$(eval echo \${MODULESD_${currm_t}_DOCS})"
385 module_enabled="$(eval echo \${MODULESD_${currm_t}_ENABLED})"
386 module_aliases="$(eval echo \${#MODULESD_${currm_t}_ALIASES[*]})"
387 module_additions="$(eval echo \${#MODULESD_${currm_t}_ADDITIONS[*]})"
388 module_examples="$(eval echo \${#MODULESD_${currm_t}_EXAMPLES[*]})"
390 [[ ${module_aliases} -eq 0 ]] && unset module_aliases
391 [[ ${module_additions} -eq 0 ]] && unset module_additions
392 [[ ${module_examples} -eq 0 ]] && unset module_examples
394 # If we specify we dont want it, then lets exit, otherwise we assume
395 # that if its set, we do want it.
396 [[ ${module_enabled} == no ]] && return 0
398 # unset any unwanted variables.
399 for t in ${!module_*}
401 [[ -z ${!t} ]] && unset ${t}
404 [[ -z ${!module_*} ]] && return 0
406 # OK so now if we have got this far, then we know we want to continue
407 # and generate the modprobe.d file.
408 module_modinfo="$(modinfo -p ${currm_path}.${KV_OBJ})"
409 module_config="${T}/modulesd-${currm}"
411 ebegin "Preparing file for modprobe.d"
412 #-----------------------------------------------------------------------
413 echo "# modprobe.d configuration file for ${currm}" >> "${module_config}"
414 #-----------------------------------------------------------------------
415 [[ -n ${module_docs} ]] && \
416 echo "# For more information please read:" >> "${module_config}"
417 for t in ${module_docs}
419 echo "# ${t//*\/}" >> "${module_config}"
421 echo >> "${module_config}"
423 #-----------------------------------------------------------------------
424 if [[ ${module_aliases} -gt 0 ]]
426 echo "# Internal Aliases - Do not edit" >> "${module_config}"
427 echo "# ------------------------------" >> "${module_config}"
429 for((t=0; t<${module_aliases}; t++))
431 echo "alias $(eval echo \${MODULESD_${currm}_ALIASES[$t]})" \
432 >> "${module_config}"
434 echo '' >> "${module_config}"
437 #-----------------------------------------------------------------------
438 if [[ -n ${module_modinfo} ]]
440 echo >> "${module_config}"
441 echo "# Configurable module parameters" >> "${module_config}"
442 echo "# ------------------------------" >> "${module_config}"
444 IFS="$(echo -en "\n\b")"
446 for t in ${module_modinfo}
448 myVAR="$(echo ${t#*:} | grep -o "[^ ]*[0-9][ =][^ ]*" | tail -1 | grep -o "[0-9]")"
451 module_opts="${module_opts} ${t%%:*}:${myVAR}"
453 echo -e "# ${t%%:*}:\t${t#*:}" >> "${module_config}"
456 echo '' >> "${module_config}"
459 #-----------------------------------------------------------------------
460 if [[ $(eval echo \${MODULESD_${currm}_ALIASES[0]}) == guess ]]
462 # So lets do some guesswork eh?
463 if [[ -n ${module_opts} ]]
465 echo "# For Example..." >> "${module_config}"
466 echo "# --------------" >> "${module_config}"
467 for t in ${module_opts}
469 echo "# options ${currm} ${t//:*}=${t//*:}" >> "${module_config}"
471 echo '' >> "${module_config}"
473 elif [[ ${module_examples} -gt 0 ]]
475 echo "# For Example..." >> "${module_config}"
476 echo "# --------------" >> "${module_config}"
477 for((t=0; t<${module_examples}; t++))
479 echo "options $(eval echo \${MODULESD_${currm}_EXAMPLES[$t]})" \
480 >> "${module_config}"
482 echo '' >> "${module_config}"
485 #-----------------------------------------------------------------------
486 if [[ ${module_additions} -gt 0 ]]
488 for((t=0; t<${module_additions}; t++))
490 echo "$(eval echo \${MODULESD_${currm}_ADDITIONS[$t]})" \
491 >> "${module_config}"
493 echo '' >> "${module_config}"
496 #-----------------------------------------------------------------------
499 insinto /etc/modprobe.d
500 newins "${module_config}" "${currm_path//*\/}.conf"
502 # and install any documentation we might have.
503 [[ -n ${module_docs} ]] && dodoc ${module_docs}
511 # FUNCTION: find_module_params
512 # USAGE: A string "NAME(LIBDIR:SRCDIR:OBJDIR)"
513 # RETURN: The string "modulename:NAME libdir:LIBDIR srcdir:SRCDIR objdir:OBJDIR"
515 # Analyze the specification NAME(LIBDIR:SRCDIR:OBJDIR) of one module as described in MODULE_NAMES.
516 find_module_params() {
517 debug-print-function ${FUNCNAME} $*
519 local matched_offset=0 matched_opts=0 test="${@}" temp_var result
522 for((i=0; i<=${#test}; i++))
524 case ${test:${i}:1} in
525 \() matched_offset[0]=${i};;
526 \:) matched_opts=$((${matched_opts} + 1));
527 matched_offset[${matched_opts}]="${i}";;
528 \)) matched_opts=$((${matched_opts} + 1));
529 matched_offset[${matched_opts}]="${i}";;
533 for((i=0; i<=${matched_opts}; i++))
535 # i = offset were working on
537 # z = current offset - last offset
538 # temp_var = temporary name
540 0) tempvar=${test:0:${matched_offset[0]}};;
541 *) y=$((${matched_offset[$((${i} - 1))]} + 1))
542 z=$((${matched_offset[${i}]} - ${matched_offset[$((${i} - 1))]}));
544 tempvar=${test:${y}:${z}};;
548 0) result="${result} modulename:${tempvar}";;
549 1) result="${result} libdir:${tempvar}";;
550 2) result="${result} srcdir:${tempvar}";;
551 3) result="${result} objdir:${tempvar}";;
558 # default ebuild functions
559 # --------------------------------
561 # @FUNCTION: linux-mod_pkg_setup
563 # It checks the CONFIG_CHECK options (see linux-info.eclass(5)), verifies that the kernel is
564 # configured, verifies that the sources are prepared, verifies that the modules support is builtin
565 # in the kernel and sets the object extension KV_OBJ.
566 linux-mod_pkg_setup() {
567 debug-print-function ${FUNCNAME} $*
568 [ -n "${MODULES_OPTIONAL_USE}" ] && use !${MODULES_OPTIONAL_USE} && return
570 local is_bin="${MERGE_TYPE}"
572 # If we are installing a binpkg, take a different path.
573 # use MERGE_TYPE if available (eapi>=4); else use non-PMS EMERGE_FROM (eapi<4)
574 if has ${EAPI} 0 1 2 3; then
575 is_bin=${EMERGE_FROM}
578 if [[ ${is_bin} == binary ]]; then
579 linux-mod_pkg_setup_binary
583 # External modules use kernel symbols (bug #591832)
584 CONFIG_CHECK+=" !TRIM_UNUSED_KSYMS"
586 linux-info_pkg_setup;
587 require_configured_kernel
590 [[ -n ${MODULE_NAMES} ]] && check_modules_supported
592 # Commented out with permission from johnm until a fixed version for arches
593 # who intentionally use different kernel and userland compilers can be
594 # introduced - Jason Wever <weeve@gentoo.org>, 23 Oct 2005
598 # @FUNCTION: linux-mod_pkg_setup_binary
600 # Perform all kernel option checks non-fatally, as the .config and
601 # /proc/config.gz might not be present. Do not do anything that requires kernel
603 linux-mod_pkg_setup_binary() {
604 debug-print-function ${FUNCNAME} $*
605 local new_CONFIG_CHECK
606 # ~ needs always to be quoted, else bash expands it.
607 for config in $CONFIG_CHECK ; do
609 [[ ${config:0:1} == "~" ]] && optional=''
610 new_CONFIG_CHECK="${new_CONFIG_CHECK} ${optional}${config}"
612 CONFIG_CHECK="${new_CONFIG_CHECK}"
613 linux-info_pkg_setup;
616 strip_modulenames() {
617 debug-print-function ${FUNCNAME} $*
620 for i in ${MODULE_IGNORE}; do
621 MODULE_NAMES=${MODULE_NAMES//${i}(*}
625 # @FUNCTION: linux-mod_src_compile
627 # It compiles all the modules specified in MODULE_NAMES. For each module the econf command is
628 # executed only if ECONF_PARAMS is defined, the name of the target is specified by BUILD_TARGETS
629 # while the options are in BUILD_PARAMS (all the modules share these variables). The compilation
630 # happens inside ${srcdir}.
632 # Look at the description of these variables for more details.
633 linux-mod_src_compile() {
634 debug-print-function ${FUNCNAME} $*
635 [ -n "${MODULES_OPTIONAL_USE}" ] && use !${MODULES_OPTIONAL_USE} && return
637 local modulename libdir srcdir objdir i n myABI="${ABI}"
641 BUILD_TARGETS=${BUILD_TARGETS:-clean module}
645 for i in ${MODULE_NAMES}
647 unset libdir srcdir objdir
648 for n in $(find_module_params ${i})
650 eval ${n/:*}=${n/*:/}
652 libdir=${libdir:-misc}
653 srcdir=${srcdir:-${S}}
654 objdir=${objdir:-${srcdir}}
656 if [ ! -f "${srcdir}/.built" ];
659 ln -s "${S}"/Module.symvers Module.symvers
660 einfo "Preparing ${modulename} module"
661 if [[ -n ${ECONF_PARAMS} ]]
663 econf ${ECONF_PARAMS} || \
664 die "Unable to run econf ${ECONF_PARAMS}"
667 # This looks messy, but it is needed to handle multiple variables
668 # being passed in the BUILD_* stuff where the variables also have
669 # spaces that must be preserved. If don't do this, then the stuff
670 # inside the variables gets used as targets for Make, which then
672 eval "emake HOSTCC=\"$(tc-getBUILD_CC)\" \
673 CROSS_COMPILE=${CHOST}- \
674 LDFLAGS=\"$(get_abi_LDFLAGS)\" \
678 || die "Unable to emake HOSTCC="$(tc-getBUILD_CC)" CROSS_COMPILE=${CHOST}- LDFLAGS="$(get_abi_LDFLAGS)" ${BUILD_FIXES} ${BUILD_PARAMS} ${BUILD_TARGETS}"
680 touch "${srcdir}"/.built
688 # @FUNCTION: linux-mod_src_install
690 # It install the modules specified in MODULES_NAME. The modules should be inside the ${objdir}
691 # directory and they are installed inside /lib/modules/${KV_FULL}/${libdir}.
693 # The modprobe.d configuration file is automatically generated if the
694 # MODULESD_<modulename>_* variables are defined. The only way to stop this process is by
695 # setting MODULESD_<modulename>_ENABLED=no. At the end the documentation specified via
696 # MODULESD_<modulename>_DOCS is also installed.
698 # Look at the description of these variables for more details.
699 linux-mod_src_install() {
700 debug-print-function ${FUNCNAME} $*
701 [ -n "${MODULES_OPTIONAL_USE}" ] && use !${MODULES_OPTIONAL_USE} && return
703 local modulename libdir srcdir objdir i n
706 for i in ${MODULE_NAMES}
708 unset libdir srcdir objdir
709 for n in $(find_module_params ${i})
711 eval ${n/:*}=${n/*:/}
713 libdir=${libdir:-misc}
714 srcdir=${srcdir:-${S}}
715 objdir=${objdir:-${srcdir}}
717 einfo "Installing ${modulename} module"
718 cd "${objdir}" || die "${objdir} does not exist"
719 insinto /lib/modules/${KV_FULL}/${libdir}
720 doins ${modulename}.${KV_OBJ} || die "doins ${modulename}.${KV_OBJ} failed"
723 generate_modulesd "${objdir}/${modulename}"
727 # @FUNCTION: linux-mod_pkg_preinst
729 # It checks what to do after having merged the package.
730 linux-mod_pkg_preinst() {
731 debug-print-function ${FUNCNAME} $*
732 [ -n "${MODULES_OPTIONAL_USE}" ] && use !${MODULES_OPTIONAL_USE} && return
734 [ -d "${D%/}/lib/modules" ] && UPDATE_DEPMOD=true || UPDATE_DEPMOD=false
735 [ -d "${D%/}/lib/modules" ] && UPDATE_MODULEDB=true || UPDATE_MODULEDB=false
738 # @FUNCTION: linux-mod_pkg_postinst
740 # It executes /sbin/depmod and adds the package to the /var/lib/module-rebuild/moduledb
741 # database (if ${D}/lib/modules is created)"
742 linux-mod_pkg_postinst() {
743 debug-print-function ${FUNCNAME} $*
744 [ -n "${MODULES_OPTIONAL_USE}" ] && use !${MODULES_OPTIONAL_USE} && return
746 ${UPDATE_DEPMOD} && update_depmod;
747 ${UPDATE_MODULEDB} && update_moduledb;
750 # @FUNCTION: linux-mod_pkg_postrm
752 # It removes the package from the /var/lib/module-rebuild/moduledb database but it doens't
753 # call /sbin/depmod because the modules are still installed.
754 linux-mod_pkg_postrm() {
755 debug-print-function ${FUNCNAME} $*
756 [ -n "${MODULES_OPTIONAL_USE}" ] && use !${MODULES_OPTIONAL_USE} && return