| 1 | # Copyright 1999-2004 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.93 2008/11/05 12:00:19 dsd Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/linux-mod.eclass,v 1.106 2012/08/28 15:28:01 mpagano Exp $ |
| 4 | |
|
|
| 5 | # Author(s): John Mylchreest <johnm@gentoo.org>, |
|
|
| 6 | # Stefan Schweizer <genstef@gentoo.org> |
|
|
| 7 | # Maintainer: kernel-misc@gentoo.org |
|
|
| 8 | # |
|
|
| 9 | # Please direct your bugs to the current eclass maintainer :) |
|
|
| 10 | |
4 | |
| 11 | # @ECLASS: linux-mod.eclass |
5 | # @ECLASS: linux-mod.eclass |
| 12 | # @MAINTAINER: |
6 | # @MAINTAINER: |
| 13 | # kernel-misc@gentoo.org |
7 | # kernel-misc@gentoo.org |
|
|
8 | # @AUTHOR: |
|
|
9 | # John Mylchreest <johnm@gentoo.org>, |
|
|
10 | # Stefan Schweizer <genstef@gentoo.org> |
| 14 | # @BLURB: It provides the functionality required to install external modules against a kernel source tree. |
11 | # @BLURB: It provides the functionality required to install external modules against a kernel source tree. |
| 15 | # @DESCRIPTION: |
12 | # @DESCRIPTION: |
| 16 | # This eclass is used to interface with linux-info.eclass in such a way |
13 | # This eclass is used to interface with linux-info.eclass in such a way |
| 17 | # to provide the functionality and initial functions |
14 | # to provide the functionality and initial functions |
| 18 | # required to install external modules against a kernel source |
15 | # required to install external modules against a kernel source |
| … | |
… | |
| 55 | # srcdir = place for ebuild to cd to before running make (by default it's ${S}) |
52 | # srcdir = place for ebuild to cd to before running make (by default it's ${S}) |
| 56 | # objdir = place the .ko and objects are located after make runs (by default it's set to srcdir) |
53 | # objdir = place the .ko and objects are located after make runs (by default it's set to srcdir) |
| 57 | # |
54 | # |
| 58 | # To get an idea of how these variables are used, here's a few lines |
55 | # To get an idea of how these variables are used, here's a few lines |
| 59 | # of code from around line 540 in this eclass: |
56 | # of code from around line 540 in this eclass: |
| 60 | # |
57 | # |
| 61 | # einfo "Installing ${modulename} module" |
58 | # einfo "Installing ${modulename} module" |
| 62 | # cd ${objdir} || die "${objdir} does not exist" |
59 | # cd ${objdir} || die "${objdir} does not exist" |
| 63 | # insinto /lib/modules/${KV_FULL}/${libdir} |
60 | # insinto /lib/modules/${KV_FULL}/${libdir} |
| 64 | # doins ${modulename}.${KV_OBJ} || die "doins ${modulename}.${KV_OBJ} failed" |
61 | # doins ${modulename}.${KV_OBJ} || die "doins ${modulename}.${KV_OBJ} failed" |
| 65 | # |
62 | # |
| … | |
… | |
| 123 | |
120 | |
| 124 | # @ECLASS-VARIABLE: KV_OBJ |
121 | # @ECLASS-VARIABLE: KV_OBJ |
| 125 | # @DESCRIPTION: |
122 | # @DESCRIPTION: |
| 126 | # It's a read-only variable. It contains the extension of the kernel modules. |
123 | # It's a read-only variable. It contains the extension of the kernel modules. |
| 127 | |
124 | |
| 128 | # The order of these is important as both of linux-info and eutils contain |
|
|
| 129 | # set_arch_to_kernel and set_arch_to_portage functions and the ones in eutils |
|
|
| 130 | # are deprecated in favor of the ones in linux-info. |
|
|
| 131 | # See http://bugs.gentoo.org/show_bug.cgi?id=127506 |
|
|
| 132 | |
|
|
| 133 | inherit eutils linux-info multilib |
125 | inherit eutils linux-info multilib |
| 134 | EXPORT_FUNCTIONS pkg_setup pkg_preinst pkg_postinst src_install src_compile pkg_postrm |
126 | EXPORT_FUNCTIONS pkg_setup pkg_preinst pkg_postinst src_install src_compile pkg_postrm |
| 135 | |
127 | |
| 136 | IUSE="kernel_linux" |
128 | IUSE="kernel_linux" |
| 137 | SLOT="0" |
129 | SLOT="0" |
| 138 | DESCRIPTION="Based on the $ECLASS eclass" |
130 | DESCRIPTION="Based on the $ECLASS eclass" |
| 139 | RDEPEND="kernel_linux? ( virtual/modutils )" |
131 | RDEPEND="kernel_linux? ( virtual/modutils )" |
| 140 | DEPEND="${RDEPEND} |
132 | DEPEND="${RDEPEND} |
| 141 | sys-apps/sed" |
133 | sys-apps/sed |
|
|
134 | kernel_linux? ( virtual/linux-sources )" |
| 142 | |
135 | |
| 143 | # eclass utilities |
136 | # eclass utilities |
| 144 | # ---------------------------------- |
137 | # ---------------------------------- |
| 145 | |
138 | |
| 146 | check_vermagic() { |
139 | check_vermagic() { |
| 147 | debug-print-function ${FUNCNAME} $* |
140 | debug-print-function ${FUNCNAME} $* |
| 148 | |
141 | |
| 149 | local curr_gcc_ver=$(gcc -dumpversion) |
142 | local curr_gcc_ver=$(gcc -dumpversion) |
| 150 | local tmpfile old_chost old_gcc_ver result=0 |
143 | local tmpfile old_chost old_gcc_ver result=0 |
| 151 | |
144 | |
| 152 | tmpfile=`find ${KV_DIR}/ -iname "*.o.cmd" -exec grep usr/lib/gcc {} \; -quit` |
145 | tmpfile=`find "${KV_DIR}/" -iname "*.o.cmd" -exec grep usr/lib/gcc {} \; -quit` |
| 153 | tmpfile=${tmpfile//*usr/lib} |
146 | tmpfile=${tmpfile//*usr/lib} |
| 154 | tmpfile=${tmpfile//\/include*} |
147 | tmpfile=${tmpfile//\/include*} |
| 155 | old_chost=${tmpfile//*gcc\/} |
148 | old_chost=${tmpfile//*gcc\/} |
| 156 | old_chost=${old_chost//\/*} |
149 | old_chost=${old_chost//\/*} |
| 157 | old_gcc_ver=${tmpfile//*\/} |
150 | old_gcc_ver=${tmpfile//*\/} |
| … | |
… | |
| 192 | # if we haven't determined the version yet, we need too. |
185 | # if we haven't determined the version yet, we need too. |
| 193 | get_version; |
186 | get_version; |
| 194 | |
187 | |
| 195 | # if the kernel version is greater than 2.6.6 then we should use |
188 | # if the kernel version is greater than 2.6.6 then we should use |
| 196 | # M= instead of SUBDIRS= |
189 | # M= instead of SUBDIRS= |
|
|
190 | [ ${KV_MAJOR} -eq 3 ] && return 0 |
| 197 | [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -gt 5 -a ${KV_PATCH} -gt 5 ] && \ |
191 | [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -gt 5 -a ${KV_PATCH} -gt 5 ] && \ |
| 198 | return 0 || return 1 |
192 | return 0 || return 1 |
| 199 | } |
193 | } |
| 200 | |
194 | |
| 201 | # @FUNCTION: convert_to_m |
195 | # @FUNCTION: convert_to_m |
| … | |
… | |
| 208 | if use_m |
202 | if use_m |
| 209 | then |
203 | then |
| 210 | [ ! -f "${1}" ] && \ |
204 | [ ! -f "${1}" ] && \ |
| 211 | die "convert_to_m() requires a filename as an argument" |
205 | die "convert_to_m() requires a filename as an argument" |
| 212 | ebegin "Converting ${1/${WORKDIR}\//} to use M= instead of SUBDIRS=" |
206 | ebegin "Converting ${1/${WORKDIR}\//} to use M= instead of SUBDIRS=" |
| 213 | sed -i 's:SUBDIRS=:M=:g' ${1} |
207 | sed -i 's:SUBDIRS=:M=:g' "${1}" |
| 214 | eend $? |
208 | eend $? |
| 215 | fi |
209 | fi |
| 216 | } |
210 | } |
| 217 | |
211 | |
| 218 | # internal function |
212 | # internal function |
| … | |
… | |
| 225 | |
219 | |
| 226 | # if we haven't determined the version yet, we need too. |
220 | # if we haven't determined the version yet, we need too. |
| 227 | get_version; |
221 | get_version; |
| 228 | |
222 | |
| 229 | ebegin "Updating module dependencies for ${KV_FULL}" |
223 | ebegin "Updating module dependencies for ${KV_FULL}" |
| 230 | if [ -r ${KV_OUT_DIR}/System.map ] |
224 | if [ -r "${KV_OUT_DIR}"/System.map ] |
| 231 | then |
225 | then |
| 232 | depmod -ae -F ${KV_OUT_DIR}/System.map -b ${ROOT} -r ${KV_FULL} |
226 | depmod -ae -F "${KV_OUT_DIR}"/System.map -b "${ROOT}" ${KV_FULL} |
| 233 | eend $? |
227 | eend $? |
| 234 | else |
228 | else |
| 235 | ewarn |
229 | ewarn |
| 236 | ewarn "${KV_OUT_DIR}/System.map not found." |
230 | ewarn "${KV_OUT_DIR}/System.map not found." |
| 237 | ewarn "You must manually update the kernel module dependencies using depmod." |
231 | ewarn "You must manually update the kernel module dependencies using depmod." |
| … | |
… | |
| 247 | # It calls the update-modules utility. |
241 | # It calls the update-modules utility. |
| 248 | update_modules() { |
242 | update_modules() { |
| 249 | debug-print-function ${FUNCNAME} $* |
243 | debug-print-function ${FUNCNAME} $* |
| 250 | |
244 | |
| 251 | if [ -x /sbin/update-modules ] && \ |
245 | if [ -x /sbin/update-modules ] && \ |
| 252 | grep -v -e "^#" -e "^$" ${D}/etc/modules.d/* >/dev/null 2>&1; then |
246 | grep -v -e "^#" -e "^$" "${D}"/etc/modules.d/* >/dev/null 2>&1; then |
| 253 | ebegin "Updating modules.conf" |
247 | ebegin "Updating modules.conf" |
| 254 | /sbin/update-modules |
248 | /sbin/update-modules |
| 255 | eend $? |
249 | eend $? |
| 256 | elif [ -x /sbin/update-modules ] && \ |
250 | elif [ -x /sbin/update-modules ] && \ |
| 257 | grep -v -e "^#" -e "^$" ${D}/etc/modules.d/* >/dev/null 2>&1; then |
251 | grep -v -e "^#" -e "^$" "${D}"/etc/modules.d/* >/dev/null 2>&1; then |
| 258 | ebegin "Updating modules.conf" |
252 | ebegin "Updating modules.conf" |
| 259 | /sbin/update-modules |
253 | /sbin/update-modules |
| 260 | eend $? |
254 | eend $? |
| 261 | fi |
255 | fi |
| 262 | } |
256 | } |
| … | |
… | |
| 267 | # DESCRIPTION: |
261 | # DESCRIPTION: |
| 268 | # It updates the location of the database used by the module-rebuild utility. |
262 | # It updates the location of the database used by the module-rebuild utility. |
| 269 | move_old_moduledb() { |
263 | move_old_moduledb() { |
| 270 | debug-print-function ${FUNCNAME} $* |
264 | debug-print-function ${FUNCNAME} $* |
| 271 | |
265 | |
| 272 | local OLDDIR=${ROOT}/usr/share/module-rebuild/ |
266 | local OLDDIR="${ROOT}"/usr/share/module-rebuild/ |
| 273 | local NEWDIR=${ROOT}/var/lib/module-rebuild/ |
267 | local NEWDIR="${ROOT}"/var/lib/module-rebuild/ |
| 274 | |
268 | |
| 275 | if [[ -f ${OLDDIR}/moduledb ]]; then |
269 | if [[ -f "${OLDDIR}"/moduledb ]]; then |
| 276 | [[ ! -d ${NEWDIR} ]] && mkdir -p ${NEWDIR} |
270 | [[ ! -d "${NEWDIR}" ]] && mkdir -p "${NEWDIR}" |
| 277 | [[ ! -f ${NEWDIR}/moduledb ]] && \ |
271 | [[ ! -f "${NEWDIR}"/moduledb ]] && \ |
| 278 | mv ${OLDDIR}/moduledb ${NEWDIR}/moduledb |
272 | mv "${OLDDIR}"/moduledb "${NEWDIR}"/moduledb |
| 279 | rm -f ${OLDDIR}/* |
273 | rm -f "${OLDDIR}"/* |
| 280 | rmdir ${OLDDIR} |
274 | rmdir "${OLDDIR}" |
| 281 | fi |
275 | fi |
| 282 | } |
276 | } |
| 283 | |
277 | |
| 284 | # internal function |
278 | # internal function |
| 285 | # |
279 | # |
| … | |
… | |
| 287 | # DESCRIPTION: |
281 | # DESCRIPTION: |
| 288 | # It adds the package to the /var/lib/module-rebuild/moduledb database used by the module-rebuild utility. |
282 | # It adds the package to the /var/lib/module-rebuild/moduledb database used by the module-rebuild utility. |
| 289 | update_moduledb() { |
283 | update_moduledb() { |
| 290 | debug-print-function ${FUNCNAME} $* |
284 | debug-print-function ${FUNCNAME} $* |
| 291 | |
285 | |
| 292 | local MODULEDB_DIR=${ROOT}/var/lib/module-rebuild/ |
286 | local MODULEDB_DIR="${ROOT}"/var/lib/module-rebuild/ |
| 293 | move_old_moduledb |
287 | move_old_moduledb |
| 294 | |
288 | |
| 295 | if [[ ! -f ${MODULEDB_DIR}/moduledb ]]; then |
289 | if [[ ! -f "${MODULEDB_DIR}"/moduledb ]]; then |
| 296 | [[ ! -d ${MODULEDB_DIR} ]] && mkdir -p ${MODULEDB_DIR} |
290 | [[ ! -d "${MODULEDB_DIR}" ]] && mkdir -p "${MODULEDB_DIR}" |
| 297 | touch ${MODULEDB_DIR}/moduledb |
291 | touch "${MODULEDB_DIR}"/moduledb |
| 298 | fi |
292 | fi |
| 299 | |
293 | |
| 300 | if ! grep -qs ${CATEGORY}/${PN}-${PVR} ${MODULEDB_DIR}/moduledb ; then |
294 | if ! grep -qs ${CATEGORY}/${PN}-${PVR} "${MODULEDB_DIR}"/moduledb ; then |
| 301 | einfo "Adding module to moduledb." |
295 | einfo "Adding module to moduledb." |
| 302 | echo "a:1:${CATEGORY}/${PN}-${PVR}" >> ${MODULEDB_DIR}/moduledb |
296 | echo "a:1:${CATEGORY}/${PN}-${PVR}" >> "${MODULEDB_DIR}"/moduledb |
| 303 | fi |
297 | fi |
| 304 | } |
298 | } |
| 305 | |
299 | |
| 306 | # internal function |
300 | # internal function |
| 307 | # |
301 | # |
| … | |
… | |
| 310 | # It removes the package from the /var/lib/module-rebuild/moduledb database used by |
304 | # It removes the package from the /var/lib/module-rebuild/moduledb database used by |
| 311 | # the module-rebuild utility. |
305 | # the module-rebuild utility. |
| 312 | remove_moduledb() { |
306 | remove_moduledb() { |
| 313 | debug-print-function ${FUNCNAME} $* |
307 | debug-print-function ${FUNCNAME} $* |
| 314 | |
308 | |
| 315 | local MODULEDB_DIR=${ROOT}/var/lib/module-rebuild/ |
309 | local MODULEDB_DIR="${ROOT}"/var/lib/module-rebuild/ |
| 316 | move_old_moduledb |
310 | move_old_moduledb |
| 317 | |
311 | |
| 318 | if grep -qs ${CATEGORY}/${PN}-${PVR} ${MODULEDB_DIR}/moduledb ; then |
312 | if grep -qs ${CATEGORY}/${PN}-${PVR} "${MODULEDB_DIR}"/moduledb ; then |
| 319 | einfo "Removing ${CATEGORY}/${PN}-${PVR} from moduledb." |
313 | einfo "Removing ${CATEGORY}/${PN}-${PVR} from moduledb." |
| 320 | sed -i -e "/.*${CATEGORY}\/${PN}-${PVR}.*/d" ${MODULEDB_DIR}/moduledb |
314 | sed -i -e "/.*${CATEGORY}\/${PN}-${PVR}.*/d" "${MODULEDB_DIR}"/moduledb |
| 321 | fi |
315 | fi |
| 322 | } |
316 | } |
| 323 | |
317 | |
| 324 | # @FUNCTION: set_kvobj |
318 | # @FUNCTION: set_kvobj |
| 325 | # @DESCRIPTION: |
319 | # @DESCRIPTION: |
| 326 | # It sets the KV_OBJ variable. |
320 | # It sets the KV_OBJ variable. |
| 327 | set_kvobj() { |
321 | set_kvobj() { |
| 328 | debug-print-function ${FUNCNAME} $* |
322 | debug-print-function ${FUNCNAME} $* |
| 329 | |
323 | |
| 330 | if kernel_is 2 6 |
324 | if kernel_is ge 2 6 |
| 331 | then |
325 | then |
| 332 | KV_OBJ="ko" |
326 | KV_OBJ="ko" |
| 333 | else |
327 | else |
| 334 | KV_OBJ="o" |
328 | KV_OBJ="o" |
| 335 | fi |
329 | fi |
| … | |
… | |
| 413 | module_modinfo="$(modinfo -p ${currm_path}.${KV_OBJ})" |
407 | module_modinfo="$(modinfo -p ${currm_path}.${KV_OBJ})" |
| 414 | module_config="${T}/modulesd-${currm}" |
408 | module_config="${T}/modulesd-${currm}" |
| 415 | |
409 | |
| 416 | ebegin "Preparing file for modules.d" |
410 | ebegin "Preparing file for modules.d" |
| 417 | #----------------------------------------------------------------------- |
411 | #----------------------------------------------------------------------- |
| 418 | echo "# modules.d configuration file for ${currm}" >> ${module_config} |
412 | echo "# modules.d configuration file for ${currm}" >> "${module_config}" |
| 419 | #----------------------------------------------------------------------- |
413 | #----------------------------------------------------------------------- |
| 420 | [[ -n ${module_docs} ]] && \ |
414 | [[ -n ${module_docs} ]] && \ |
| 421 | echo "# For more information please read:" >> ${module_config} |
415 | echo "# For more information please read:" >> "${module_config}" |
| 422 | for t in ${module_docs} |
416 | for t in ${module_docs} |
| 423 | do |
417 | do |
| 424 | echo "# ${t//*\/}" >> ${module_config} |
418 | echo "# ${t//*\/}" >> "${module_config}" |
| 425 | done |
419 | done |
| 426 | echo >> ${module_config} |
420 | echo >> "${module_config}" |
| 427 | |
421 | |
| 428 | #----------------------------------------------------------------------- |
422 | #----------------------------------------------------------------------- |
| 429 | if [[ ${module_aliases} -gt 0 ]] |
423 | if [[ ${module_aliases} -gt 0 ]] |
| 430 | then |
424 | then |
| 431 | echo "# Internal Aliases - Do not edit" >> ${module_config} |
425 | echo "# Internal Aliases - Do not edit" >> "${module_config}" |
| 432 | echo "# ------------------------------" >> ${module_config} |
426 | echo "# ------------------------------" >> "${module_config}" |
| 433 | |
427 | |
| 434 | for((t=0; t<${module_aliases}; t++)) |
428 | for((t=0; t<${module_aliases}; t++)) |
| 435 | do |
429 | do |
| 436 | echo "alias $(eval echo \${MODULESD_${currm}_ALIASES[$t]})" \ |
430 | echo "alias $(eval echo \${MODULESD_${currm}_ALIASES[$t]})" \ |
| 437 | >> ${module_config} |
431 | >> "${module_config}" |
| 438 | done |
432 | done |
| 439 | echo '' >> ${module_config} |
433 | echo '' >> "${module_config}" |
| 440 | fi |
434 | fi |
| 441 | |
435 | |
| 442 | #----------------------------------------------------------------------- |
436 | #----------------------------------------------------------------------- |
| 443 | if [[ -n ${module_modinfo} ]] |
437 | if [[ -n ${module_modinfo} ]] |
| 444 | then |
438 | then |
| 445 | echo >> ${module_config} |
439 | echo >> "${module_config}" |
| 446 | echo "# Configurable module parameters" >> ${module_config} |
440 | echo "# Configurable module parameters" >> "${module_config}" |
| 447 | echo "# ------------------------------" >> ${module_config} |
441 | echo "# ------------------------------" >> "${module_config}" |
| 448 | myIFS="${IFS}" |
442 | myIFS="${IFS}" |
| 449 | IFS="$(echo -en "\n\b")" |
443 | IFS="$(echo -en "\n\b")" |
| 450 | |
444 | |
| 451 | for t in ${module_modinfo} |
445 | for t in ${module_modinfo} |
| 452 | do |
446 | do |
| 453 | myVAR="$(echo ${t#*:} | grep -e " [0-9][ =]" | sed "s:.*\([01][= ]\).*:\1:")" |
447 | myVAR="$(echo ${t#*:} | grep -e " [0-9][ =]" | sed "s:.*\([01][= ]\).*:\1:")" |
| 454 | if [[ -n ${myVAR} ]] |
448 | if [[ -n ${myVAR} ]] |
| 455 | then |
449 | then |
| 456 | module_opts="${module_opts} ${t%%:*}:${myVAR}" |
450 | module_opts="${module_opts} ${t%%:*}:${myVAR}" |
| 457 | fi |
451 | fi |
| 458 | echo -e "# ${t%%:*}:\t${t#*:}" >> ${module_config} |
452 | echo -e "# ${t%%:*}:\t${t#*:}" >> "${module_config}" |
| 459 | done |
453 | done |
| 460 | IFS="${myIFS}" |
454 | IFS="${myIFS}" |
| 461 | echo '' >> ${module_config} |
455 | echo '' >> "${module_config}" |
| 462 | fi |
456 | fi |
| 463 | |
457 | |
| 464 | #----------------------------------------------------------------------- |
458 | #----------------------------------------------------------------------- |
| 465 | if [[ $(eval echo \${MODULESD_${currm}_ALIASES[0]}) == guess ]] |
459 | if [[ $(eval echo \${MODULESD_${currm}_ALIASES[0]}) == guess ]] |
| 466 | then |
460 | then |
| 467 | # So lets do some guesswork eh? |
461 | # So lets do some guesswork eh? |
| 468 | if [[ -n ${module_opts} ]] |
462 | if [[ -n ${module_opts} ]] |
| 469 | then |
463 | then |
| 470 | echo "# For Example..." >> ${module_config} |
464 | echo "# For Example..." >> "${module_config}" |
| 471 | echo "# --------------" >> ${module_config} |
465 | echo "# --------------" >> "${module_config}" |
| 472 | for t in ${module_opts} |
466 | for t in ${module_opts} |
| 473 | do |
467 | do |
| 474 | echo "# options ${currm} ${t//:*}=${t//*:}" >> ${module_config} |
468 | echo "# options ${currm} ${t//:*}=${t//*:}" >> "${module_config}" |
| 475 | done |
469 | done |
| 476 | echo '' >> ${module_config} |
470 | echo '' >> "${module_config}" |
| 477 | fi |
471 | fi |
| 478 | elif [[ ${module_examples} -gt 0 ]] |
472 | elif [[ ${module_examples} -gt 0 ]] |
| 479 | then |
473 | then |
| 480 | echo "# For Example..." >> ${module_config} |
474 | echo "# For Example..." >> "${module_config}" |
| 481 | echo "# --------------" >> ${module_config} |
475 | echo "# --------------" >> "${module_config}" |
| 482 | for((t=0; t<${module_examples}; t++)) |
476 | for((t=0; t<${module_examples}; t++)) |
| 483 | do |
477 | do |
| 484 | echo "options $(eval echo \${MODULESD_${currm}_EXAMPLES[$t]})" \ |
478 | echo "options $(eval echo \${MODULESD_${currm}_EXAMPLES[$t]})" \ |
| 485 | >> ${module_config} |
479 | >> "${module_config}" |
| 486 | done |
480 | done |
| 487 | echo '' >> ${module_config} |
481 | echo '' >> "${module_config}" |
| 488 | fi |
482 | fi |
| 489 | |
483 | |
| 490 | #----------------------------------------------------------------------- |
484 | #----------------------------------------------------------------------- |
| 491 | if [[ ${module_additions} -gt 0 ]] |
485 | if [[ ${module_additions} -gt 0 ]] |
| 492 | then |
486 | then |
| 493 | for((t=0; t<${module_additions}; t++)) |
487 | for((t=0; t<${module_additions}; t++)) |
| 494 | do |
488 | do |
| 495 | echo "$(eval echo \${MODULESD_${currm}_ADDITIONS[$t]})" \ |
489 | echo "$(eval echo \${MODULESD_${currm}_ADDITIONS[$t]})" \ |
| 496 | >> ${module_config} |
490 | >> "${module_config}" |
| 497 | done |
491 | done |
| 498 | echo '' >> ${module_config} |
492 | echo '' >> "${module_config}" |
| 499 | fi |
493 | fi |
| 500 | |
494 | |
| 501 | #----------------------------------------------------------------------- |
495 | #----------------------------------------------------------------------- |
| 502 | |
496 | |
| 503 | # then we install it |
497 | # then we install it |
| 504 | if kernel_is ge 2 6; then |
498 | if kernel_is ge 2 6; then |
| 505 | insinto /etc/modprobe.d |
499 | insinto /etc/modprobe.d |
| 506 | else |
500 | else |
| 507 | insinto /etc/modules.d |
501 | insinto /etc/modules.d |
| 508 | fi |
502 | fi |
| 509 | newins ${module_config} ${currm_path//*\/} |
503 | newins "${module_config}" "${currm_path//*\/}.conf" |
| 510 | |
504 | |
| 511 | # and install any documentation we might have. |
505 | # and install any documentation we might have. |
| 512 | [[ -n ${module_docs} ]] && dodoc ${module_docs} |
506 | [[ -n ${module_docs} ]] && dodoc ${module_docs} |
| 513 | done |
507 | done |
| 514 | eend 0 |
508 | eend 0 |
| … | |
… | |
| 573 | # configured, verifies that the sources are prepared, verifies that the modules support is builtin |
567 | # configured, verifies that the sources are prepared, verifies that the modules support is builtin |
| 574 | # in the kernel and sets the object extension KV_OBJ. |
568 | # in the kernel and sets the object extension KV_OBJ. |
| 575 | linux-mod_pkg_setup() { |
569 | linux-mod_pkg_setup() { |
| 576 | debug-print-function ${FUNCNAME} $* |
570 | debug-print-function ${FUNCNAME} $* |
| 577 | |
571 | |
|
|
572 | local is_bin="${MERGE_TYPE}" |
|
|
573 | |
|
|
574 | # If we are installing a binpkg, take a different path. |
|
|
575 | # use MERGE_TYPE if available (eapi>=4); else use non-PMS EMERGE_FROM (eapi<4) |
|
|
576 | if has ${EAPI} 0 1 2 3; then |
|
|
577 | is_bin=${EMERGE_FROM} |
|
|
578 | fi |
|
|
579 | |
|
|
580 | if [[ ${is_bin} == binary ]]; then |
|
|
581 | linux-mod_pkg_setup_binary |
|
|
582 | return |
|
|
583 | fi |
|
|
584 | |
| 578 | linux-info_pkg_setup; |
585 | linux-info_pkg_setup; |
| 579 | require_configured_kernel |
586 | require_configured_kernel |
| 580 | check_kernel_built; |
587 | check_kernel_built; |
| 581 | strip_modulenames; |
588 | strip_modulenames; |
| 582 | [[ -n ${MODULE_NAMES} ]] && check_modules_supported |
589 | [[ -n ${MODULE_NAMES} ]] && check_modules_supported |
| 583 | set_kvobj; |
590 | set_kvobj; |
| 584 | # Commented out with permission from johnm until a fixed version for arches |
591 | # Commented out with permission from johnm until a fixed version for arches |
| 585 | # who intentionally use different kernel and userland compilers can be |
592 | # who intentionally use different kernel and userland compilers can be |
| 586 | # introduced - Jason Wever <weeve@gentoo.org>, 23 Oct 2005 |
593 | # introduced - Jason Wever <weeve@gentoo.org>, 23 Oct 2005 |
| 587 | #check_vermagic; |
594 | #check_vermagic; |
|
|
595 | } |
|
|
596 | |
|
|
597 | # @FUNCTION: linux-mod_pkg_setup_binary |
|
|
598 | # @DESCRIPTION: |
|
|
599 | # Perform all kernel option checks non-fatally, as the .config and |
|
|
600 | # /proc/config.gz might not be present. Do not do anything that requires kernel |
|
|
601 | # sources. |
|
|
602 | linux-mod_pkg_setup_binary() { |
|
|
603 | debug-print-function ${FUNCNAME} $* |
|
|
604 | local new_CONFIG_CHECK |
|
|
605 | # ~ needs always to be quoted, else bash expands it. |
|
|
606 | for config in $CONFIG_CHECK ; do |
|
|
607 | optional='~' |
|
|
608 | [[ ${config:0:1} == "~" ]] && optional='' |
|
|
609 | new_CONFIG_CHECK="${new_CONFIG_CHECK} ${optional}${config}" |
|
|
610 | done |
|
|
611 | export CONFIG_CHECK="${new_CONFIG_CHECK}" |
|
|
612 | linux-info_pkg_setup; |
| 588 | } |
613 | } |
| 589 | |
614 | |
| 590 | strip_modulenames() { |
615 | strip_modulenames() { |
| 591 | debug-print-function ${FUNCNAME} $* |
616 | debug-print-function ${FUNCNAME} $* |
| 592 | |
617 | |
| … | |
… | |
| 626 | srcdir=${srcdir:-${S}} |
651 | srcdir=${srcdir:-${S}} |
| 627 | objdir=${objdir:-${srcdir}} |
652 | objdir=${objdir:-${srcdir}} |
| 628 | |
653 | |
| 629 | if [ ! -f "${srcdir}/.built" ]; |
654 | if [ ! -f "${srcdir}/.built" ]; |
| 630 | then |
655 | then |
| 631 | cd ${srcdir} |
656 | cd "${srcdir}" |
| 632 | ln -s "${S}"/Module.symvers Module.symvers |
657 | ln -s "${S}"/Module.symvers Module.symvers |
| 633 | einfo "Preparing ${modulename} module" |
658 | einfo "Preparing ${modulename} module" |
| 634 | if [[ -n ${ECONF_PARAMS} ]] |
659 | if [[ -n ${ECONF_PARAMS} ]] |
| 635 | then |
660 | then |
| 636 | econf ${ECONF_PARAMS} || \ |
661 | econf ${ECONF_PARAMS} || \ |
| … | |
… | |
| 647 | LDFLAGS=\"$(get_abi_LDFLAGS)\" \ |
672 | LDFLAGS=\"$(get_abi_LDFLAGS)\" \ |
| 648 | ${BUILD_FIXES} \ |
673 | ${BUILD_FIXES} \ |
| 649 | ${BUILD_PARAMS} \ |
674 | ${BUILD_PARAMS} \ |
| 650 | ${BUILD_TARGETS} " \ |
675 | ${BUILD_TARGETS} " \ |
| 651 | || die "Unable to emake HOSTCC="$(tc-getBUILD_CC)" CROSS_COMPILE=${CHOST}- LDFLAGS="$(get_abi_LDFLAGS)" ${BUILD_FIXES} ${BUILD_PARAMS} ${BUILD_TARGETS}" |
676 | || die "Unable to emake HOSTCC="$(tc-getBUILD_CC)" CROSS_COMPILE=${CHOST}- LDFLAGS="$(get_abi_LDFLAGS)" ${BUILD_FIXES} ${BUILD_PARAMS} ${BUILD_TARGETS}" |
| 652 | cd ${OLDPWD} |
677 | cd "${OLDPWD}" |
| 653 | touch ${srcdir}/.built |
678 | touch "${srcdir}"/.built |
| 654 | fi |
679 | fi |
| 655 | done |
680 | done |
| 656 | |
681 | |
| 657 | set_arch_to_portage |
682 | set_arch_to_portage |
| 658 | ABI="${myABI}" |
683 | ABI="${myABI}" |
| … | |
… | |
| 685 | libdir=${libdir:-misc} |
710 | libdir=${libdir:-misc} |
| 686 | srcdir=${srcdir:-${S}} |
711 | srcdir=${srcdir:-${S}} |
| 687 | objdir=${objdir:-${srcdir}} |
712 | objdir=${objdir:-${srcdir}} |
| 688 | |
713 | |
| 689 | einfo "Installing ${modulename} module" |
714 | einfo "Installing ${modulename} module" |
| 690 | cd ${objdir} || die "${objdir} does not exist" |
715 | cd "${objdir}" || die "${objdir} does not exist" |
| 691 | insinto /lib/modules/${KV_FULL}/${libdir} |
716 | insinto /lib/modules/${KV_FULL}/${libdir} |
| 692 | doins ${modulename}.${KV_OBJ} || die "doins ${modulename}.${KV_OBJ} failed" |
717 | doins ${modulename}.${KV_OBJ} || die "doins ${modulename}.${KV_OBJ} failed" |
| 693 | cd ${OLDPWD} |
718 | cd "${OLDPWD}" |
| 694 | |
719 | |
| 695 | generate_modulesd ${objdir}/${modulename} |
720 | generate_modulesd "${objdir}/${modulename}" |
| 696 | done |
721 | done |
| 697 | } |
722 | } |
| 698 | |
723 | |
| 699 | # @FUNCTION: linux-mod_pkg_preinst |
724 | # @FUNCTION: linux-mod_pkg_preinst |
| 700 | # @DESCRIPTION: |
725 | # @DESCRIPTION: |