/[gentoo-x86]/eclass/linux-mod.eclass
Gentoo

Diff of /eclass/linux-mod.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.107 Revision 1.111
1# Copyright 1999-2012 Gentoo Foundation 1# Copyright 1999-2012 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/linux-mod.eclass,v 1.107 2012/08/30 23:52:59 mpagano Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/linux-mod.eclass,v 1.111 2013/03/26 07:36:11 ssuominen Exp $
4 4
5# @ECLASS: linux-mod.eclass 5# @ECLASS: linux-mod.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# kernel-misc@gentoo.org 7# kernel-misc@gentoo.org
8# @AUTHOR: 8# @AUTHOR:
75# make ${BUILD_PARAMS} ${BUILD_TARGETS} 75# make ${BUILD_PARAMS} ${BUILD_TARGETS}
76# cd "${S}" 76# cd "${S}"
77# insinto /lib/modules/${KV_FULL}/usb 77# insinto /lib/modules/${KV_FULL}/usb
78# doins module_usb.${KV_OBJ} 78# doins module_usb.${KV_OBJ}
79 79
80# There is also support for automated modprobe.d/modules.d(2.4) file generation. 80# There is also support for automated modprobe.d file generation.
81# This can be explicitly enabled by setting any of the following variables. 81# This can be explicitly enabled by setting any of the following variables.
82 82
83# @ECLASS-VARIABLE: MODULESD_<modulename>_ENABLED 83# @ECLASS-VARIABLE: MODULESD_<modulename>_ENABLED
84# @DESCRIPTION: 84# @DESCRIPTION:
85# This is used to disable the modprobe.d/modules.d file generation otherwise the file will be 85# This is used to disable the modprobe.d file generation otherwise the file will be
86# always generated (unless no MODULESD_<modulename>_* variable is provided). Set to "no" to disable 86# always generated (unless no MODULESD_<modulename>_* variable is provided). Set to "no" to disable
87# the generation of the file and the installation of the documentation. 87# the generation of the file and the installation of the documentation.
88 88
89# @ECLASS-VARIABLE: MODULESD_<modulename>_EXAMPLES 89# @ECLASS-VARIABLE: MODULESD_<modulename>_EXAMPLES
90# @DESCRIPTION: 90# @DESCRIPTION:
91# This is a bash array containing a list of examples which should 91# This is a bash array containing a list of examples which should
92# be used. If you want us to try and take a guess set this to "guess". 92# be used. If you want us to try and take a guess set this to "guess".
93# 93#
94# For each array_component it's added an options line in the modprobe.d/modules.d file 94# For each array_component it's added an options line in the modprobe.d file
95# 95#
96# options array_component 96# options array_component
97# 97#
98# where array_component is "<modulename> options" (see modprobe.conf(5)) 98# where array_component is "<modulename> options" (see modprobe.conf(5))
99 99
100# @ECLASS-VARIABLE: MODULESD_<modulename>_ALIASES 100# @ECLASS-VARIABLE: MODULESD_<modulename>_ALIASES
101# @DESCRIPTION: 101# @DESCRIPTION:
102# This is a bash array containing a list of associated aliases. 102# This is a bash array containing a list of associated aliases.
103# 103#
104# For each array_component it's added an alias line in the modprobe.d/modules.d file 104# For each array_component it's added an alias line in the modprobe.d file
105# 105#
106# alias array_component 106# alias array_component
107# 107#
108# where array_component is "wildcard <modulename>" (see modprobe.conf(5)) 108# where array_component is "wildcard <modulename>" (see modprobe.conf(5))
109 109
125inherit eutils linux-info multilib 125inherit eutils linux-info multilib
126EXPORT_FUNCTIONS pkg_setup pkg_preinst pkg_postinst src_install src_compile pkg_postrm 126EXPORT_FUNCTIONS pkg_setup pkg_preinst pkg_postinst src_install src_compile pkg_postrm
127 127
128IUSE="kernel_linux" 128IUSE="kernel_linux"
129SLOT="0" 129SLOT="0"
130DESCRIPTION="Based on the $ECLASS eclass" 130if ! [[ ${PN} == kmod ]]; then
131RDEPEND="kernel_linux? ( virtual/modutils )" 131 RDEPEND="kernel_linux? ( virtual/modutils )"
132DEPEND="${RDEPEND} 132 DEPEND="${RDEPEND}
133 sys-apps/sed 133 sys-apps/sed
134 kernel_linux? ( virtual/linux-sources )" 134 kernel_linux? ( virtual/linux-sources )"
135fi
135 136
136# eclass utilities 137# eclass utilities
137# ---------------------------------- 138# ----------------------------------
138 139
139check_vermagic() { 140check_vermagic() {
234 fi 235 fi
235} 236}
236 237
237# internal function 238# internal function
238# 239#
239# FUNCTION: update_modules
240# DESCRIPTION:
241# It calls the update-modules utility.
242update_modules() {
243 debug-print-function ${FUNCNAME} $*
244
245 if [ -x /sbin/update-modules ] && \
246 grep -v -e "^#" -e "^$" "${D}"/etc/modules.d/* >/dev/null 2>&1; then
247 ebegin "Updating modules.conf"
248 /sbin/update-modules
249 eend $?
250 elif [ -x /sbin/update-modules ] && \
251 grep -v -e "^#" -e "^$" "${D}"/etc/modules.d/* >/dev/null 2>&1; then
252 ebegin "Updating modules.conf"
253 /sbin/update-modules
254 eend $?
255 fi
256}
257
258# internal function
259#
260# FUNCTION: move_old_moduledb 240# FUNCTION: move_old_moduledb
261# DESCRIPTION: 241# DESCRIPTION:
262# It updates the location of the database used by the module-rebuild utility. 242# It updates the location of the database used by the module-rebuild utility.
263move_old_moduledb() { 243move_old_moduledb() {
264 debug-print-function ${FUNCNAME} $* 244 debug-print-function ${FUNCNAME} $*
354 334
355# internal function 335# internal function
356# 336#
357# FUNCTION: 337# FUNCTION:
358# USAGE: /path/to/the/modulename_without_extension 338# USAGE: /path/to/the/modulename_without_extension
359# RETURN: A file in /etc/modules.d/ (kernel < 2.6) or /etc/modprobe.d/ (kernel >= 2.6) 339# RETURN: A file in /etc/modprobe.d
360# DESCRIPTION: 340# DESCRIPTION:
361# This function will generate and install the neccessary modprobe.d/modules.d file from the 341# This function will generate and install the neccessary modprobe.d file from the
362# information contained in the modules exported parms. 342# information contained in the modules exported parms.
363# (see the variables MODULESD_<modulename>_ENABLED, MODULESD_<modulename>_EXAMPLES, 343# (see the variables MODULESD_<modulename>_ENABLED, MODULESD_<modulename>_EXAMPLES,
364# MODULESD_<modulename>_ALIASES, MODULESD_<modulename>_ADDITION and MODULESD_<modulename>_DOCS). 344# MODULESD_<modulename>_ALIASES, MODULESD_<modulename>_ADDITION and MODULESD_<modulename>_DOCS).
365# 345#
366# At the end the documentation specified with MODULESD_<modulename>_DOCS is installed. 346# At the end the documentation specified with MODULESD_<modulename>_DOCS is installed.
401 done 381 done
402 382
403 [[ -z ${!module_*} ]] && return 0 383 [[ -z ${!module_*} ]] && return 0
404 384
405 # OK so now if we have got this far, then we know we want to continue 385 # OK so now if we have got this far, then we know we want to continue
406 # and generate the modules.d file. 386 # and generate the modprobe.d file.
407 module_modinfo="$(modinfo -p ${currm_path}.${KV_OBJ})" 387 module_modinfo="$(modinfo -p ${currm_path}.${KV_OBJ})"
408 module_config="${T}/modulesd-${currm}" 388 module_config="${T}/modulesd-${currm}"
409 389
410 ebegin "Preparing file for modules.d" 390 ebegin "Preparing file for modprobe.d"
411 #----------------------------------------------------------------------- 391 #-----------------------------------------------------------------------
412 echo "# modules.d configuration file for ${currm}" >> "${module_config}" 392 echo "# modprobe.d configuration file for ${currm}" >> "${module_config}"
413 #----------------------------------------------------------------------- 393 #-----------------------------------------------------------------------
414 [[ -n ${module_docs} ]] && \ 394 [[ -n ${module_docs} ]] && \
415 echo "# For more information please read:" >> "${module_config}" 395 echo "# For more information please read:" >> "${module_config}"
416 for t in ${module_docs} 396 for t in ${module_docs}
417 do 397 do
493 fi 473 fi
494 474
495 #----------------------------------------------------------------------- 475 #-----------------------------------------------------------------------
496 476
497 # then we install it 477 # then we install it
498 if kernel_is ge 2 6; then
499 insinto /etc/modprobe.d 478 insinto /etc/modprobe.d
500 else
501 insinto /etc/modules.d
502 fi
503 newins "${module_config}" "${currm_path//*\/}.conf" 479 newins "${module_config}" "${currm_path//*\/}.conf"
504 480
505 # and install any documentation we might have. 481 # and install any documentation we might have.
506 [[ -n ${module_docs} ]] && dodoc ${module_docs} 482 [[ -n ${module_docs} ]] && dodoc ${module_docs}
507 done 483 done
686# @FUNCTION: linux-mod_src_install 662# @FUNCTION: linux-mod_src_install
687# @DESCRIPTION: 663# @DESCRIPTION:
688# It install the modules specified in MODULES_NAME. The modules should be inside the ${objdir} 664# It install the modules specified in MODULES_NAME. The modules should be inside the ${objdir}
689# directory and they are installed inside /lib/modules/${KV_FULL}/${libdir}. 665# directory and they are installed inside /lib/modules/${KV_FULL}/${libdir}.
690# 666#
691# The modprobe.d/modules.d configuration file is automatically generated if the 667# The modprobe.d configuration file is automatically generated if the
692# MODULESD_<modulename>_* variables are defined. The only way to stop this process is by 668# MODULESD_<modulename>_* variables are defined. The only way to stop this process is by
693# setting MODULESD_<modulename>_ENABLED=no. At the end the documentation specified via 669# setting MODULESD_<modulename>_ENABLED=no. At the end the documentation specified via
694# MODULESD_<modulename>_DOCS is also installed. 670# MODULESD_<modulename>_DOCS is also installed.
695# 671#
696# Look at the description of these variables for more details. 672# Look at the description of these variables for more details.
726# It checks what to do after having merged the package. 702# It checks what to do after having merged the package.
727linux-mod_pkg_preinst() { 703linux-mod_pkg_preinst() {
728 debug-print-function ${FUNCNAME} $* 704 debug-print-function ${FUNCNAME} $*
729 705
730 [ -d "${D}lib/modules" ] && UPDATE_DEPMOD=true || UPDATE_DEPMOD=false 706 [ -d "${D}lib/modules" ] && UPDATE_DEPMOD=true || UPDATE_DEPMOD=false
731 [ -d "${D}etc/modules.d" ] && UPDATE_MODULES=true || UPDATE_MODULES=false
732 [ -d "${D}lib/modules" ] && UPDATE_MODULEDB=true || UPDATE_MODULEDB=false 707 [ -d "${D}lib/modules" ] && UPDATE_MODULEDB=true || UPDATE_MODULEDB=false
733} 708}
734 709
735# @FUNCTION: linux-mod_pkg_postinst 710# @FUNCTION: linux-mod_pkg_postinst
736# @DESCRIPTION: 711# @DESCRIPTION:
737# It executes /sbin/depmod and adds the package to the /var/lib/module-rebuild/moduledb 712# It executes /sbin/depmod and adds the package to the /var/lib/module-rebuild/moduledb
738# database (if ${D}/lib/modules is created) and it runs /sbin/update-modules
739# (if ${D}/etc/modules.d is created). 713# database (if ${D}/lib/modules is created)"
740linux-mod_pkg_postinst() { 714linux-mod_pkg_postinst() {
741 debug-print-function ${FUNCNAME} $* 715 debug-print-function ${FUNCNAME} $*
742 716
743 ${UPDATE_DEPMOD} && update_depmod; 717 ${UPDATE_DEPMOD} && update_depmod;
744 ${UPDATE_MODULES} && update_modules;
745 ${UPDATE_MODULEDB} && update_moduledb; 718 ${UPDATE_MODULEDB} && update_moduledb;
746} 719}
747 720
748# @FUNCTION: linux-mod_pkg_postrm 721# @FUNCTION: linux-mod_pkg_postrm
749# @DESCRIPTION: 722# @DESCRIPTION:
750# It removes the package from the /var/lib/module-rebuild/moduledb database but it doens't 723# It removes the package from the /var/lib/module-rebuild/moduledb database but it doens't
751# call /sbin/depmod and /sbin/update-modules because the modules are still installed. 724# call /sbin/depmod because the modules are still installed.
752linux-mod_pkg_postrm() { 725linux-mod_pkg_postrm() {
753 debug-print-function ${FUNCNAME} $* 726 debug-print-function ${FUNCNAME} $*
754 remove_moduledb; 727 remove_moduledb;
755} 728}

Legend:
Removed from v.1.107  
changed lines
  Added in v.1.111

  ViewVC Help
Powered by ViewVC 1.1.20