/[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.20 Revision 1.85
1# Copyright 1999-2004 Gentoo Foundation 1# Copyright 1999-2004 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.20 2005/01/15 21:46:00 johnm Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/linux-mod.eclass,v 1.85 2008/10/31 21:25:56 dsd Exp $
4 4
5# Description: This eclass is used to interface with linux-info in such a way 5# Description: This eclass is used to interface with linux-info in such a way
6# to provide the functionality required and initial functions 6# to provide the functionality required and initial functions
7# required to install external modules against a kernel source 7# required to install external modules against a kernel source
8# tree. 8# tree.
9# 9#
10# Maintainer: John Mylchreest <johnm@gentoo.org> 10# Author(s): John Mylchreest <johnm@gentoo.org>,
11# Copyright 2004 Gentoo Linux 11# Stefan Schweizer <genstef@gentoo.org>
12# Maintainer: kernel-misc@gentoo.org
12# 13#
13# Please direct your bugs to the current eclass maintainer :) 14# Please direct your bugs to the current eclass maintainer :)
14 15
15# A Couple of env vars are available to effect usage of this eclass 16# A Couple of env vars are available to effect usage of this eclass
16# These are as follows: 17# These are as follows:
17# 18#
18# Env Var Option Default Description 19# Env Var Option Default Description
19# KERNEL_DIR <string> /usr/src/linux The directory containing kernel 20# KERNEL_DIR <string> /usr/src/linux The directory containing kernel
20# the target kernel sources. 21# the target kernel sources.
22# ECONF_PARAMS <string> The parameters to pass to econf.
23# If this is not set, then econf
24# isn't run.
21# BUILD_PARAMS <string> The parameters to pass to make. 25# BUILD_PARAMS <string> The parameters to pass to emake.
22# BUILD_TARGETS <string> clean modules The build targets to pass to make. 26# BUILD_TARGETS <string> clean modules The build targets to pass to
27# make.
23# MODULE_NAMES <string> This is the modules which are 28# MODULE_NAMES <string> This is the modules which are
24# to be built automatically using the 29# to be built automatically using
25# default pkg_compile/install. They 30# the default pkg_compile/install.
26# are explained properly below. 31# They are explained properly
27# It will only make BUILD_TARGETS once 32# below. It will only make
33# BUILD_TARGETS once in any
28# in any directory. 34# directory.
29# NO_MODULESD <string> Set this to something to prevent
30# modulesd file generation
31
32 35
33# MODULE_NAMES - Detailed Overview 36# MODULE_NAMES - Detailed Overview
34# 37#
35# The structure of each MODULE_NAMES entry is as follows: 38# The structure of each MODULE_NAMES entry is as follows:
36# modulename(libmodulesdir:modulesourcedir) 39# modulename(libdir:srcdir:objdir)
40#
41# modulename = name of the module file excluding the .ko
42# libdir = place in system modules directory where module is installed:
43# srcdir = place for ebuild to cd to before running make
44# objdir = place the .ko and objects are located after make runs
45#
46# To get an idea of how these variables are used, here's a few lines
47# of code from around line 540 in this eclass:
48#
49# einfo "Installing ${modulename} module"
50# cd ${objdir} || die "${objdir} does not exist"
51# insinto /lib/modules/${KV_FULL}/${libdir}
52# doins ${modulename}.${KV_OBJ} || die "doins ${modulename}.${KV_OBJ} failed"
53#
37# for example: 54# for example:
38# MODULE_NAMES="module_pci(pci:${S}/pci) module_usb(usb:${S}/usb)" 55# MODULE_NAMES="module_pci(pci:${S}/pci:${S}) module_usb(usb:${S}/usb:${S})"
39# 56#
40# what this would do is 57# what this would do is
41# cd ${S}/pci 58# cd ${S}/pci
42# make ${BUILD_PARAMS} ${BUILD_TARGETS} 59# make ${BUILD_PARAMS} ${BUILD_TARGETS}
60# cd ${S}
43# insinto /lib/modules/${KV_FULL}/pci 61# insinto /lib/modules/${KV_FULL}/pci
44# doins module_pci.${KV_OBJ} 62# doins module_pci.${KV_OBJ}
45# 63#
46# cd ${S}/usb 64# cd ${S}/usb
47# make ${BUILD_PARAMS} ${BUILD_TARGETS} 65# make ${BUILD_PARAMS} ${BUILD_TARGETS}
66# cd ${S}
48# insinto /lib/modules/${KV_FULL}/usb 67# insinto /lib/modules/${KV_FULL}/usb
49# doins module_usb.${KV_OBJ} 68# doins module_usb.${KV_OBJ}
50# 69#
51# if the modulessourcedir isnt specified, it assumes ${S} 70# if the srcdir isnt specified, it assumes ${S}
52# if the libmodulesdir isnt specified, it assumes misc. 71# if the libdir isnt specified, it assumes misc.
53# if no seperator is defined ":" then it assumes the argument is modulesourcedir 72# if the objdir isnt specified, it assumes srcdir
54 73
55inherit linux-info 74# There is also support for automated modprobe.d/modules.d(2.4) file generation.
56ECLASS=linux-mod 75# This can be explicitly enabled by setting any of the following variables.
57INHERITED="$INHERITED $ECLASS" 76#
77#
78# MODULESD_${modulename}_ENABLED This enables the modules.d file
79# generation even if we dont
80# specify any additional info.
81# MODULESD_${modulename}_EXAMPLES This is a bash array containing
82# a list of examples which should
83# be used. If you want us to try and
84# take a guess. Set this to "guess"
85# MODULESD_${modulename}_ALIASES This is a bash array containing
86# a list of associated aliases.
87# MODULESD_${modulename}_ADDITIONS This is a bash array containing
88# A list of additional things to
89# add to the bottom of the file.
90# This can be absolutely anything.
91# Each entry is a new line.
92# MODULES_${modulename}_DOCS This is a string list which contains
93# the full path to any associated
94# documents for $modulename
95
96# The order of these is important as both of linux-info and eutils contain
97# set_arch_to_kernel and set_arch_to_portage functions and the ones in eutils
98# are deprecated in favor of the ones in linux-info.
99# See http://bugs.gentoo.org/show_bug.cgi?id=127506
100
101inherit eutils linux-info multilib
58EXPORT_FUNCTIONS pkg_setup src_install pkg_postinst src_compile 102EXPORT_FUNCTIONS pkg_setup pkg_preinst pkg_postinst src_install src_compile pkg_postrm
59 103
104IUSE="kernel_linux"
105SLOT="0"
60DESCRIPTION="Based on the $ECLASS eclass" 106DESCRIPTION="Based on the $ECLASS eclass"
61SLOT=0 107RDEPEND="kernel_linux? ( virtual/modutils )"
62DEPEND="virtual/linux-sources 108DEPEND="${RDEPEND}
63 sys-apps/sed 109 sys-apps/sed"
64 virtual/modutils"
65 110
66# eclass utilities 111# eclass utilities
67# ---------------------------------- 112# ----------------------------------
68 113
114check_vermagic() {
115 debug-print-function ${FUNCNAME} $*
116
117 local curr_gcc_ver=$(gcc -dumpversion)
118 local tmpfile old_chost old_gcc_ver result=0
119
120 tmpfile=`find ${KV_DIR}/ -iname "*.o.cmd" -exec grep usr/lib/gcc {} \; -quit`
121 tmpfile=${tmpfile//*usr/lib}
122 tmpfile=${tmpfile//\/include*}
123 old_chost=${tmpfile//*gcc\/}
124 old_chost=${old_chost//\/*}
125 old_gcc_ver=${tmpfile//*\/}
126
127 if [[ -z ${old_gcc_ver} || -z ${old_chost} ]]; then
128 ewarn ""
129 ewarn "Unable to detect what version of GCC was used to compile"
130 ewarn "the kernel. Build will continue, but you may experience problems."
131 elif [[ ${curr_gcc_ver} != ${old_gcc_ver} ]]; then
132 ewarn ""
133 ewarn "The version of GCC you are using (${curr_gcc_ver}) does"
134 ewarn "not match the version of GCC used to compile the"
135 ewarn "kernel (${old_gcc_ver})."
136 result=1
137 elif [[ ${CHOST} != ${old_chost} ]]; then
138 ewarn ""
139 ewarn "The current CHOST (${CHOST}) does not match the chost"
140 ewarn "used when compiling the kernel (${old_chost})."
141 result=1
142 fi
143
144 if [[ ${result} -gt 0 ]]; then
145 ewarn ""
146 ewarn "Build will not continue, because you will experience problems."
147 ewarn "To fix this either change the version of GCC you wish to use"
148 ewarn "to match the kernel, or recompile the kernel first."
149 die "GCC Version Mismatch."
150 fi
151}
152
69use_m() { 153use_m() {
154 debug-print-function ${FUNCNAME} $*
155
70 # if we haven't determined the version yet, we need too. 156 # if we haven't determined the version yet, we need too.
71 get_version; 157 get_version;
72 158
73 # if the kernel version is greater than 2.6.6 then we should use 159 # if the kernel version is greater than 2.6.6 then we should use
74 # M= instead of SUBDIRS= 160 # M= instead of SUBDIRS=
75 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -gt 5 -a ${KV_PATCH} -gt 5 ] && \ 161 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -gt 5 -a ${KV_PATCH} -gt 5 ] && \
76 return 0 || return 1 162 return 0 || return 1
77} 163}
78 164
79convert_to_m() { 165convert_to_m() {
80 [ ! -f "${1}" ] && die "convert_to_m() requires a filename as an argument" 166 debug-print-function ${FUNCNAME} $*
167
81 if use_m 168 if use_m
82 then 169 then
170 [ ! -f "${1}" ] && \
171 die "convert_to_m() requires a filename as an argument"
83 ebegin "Converting ${1/${WORKDIR}\//} to use M= instead of SUBDIRS=" 172 ebegin "Converting ${1/${WORKDIR}\//} to use M= instead of SUBDIRS="
84 sed -i 's:SUBDIRS=:M=:g' ${1} 173 sed -i 's:SUBDIRS=:M=:g' ${1}
85 eend $? 174 eend $?
86 fi 175 fi
87} 176}
88 177
89update_depmod() { 178update_depmod() {
179 debug-print-function ${FUNCNAME} $*
180
90 # if we haven't determined the version yet, we need too. 181 # if we haven't determined the version yet, we need too.
91 get_version; 182 get_version;
92 183
93 ebegin "Updating module dependencies for ${KV_FULL}" 184 ebegin "Updating module dependencies for ${KV_FULL}"
94 if [ -r ${KV_OUT_DIR}/System.map ] 185 if [ -r ${KV_OUT_DIR}/System.map ]
95 then 186 then
96 depmod -ae -F ${KV_OUT_DIR}/System.map -b ${ROOT} -r ${KV_FULL} 187 depmod -ae -F ${KV_OUT_DIR}/System.map -b ${ROOT} -r ${KV_FULL}
97 eend $? 188 eend $?
103 ewarn 194 ewarn
104 fi 195 fi
105} 196}
106 197
107update_modules() { 198update_modules() {
108 if [ -x /sbin/modules-update ] ; 199 debug-print-function ${FUNCNAME} $*
109 then 200
201 if [ -x /sbin/update-modules ] && \
202 grep -v -e "^#" -e "^$" ${D}/etc/modules.d/* >/dev/null 2>&1; then
110 ebegin "Updating modules.conf" 203 ebegin "Updating modules.conf"
111 /sbin/modules-update 204 /sbin/update-modules
112 eend $? 205 eend $?
206 elif [ -x /sbin/update-modules ] && \
207 grep -v -e "^#" -e "^$" ${D}/etc/modules.d/* >/dev/null 2>&1; then
208 ebegin "Updating modules.conf"
209 /sbin/update-modules
210 eend $?
211 fi
212}
213
214move_old_moduledb() {
215 debug-print-function ${FUNCNAME} $*
216
217 local OLDDIR=${ROOT}/usr/share/module-rebuild/
218 local NEWDIR=${ROOT}/var/lib/module-rebuild/
219
220 if [[ -f ${OLDDIR}/moduledb ]]; then
221 [[ ! -d ${NEWDIR} ]] && mkdir -p ${NEWDIR}
222 [[ ! -f ${NEWDIR}/moduledb ]] && \
223 mv ${OLDDIR}/moduledb ${NEWDIR}/moduledb
224 rm -f ${OLDDIR}/*
225 rmdir ${OLDDIR}
226 fi
227}
228
229update_moduledb() {
230 debug-print-function ${FUNCNAME} $*
231
232 local MODULEDB_DIR=${ROOT}/var/lib/module-rebuild/
233 move_old_moduledb
234
235 if [[ ! -f ${MODULEDB_DIR}/moduledb ]]; then
236 [[ ! -d ${MODULEDB_DIR} ]] && mkdir -p ${MODULEDB_DIR}
237 touch ${MODULEDB_DIR}/moduledb
238 fi
239
240 if ! grep -qs ${CATEGORY}/${PN}-${PVR} ${MODULEDB_DIR}/moduledb ; then
241 einfo "Adding module to moduledb."
242 echo "a:1:${CATEGORY}/${PN}-${PVR}" >> ${MODULEDB_DIR}/moduledb
243 fi
244}
245
246remove_moduledb() {
247 debug-print-function ${FUNCNAME} $*
248
249 local MODULEDB_DIR=${ROOT}/var/lib/module-rebuild/
250 move_old_moduledb
251
252 if grep -qs ${CATEGORY}/${PN}-${PVR} ${MODULEDB_DIR}/moduledb ; then
253 einfo "Removing ${CATEGORY}/${PN}-${PVR} from moduledb."
254 sed -i -e "/.*${CATEGORY}\/${PN}-${PVR}.*/d" ${MODULEDB_DIR}/moduledb
113 fi 255 fi
114} 256}
115 257
116set_kvobj() { 258set_kvobj() {
259 debug-print-function ${FUNCNAME} $*
260
117 if kernel_is 2 6 261 if kernel_is 2 6
118 then 262 then
119 KV_OBJ="ko" 263 KV_OBJ="ko"
120 else 264 else
121 KV_OBJ="o" 265 KV_OBJ="o"
122 fi 266 fi
267 # Do we really need to know this?
268 # Lets silence it.
123 einfo "Using KV_OBJ=${KV_OBJ}" 269 # einfo "Using KV_OBJ=${KV_OBJ}"
270}
271
272get-KERNEL_CC() {
273 debug-print-function ${FUNCNAME} $*
274
275 if [[ -n ${KERNEL_CC} ]] ; then
276 echo "${KERNEL_CC}"
277 return
278 fi
279
280 local kernel_cc
281 if [ -n "${KERNEL_ABI}" ]; then
282 # In future, an arch might want to define CC_$ABI
283 #kernel_cc="$(get_abi_CC)"
284 #[ -z "${kernel_cc}" ] &&
285 kernel_cc="$(tc-getCC $(ABI=${KERNEL_ABI} get_abi_CHOST))"
286 else
287 kernel_cc=$(tc-getCC)
288 fi
289 echo "${kernel_cc}"
124} 290}
125 291
126generate_modulesd() { 292generate_modulesd() {
293 debug-print-function ${FUNCNAME} $*
294
127 # This function will generate the neccessary modules.d file from the 295 # This function will generate the neccessary modules.d file from the
128 # information contained in the modules exported parms 296 # information contained in the modules exported parms
129 297
130 local selectedmodule selectedmodule_full selectedmodulevars parameter modinfop arg xifs temp 298 local currm_path currm currm_t t myIFS myVAR
131 local module_docs module_opts module_aliases module_config 299 local module_docs module_enabled module_aliases \
132 300 module_additions module_examples module_modinfo module_opts
133 for arg in ${@} 301
302 for currm_path in ${@}
134 do 303 do
135 selectedmodule_full="${arg}" 304 currm=${currm_path//*\/}
136 # strip the directory 305 currm=$(echo ${currm} | tr '[:lower:]' '[:upper:]')
137 selectedmodule="${selectedmodule_full/*\//}" 306 currm_t=${currm}
138 # convert the modulename to uppercase 307 while [[ -z ${currm_t//*-*} ]]; do
139 selectedmodule="$(echo ${selectedmodule} | tr '[:lower:]' '[:upper:]')" 308 currm_t=${currm_t/-/_}
309 done
140 310
141 module_docs="MODULESD_${selectedmodule}_DOCS" 311 module_docs="$(eval echo \${MODULESD_${currm_t}_DOCS})"
312 module_enabled="$(eval echo \${MODULESD_${currm_t}_ENABLED})"
142 module_aliases="$(eval echo \$\{#MODULESD_${selectedmodule}_ALIASES[*]\})" 313 module_aliases="$(eval echo \${#MODULESD_${currm_t}_ALIASES[*]})"
314 module_additions="$(eval echo \${#MODULESD_${currm_t}_ADDITIONS[*]})"
315 module_examples="$(eval echo \${#MODULESD_${currm_t}_EXAMPLES[*]})"
316
143 [ ${module_aliases} == 0 ] && unset module_aliases 317 [[ ${module_aliases} -eq 0 ]] && unset module_aliases
144 module_docs="${!module_docs}" 318 [[ ${module_additions} -eq 0 ]] && unset module_additions
145 modinfop="$(modinfo -p ${selectedmodule_full}.${KV_OBJ})" 319 [[ ${module_examples} -eq 0 ]] && unset module_examples
146 320
147 # By now we know if there is anything we can use to generate a file with 321 # If we specify we dont want it, then lets exit, otherwise we assume
148 # so unset empty vars and bail out if we find nothing. 322 # that if its set, we do want it.
323 [[ ${module_enabled} == no ]] && return 0
324
325 # unset any unwanted variables.
149 for parameter in ${!module_*} 326 for t in ${!module_*}
150 do 327 do
151 [ -z "${!parameter}" ] && unset ${parameter} 328 [[ -z ${!t} ]] && unset ${t}
152 done 329 done
153 [ -z "${!module_*}" -a -z "${modinfop}" ] && return
154 330
155 #so now we can set the configfilevar 331 [[ -z ${!module_*} ]] && return 0
332
333 # OK so now if we have got this far, then we know we want to continue
334 # and generate the modules.d file.
335 module_modinfo="$(modinfo -p ${currm_path}.${KV_OBJ})"
156 module_config="${T}/modulesd-${selectedmodule}" 336 module_config="${T}/modulesd-${currm}"
157 337
158 # and being working on things.
159 ebegin "Preparing file for modules.d" 338 ebegin "Preparing file for modules.d"
339 #-----------------------------------------------------------------------
160 echo "# modules.d config file for ${selectedmodule}" >> ${module_config} 340 echo "# modules.d configuration file for ${currm}" >> ${module_config}
161 echo "# this file was automatically generated from linux-mod.eclass" >> ${module_config} 341 #-----------------------------------------------------------------------
342 [[ -n ${module_docs} ]] && \
343 echo "# For more information please read:" >> ${module_config}
162 for temp in ${module_docs} 344 for t in ${module_docs}
163 do 345 do
164 echo "# Please read ${temp/*\//} for more info" >> ${module_config} 346 echo "# ${t//*\/}" >> ${module_config}
165 done 347 done
348 echo >> ${module_config}
166 349
350 #-----------------------------------------------------------------------
167 if [ ${module_aliases} > 0 ]; 351 if [[ ${module_aliases} -gt 0 ]]
168 then 352 then
169 echo >> ${module_config}
170 echo "# Internal Aliases - Do not edit" >> ${module_config} 353 echo "# Internal Aliases - Do not edit" >> ${module_config}
171 echo "# ------------------------------" >> ${module_config} 354 echo "# ------------------------------" >> ${module_config}
172 355
173 (( module_aliases-- )) 356 for((t=0; t<${module_aliases}; t++))
174 for temp in $(seq 0 ${module_aliases})
175 do 357 do
176 echo "alias $(eval echo \$\{MODULESD_${selectedmodule}_ALIASES[$temp]\})" >> ${module_config} 358 echo "alias $(eval echo \${MODULESD_${currm}_ALIASES[$t]})" \
359 >> ${module_config}
177 done 360 done
361 echo '' >> ${module_config}
178 fi 362 fi
179 363
180 # and then stating any module parameters defined from the module 364 #-----------------------------------------------------------------------
181 if [ -n "${modinfop}" ]; 365 if [[ -n ${module_modinfo} ]]
182 then 366 then
183 echo >> ${module_config} 367 echo >> ${module_config}
184 echo "# Configurable module parameters" >> ${module_config} 368 echo "# Configurable module parameters" >> ${module_config}
185 echo "# ------------------------------" >> ${module_config} 369 echo "# ------------------------------" >> ${module_config}
186 370 myIFS="${IFS}"
187 xifs="${IFS}"
188 IFS="$(echo -en "\n\b")" 371 IFS="$(echo -en "\n\b")"
189 for parameter in ${modinfop} 372
373 for t in ${module_modinfo}
190 do 374 do
191 temp="$(echo ${parameter#*:} | grep -e " [0-9][ =]" | sed "s:.*\([01][= ]\).*:\1:")" 375 myVAR="$(echo ${t#*:} | grep -e " [0-9][ =]" | sed "s:.*\([01][= ]\).*:\1:")"
192 if [ -n "${temp}" ]; 376 if [[ -n ${myVAR} ]]
193 then 377 then
194 module_opts="${module_opts} ${parameter%%:*}:${temp}" 378 module_opts="${module_opts} ${t%%:*}:${myVAR}"
195 fi 379 fi
196 echo -e "# ${parameter%%:*}:\t${parameter#*:}" >> ${module_config} 380 echo -e "# ${t%%:*}:\t${t#*:}" >> ${module_config}
197 done 381 done
198 IFS="${xifs}" 382 IFS="${myIFS}"
383 echo '' >> ${module_config}
199 fi 384 fi
200 385
201 # and any examples we can gather from them 386 #-----------------------------------------------------------------------
202 if [ -n "${module_opts}" ]; 387 if [[ $(eval echo \${MODULESD_${currm}_ALIASES[0]}) == guess ]]
203 then 388 then
389 # So lets do some guesswork eh?
390 if [[ -n ${module_opts} ]]
391 then
392 echo "# For Example..." >> ${module_config}
393 echo "# --------------" >> ${module_config}
394 for t in ${module_opts}
395 do
396 echo "# options ${currm} ${t//:*}=${t//*:}" >> ${module_config}
397 done
204 echo >> ${module_config} 398 echo '' >> ${module_config}
399 fi
400 elif [[ ${module_examples} -gt 0 ]]
401 then
205 echo "# For Example..." >> ${module_config} 402 echo "# For Example..." >> ${module_config}
206 echo "# ------------------------------" >> ${module_config} 403 echo "# --------------" >> ${module_config}
207 for parameter in ${module_opts} 404 for((t=0; t<${module_examples}; t++))
208 do 405 do
209 echo "# options ${selectedmodule_full/*\//} ${parameter//:*}=${parameter//*:}" >> ${module_config} 406 echo "options $(eval echo \${MODULESD_${currm}_EXAMPLES[$t]})" \
407 >> ${module_config}
210 done 408 done
409 echo '' >> ${module_config}
211 fi 410 fi
212 411
412 #-----------------------------------------------------------------------
413 if [[ ${module_additions} -gt 0 ]]
414 then
415 for((t=0; t<${module_additions}; t++))
416 do
417 echo "$(eval echo \${MODULESD_${currm}_ADDITIONS[$t]})" \
418 >> ${module_config}
419 done
420 echo '' >> ${module_config}
421 fi
422
423 #-----------------------------------------------------------------------
424
213 # then we install it 425 # then we install it
426 if kernel_is ge 2 6; then
427 insinto /etc/modprobe.d
428 else
214 insinto /etc/modules.d 429 insinto /etc/modules.d
215 newins ${module_config} ${selectedmodule_full/*\//} 430 fi
216 431 newins ${module_config} ${currm_path//*\/}
432
217 # and install any documentation we might have. 433 # and install any documentation we might have.
218 [ -n "${module_docs}" ] && dodoc ${module_docs} 434 [[ -n ${module_docs} ]] && dodoc ${module_docs}
219 done 435 done
220 eend 0 436 eend 0
221} 437 return 0
222
223display_postinst() {
224 # if we haven't determined the version yet, we need too.
225 get_version;
226
227 local modulename moduledir sourcedir moduletemp file i
228
229 file=${ROOT}/etc/modules.autoload.d/kernel-${KV_MAJOR}.${KV_MINOR}
230 file=${file/\/\///}
231
232 for i in ${MODULE_IGNORE}
233 do
234 MODULE_NAMES=${MODULE_NAMES//${i}(*}
235 done
236
237 einfo "If you would like to load this module automatically upon boot"
238 einfo "please type the following as root:"
239 for i in ${MODULE_NAMES}
240 do
241 for n in $(find_module_params ${i})
242 do
243 eval ${n/:*}=${n/*:/}
244 done
245 libdir=${libdir:-misc}
246 srcdir=${srcdir:-${S}}
247 objdir=${objdir:-${srcdir}}
248
249 einfo " # echo \"${modulename}\" >> ${file}"
250 done
251 echo
252} 438}
253 439
254find_module_params() { 440find_module_params() {
441 debug-print-function ${FUNCNAME} $*
442
255 local matched_offset=0 matched_opts=0 test="${@}" temp_var result 443 local matched_offset=0 matched_opts=0 test="${@}" temp_var result
256 local i=0 y=0 z=0 444 local i=0 y=0 z=0
257 445
258 for((i=0; i<=${#test}; i++)) 446 for((i=0; i<=${#test}; i++))
259 do 447 do
260 case ${test:${i}:1} in 448 case ${test:${i}:1} in
261 \() matched_offset[0]=${i};; 449 \() matched_offset[0]=${i};;
262 \:) matched_opts=$((${matched_opts} + 1)); 450 \:) matched_opts=$((${matched_opts} + 1));
263 matched_offset[${matched_opts}]="${i}";; 451 matched_offset[${matched_opts}]="${i}";;
264 \)) matched_opts=$((${matched_opts} + 1)); 452 \)) matched_opts=$((${matched_opts} + 1));
265 matched_offset[${matched_opts}]="${i}";; 453 matched_offset[${matched_opts}]="${i}";;
266 esac 454 esac
267 done 455 done
268 456
269 for((i=0; i<=${matched_opts}; i++)) 457 for((i=0; i<=${matched_opts}; i++))
270 do 458 do
271 # i = offset were working on 459 # i = offset were working on
272 # y = last offset 460 # y = last offset
273 # z = current offset - last offset 461 # z = current offset - last offset
277 *) y=$((${matched_offset[$((${i} - 1))]} + 1)) 465 *) y=$((${matched_offset[$((${i} - 1))]} + 1))
278 z=$((${matched_offset[${i}]} - ${matched_offset[$((${i} - 1))]})); 466 z=$((${matched_offset[${i}]} - ${matched_offset[$((${i} - 1))]}));
279 z=$((${z} - 1)) 467 z=$((${z} - 1))
280 tempvar=${test:${y}:${z}};; 468 tempvar=${test:${y}:${z}};;
281 esac 469 esac
282 470
283 case ${i} in 471 case ${i} in
284 0) result="${result} modulename:${tempvar}";; 472 0) result="${result} modulename:${tempvar}";;
285 1) result="${result} libdir:${tempvar}";; 473 1) result="${result} libdir:${tempvar}";;
286 2) result="${result} srcdir:${tempvar}";; 474 2) result="${result} srcdir:${tempvar}";;
287 3) result="${result} objdir:${tempvar}";; 475 3) result="${result} objdir:${tempvar}";;
288 esac 476 esac
289 done 477 done
290 478
291 echo ${result} 479 echo ${result}
292} 480}
293 481
294# default ebuild functions 482# default ebuild functions
295# -------------------------------- 483# --------------------------------
296 484
297linux-mod_pkg_setup() { 485linux-mod_pkg_setup() {
486 debug-print-function ${FUNCNAME} $*
487
298 linux-info_pkg_setup; 488 linux-info_pkg_setup;
489 require_configured_kernel
299 check_kernel_built; 490 check_kernel_built;
300 check_modules_supported; 491 strip_modulenames;
492 [[ -n ${MODULE_NAMES} ]] && check_modules_supported
301 set_kvobj; 493 set_kvobj;
494 # Commented out with permission from johnm until a fixed version for arches
495 # who intentionally use different kernel and userland compilers can be
496 # introduced - Jason Wever <weeve@gentoo.org>, 23 Oct 2005
497 #check_vermagic;
302} 498}
303 499
304linux-mod_src_compile() { 500strip_modulenames() {
305 local modulename libdir srcdir objdir i n 501 debug-print-function ${FUNCNAME} $*
306 502
307 BUILD_TARGETS=${BUILD_TARGETS:-clean module} 503 local i
308
309 for i in ${MODULE_IGNORE} 504 for i in ${MODULE_IGNORE}; do
310 do
311 MODULE_NAMES=${MODULE_NAMES//${i}(*} 505 MODULE_NAMES=${MODULE_NAMES//${i}(*}
312 done 506 done
507}
313 508
509linux-mod_src_compile() {
510 debug-print-function ${FUNCNAME} $*
511
512 local modulename libdir srcdir objdir i n myABI="${ABI}"
513 set_arch_to_kernel
514 ABI="${KERNEL_ABI}"
515
516 BUILD_TARGETS=${BUILD_TARGETS:-clean module}
517 strip_modulenames;
518 cd "${S}"
314 for i in ${MODULE_NAMES} 519 for i in ${MODULE_NAMES}
315 do 520 do
521 unset libdir srcdir objdir
316 for n in $(find_module_params ${i}) 522 for n in $(find_module_params ${i})
317 do 523 do
318 eval ${n/:*}=${n/*:/} 524 eval ${n/:*}=${n/*:/}
319 done 525 done
320 libdir=${libdir:-misc} 526 libdir=${libdir:-misc}
321 srcdir=${srcdir:-${S}} 527 srcdir=${srcdir:-${S}}
322 objdir=${objdir:-${srcdir}} 528 objdir=${objdir:-${srcdir}}
323 529
324 if [ ! -f "${srcdir}/.built" ]; 530 if [ ! -f "${srcdir}/.built" ];
325 then 531 then
326 cd ${srcdir} 532 cd ${srcdir}
327 einfo "Preparing ${modulename} module" 533 einfo "Preparing ${modulename} module"
328 env -u ARCH emake ${BUILD_FIXES} ${BUILD_PARAMS} ${BUILD_TARGETS} \ 534 if [[ -n ${ECONF_PARAMS} ]]
329 || die "Unable to make \ 535 then
330 ${BUILD_FIXES} ${BUILD_PARAMS} ${BUILD_TARGETS}." 536 econf ${ECONF_PARAMS} || \
537 die "Unable to run econf ${ECONF_PARAMS}"
538 fi
539
540 # This looks messy, but it is needed to handle multiple variables
541 # being passed in the BUILD_* stuff where the variables also have
542 # spaces that must be preserved. If don't do this, then the stuff
543 # inside the variables gets used as targets for Make, which then
544 # fails.
545 eval "emake HOSTCC=\"$(tc-getBUILD_CC)\" \
546 CROSS_COMPILE=${CHOST}- \
547 LDFLAGS=\"$(get_abi_LDFLAGS)\" \
548 ${BUILD_FIXES} \
549 ${BUILD_PARAMS} \
550 ${BUILD_TARGETS} " \
551 || die "Unable to emake HOSTCC="$(tc-getBUILD_CC)" CROSS_COMPILE=${CHOST}- LDFLAGS="$(get_abi_LDFLAGS)" ${BUILD_FIXES} ${BUILD_PARAMS} ${BUILD_TARGETS}"
331 touch ${srcdir}/.built 552 touch ${srcdir}/.built
332 cd ${OLDPWD} 553 cd ${OLDPWD}
333 fi 554 fi
334 done 555 done
556
557 set_arch_to_portage
558 ABI="${myABI}"
335} 559}
336 560
337linux-mod_src_install() { 561linux-mod_src_install() {
562 debug-print-function ${FUNCNAME} $*
563
338 local modulename libdir srcdir objdir i n 564 local modulename libdir srcdir objdir i n
339
340 for i in ${MODULE_IGNORE}
341 do
342 MODULE_NAMES=${MODULE_NAMES//${i}(*}
343 done
344 565
566 strip_modulenames;
345 for i in ${MODULE_NAMES} 567 for i in ${MODULE_NAMES}
346 do 568 do
569 unset libdir srcdir objdir
347 for n in $(find_module_params ${i}) 570 for n in $(find_module_params ${i})
348 do 571 do
349 eval ${n/:*}=${n/*:/} 572 eval ${n/:*}=${n/*:/}
350 done 573 done
351 libdir=${libdir:-misc} 574 libdir=${libdir:-misc}
352 srcdir=${srcdir:-${S}} 575 srcdir=${srcdir:-${S}}
353 objdir=${objdir:-${srcdir}} 576 objdir=${objdir:-${srcdir}}
354 577
355 einfo "Installing ${modulename} module" 578 einfo "Installing ${modulename} module"
356 cd ${objdir} 579 cd ${objdir} || die "${objdir} does not exist"
357
358 insinto /lib/modules/${KV_FULL}/${libdir} 580 insinto /lib/modules/${KV_FULL}/${libdir}
359 doins ${modulename}.${KV_OBJ} 581 doins ${modulename}.${KV_OBJ} || die "doins ${modulename}.${KV_OBJ} failed"
360 cd ${OLDPWD} 582 cd ${OLDPWD}
361 583
362 [ -z "${NO_MODULESD}" ] && generate_modulesd ${objdir}/${modulename} 584 generate_modulesd ${objdir}/${modulename}
363 done 585 done
364} 586}
365 587
588linux-mod_pkg_preinst() {
589 debug-print-function ${FUNCNAME} $*
590
591 [ -d "${D}lib/modules" ] && UPDATE_DEPMOD=true || UPDATE_DEPMOD=false
592 [ -d "${D}etc/modules.d" ] && UPDATE_MODULES=true || UPDATE_MODULES=false
593 [ -d "${D}lib/modules" ] && UPDATE_MODULEDB=true || UPDATE_MODULEDB=false
594}
595
366linux-mod_pkg_postinst() { 596linux-mod_pkg_postinst() {
367 update_depmod; 597 debug-print-function ${FUNCNAME} $*
368 update_modules; 598
369 display_postinst; 599 ${UPDATE_DEPMOD} && update_depmod;
600 ${UPDATE_MODULES} && update_modules;
601 ${UPDATE_MODULEDB} && update_moduledb;
370} 602}
603
604linux-mod_pkg_postrm() {
605 debug-print-function ${FUNCNAME} $*
606 remove_moduledb;
607}

Legend:
Removed from v.1.20  
changed lines
  Added in v.1.85

  ViewVC Help
Powered by ViewVC 1.1.20