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

Diff of /eclass/linux-info.eclass

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

Revision 1.29 Revision 1.40
1# Copyright 1999-2004 Gentoo Foundation 1# Copyright 1999-2006 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-info.eclass,v 1.29 2005/07/11 15:08:06 swegener Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/linux-info.eclass,v 1.40 2006/02/16 21:46:50 exg Exp $
4# 4#
5# Description: This eclass is used as a central eclass for accessing kernel 5# Description: This eclass is used as a central eclass for accessing kernel
6# related information for sources already installed. 6# related information for sources already installed.
7# It is vital for linux-mod to function correctly, and is split 7# It is vital for linux-mod to function correctly, and is split
8# out so that any ebuild behaviour "templates" are abstracted out 8# out so that any ebuild behaviour "templates" are abstracted out
22# CONFIG_CHECK <string> a list of .config options to check for before 22# CONFIG_CHECK <string> a list of .config options to check for before
23# proceeding with the install. ie: CONFIG_CHECK="MTRR" 23# proceeding with the install. ie: CONFIG_CHECK="MTRR"
24# You can also check that an option doesn't exist by 24# You can also check that an option doesn't exist by
25# prepending it with an exclamation mark (!). 25# prepending it with an exclamation mark (!).
26# ie: CONFIG_CHECK="!MTRR" 26# ie: CONFIG_CHECK="!MTRR"
27# To simply warn about a missing option, prepend a '~'.
27# ERROR_CFG <string> The error message to display when the above check 28# ERROR_CFG <string> The error message to display when the above check
28# fails. <CFG> should reference the appropriate option 29# fails. <CFG> should reference the appropriate option
29# as above. ie: ERROR_MTRR="MTRR exists in the .config 30# as above. ie: ERROR_MTRR="MTRR exists in the .config
30# but shouldn't!!" 31# but shouldn't!!"
31# KBUILD_OUTPUT <string> This is passed on commandline, or can be set from 32# KBUILD_OUTPUT <string> This is passed on commandline, or can be set from
50 51
51# And to ensure all the weirdness with crosscompile 52# And to ensure all the weirdness with crosscompile
52inherit toolchain-funcs versionator 53inherit toolchain-funcs versionator
53 54
54EXPORT_FUNCTIONS pkg_setup 55EXPORT_FUNCTIONS pkg_setup
56
57DEPEND="kernel_linux? ( virtual/linux-sources )"
58RDEPEND=""
55 59
56# Overwritable environment Var's 60# Overwritable environment Var's
57# --------------------------------------- 61# ---------------------------------------
58KERNEL_DIR="${KERNEL_DIR:-${ROOT}usr/src/linux}" 62KERNEL_DIR="${KERNEL_DIR:-${ROOT}usr/src/linux}"
59 63
107 then 111 then
108 echo -e "\n" 112 echo -e "\n"
109 eerror "getfilevar requires 2 variables, with the second a valid file." 113 eerror "getfilevar requires 2 variables, with the second a valid file."
110 eerror " getfilevar <VARIABLE> <CONFIGFILE>" 114 eerror " getfilevar <VARIABLE> <CONFIGFILE>"
111 else 115 else
112 workingdir=${PWD} 116 workingdir="${PWD}"
113 basefname=$(basename ${2}) 117 basefname="$(basename ${2})"
114 basedname=$(dirname ${2}) 118 basedname="$(dirname ${2})"
115 unset ARCH 119 unset ARCH
116 120
117 cd ${basedname} 121 cd "${basedname}"
118 echo -e "include ${basefname}\ne:\n\t@echo \$(${1})" | \ 122 echo -e "include ${basefname}\ne:\n\t@echo \$(${1})" | \
119 make ${BUILD_FIXES} -s -f - e 2>/dev/null 123 make ${BUILD_FIXES} -s -f - e 2>/dev/null
120 cd ${workingdir} 124 cd "${workingdir}"
121 125
122 ARCH=${myARCH} 126 ARCH=${myARCH}
123 fi 127 fi
124} 128}
125 129
190 done 194 done
191 195
192 [ ${test} ${operator} ${value} ] && return 0 || return 1 196 [ ${test} ${operator} ${value} ] && return 0 || return 1
193} 197}
194 198
199get_localversion() {
200 local lv_list i x
201
202 # ignore files with ~ in it.
203 for i in $(ls ${1}/localversion* 2>/dev/null); do
204 [[ -n ${i//*~*} ]] && lv_list="${lv_list} ${i}"
205 done
206
207 for i in ${lv_list}; do
208 x="${x}$(<${i})"
209 done
210 x=${x/ /}
211 echo ${x}
212}
213
195get_version() { 214get_version() {
196 local kbuild_output 215 local kbuild_output
197 216
198 # no need to execute this twice assuming KV_FULL is populated. 217 # no need to execute this twice assuming KV_FULL is populated.
199 # we can force by unsetting KV_FULL 218 # we can force by unsetting KV_FULL
269 if [ -n "${KV_OUT_DIR}" ]; 288 if [ -n "${KV_OUT_DIR}" ];
270 then 289 then
271 qeinfo "Found kernel object directory:" 290 qeinfo "Found kernel object directory:"
272 qeinfo " ${KV_OUT_DIR}" 291 qeinfo " ${KV_OUT_DIR}"
273 292
274 KV_LOCAL="$(cat ${KV_OUT_DIR}/localversion* 2>/dev/null)" 293 KV_LOCAL="$(get_localversion ${KV_OUT_DIR})"
275 fi 294 fi
276 # and if we STILL haven't got it, then we better just set it to KV_DIR 295 # and if we STILL haven't got it, then we better just set it to KV_DIR
277 KV_OUT_DIR="${KV_OUT_DIR:-${KV_DIR}}" 296 KV_OUT_DIR="${KV_OUT_DIR:-${KV_DIR}}"
278 297
279 KV_LOCAL="${KV_LOCAL}$(cat ${KV_DIR}/localversion* 2>/dev/null)" 298 KV_LOCAL="${KV_LOCAL}$(get_localversion ${KV_DIR})"
280 KV_LOCAL="${KV_LOCAL}$(linux_chkconfig_string LOCALVERSION)" 299 KV_LOCAL="${KV_LOCAL}$(linux_chkconfig_string LOCALVERSION)"
281 KV_LOCAL="${KV_LOCAL//\"/}" 300 KV_LOCAL="${KV_LOCAL//\"/}"
282 301
283 # And we should set KV_FULL to the full expanded version 302 # And we should set KV_FULL to the full expanded version
284 KV_FULL="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}${KV_LOCAL}" 303 KV_FULL="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}${KV_LOCAL}"
357 die "No support for external modules in ${KV_FULL} config" 376 die "No support for external modules in ${KV_FULL} config"
358 fi 377 fi
359} 378}
360 379
361check_extra_config() { 380check_extra_config() {
362 local config negate error local_error i n temp_config 381 local config negate error local_error i n
382 local temp_config die reworkmodulenames
363 383
364 # if we haven't determined the version yet, we need too. 384 # if we haven't determined the version yet, we need too.
365 get_version; 385 get_version;
366 386
367 einfo "Checking for suitable kernel configuration options" 387 einfo "Checking for suitable kernel configuration options:"
368 for config in ${CONFIG_CHECK} 388 for config in ${CONFIG_CHECK}
369 do 389 do
370 negate="${config:0:1}" 390 # if we specify any fatal, ensure we honor them
371 if [ "${negate}" == "!" ]; 391 die=1
372 then 392 error=0
393 negate=0
394 reworkmodulenames=0
395
396 if [[ -z ${config//\!*} ]]; then
397 negate=1
373 config="${config:1}" 398 config=${config:1}
374 if linux_chkconfig_present ${config}
375 then
376 local_error="${config}_ERROR"
377 local_error="${!local_error}"
378 [ -n "${local_error}" ] && eerror " ${local_error}" || \
379 eerror " CONFIG_${config}:\tshould not be set in the kernel configuration, but it is."
380 error=1
381 fi 399 fi
382 elif [ "${negate}" == "@" ]; 400 if [[ -z ${config/\@*} ]]; then
383 then 401 die=2
384 # we never call this unless we are using MODULE_NAMES 402 reworkmodulenames=1
385
386 config="${config:1}" 403 config=${config:1}
404 fi
405 if [[ -z ${config/\~*} ]]; then
406 die=0
407 config=${config:1}
408 fi
409
410 if [[ ${negate} == 1 ]]; then
411 linux_chkconfig_present ${config} && error=2
412 elif [[ ${reworkmodulenames} == 1 ]]; then
387 temp_config="${config//*:}" 413 temp_config="${config//*:}"
388 config="${config//:*}" 414 config="${config//:*}"
389 if linux_chkconfig_present ${config} 415 if linux_chkconfig_present ${config}; then
390 then
391 local_error="${config}_ERROR"
392 local_error="${!local_error}"
393 [ -n "${local_error}" ] && eerror " ${local_error}" || \
394 eerror " CONFIG_${config}:\tshould not be set in the kernel configuration, but it is."
395
396 for i in ${MODULE_NAMES} 416 for i in ${MODULE_NAMES}; do
397 do
398 n="${i//${temp_config}}" 417 n="${i//${temp_config}}"
418 [[ -z ${n//\(*} ]] && \
399 [ -z "${n//(*}" ] && MODULE_IGNORE="${MODULE_IGNORE} ${temp_config}" 419 MODULE_IGNORE="${MODULE_IGNORE} ${temp_config}"
400 done 420 done
401 error=0 421 error=2
402 fi 422 fi
403 else 423 else
404 if ! linux_chkconfig_present ${config} 424 linux_chkconfig_present ${config} || error=1
405 then 425 fi
406 # Support the new syntax first. 426
427 if [[ ${die} == 0 ]]; then
428 ebegin "CONFIG_${config}"
429 eend ${error}
430 else
431 if [[ ${error} > 0 ]]; then
407 local_error="ERROR_${config}" 432 local_error="ERROR_${config}"
408 local_error="${!local_error}" 433 local_error="${!local_error}"
409 434
410 # then fall back on the older syntax.
411 if [[ -z ${local_error} ]] ; then 435 if [[ -z "${local_error}" ]]; then
436 # using old, deprecated format.
412 local_error="${config}_ERROR" 437 local_error="${config}_ERROR"
413 local_error="${!local_error}" 438 local_error="${!local_error}"
414 fi 439 fi
415 440
416 [[ -n ${local_error} ]] && eerror " ${local_error}" || \ 441 if [[ -z "${local_error}" ]]; then
417 eerror " CONFIG_${config}:\tshould be set in the kernel configuration, but isn't" 442 [[ ${error} == 1 ]] \
418 error=1 443 && local_error="is not set when it should be." \
444 || local_error="should not be set. But it is."
445 local_error="CONFIG_${config}:\t ${local_error}"
446 fi
447 eerror " ${local_error}"
419 fi 448 fi
420 fi 449 fi
421 done 450 done
422 451
423 if [ "${error}" == 1 ] ; 452 if [[ ${error} > 0 ]]; then
424 then
425 eerror "Please check to make sure these options are set correctly." 453 eerror "Please check to make sure these options are set correctly."
454 eerror "Failure to do so may cause unexpected problems."
455 if [[ ${die} == 1 ]]; then
426 eerror "Once you have satisfied these options, please try merging" 456 eerror "Once you have satisfied these options, please try merging"
427 eerror "this package again." 457 eerror "this package again."
428 die "Incorrect kernel configuration options" 458 die "Incorrect kernel configuration options"
459 fi
429 fi 460 fi
430} 461}
431 462
432check_zlibinflate() { 463check_zlibinflate() {
433 # if we haven't determined the version yet, we need too. 464 # if we haven't determined the version yet, we need too.

Legend:
Removed from v.1.29  
changed lines
  Added in v.1.40

  ViewVC Help
Powered by ViewVC 1.1.20