/[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.60 Revision 1.71
1# Copyright 1999-2006 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.60 2009/07/04 18:39:33 robbat2 Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/linux-info.eclass,v 1.71 2009/09/08 12:34:21 robbat2 Exp $
4# 4#
5# Original author: John Mylchreest <johnm@gentoo.org> 5# Original author: John Mylchreest <johnm@gentoo.org>
6# Maintainer: kernel-misc@gentoo.org 6# Maintainer: kernel-misc@gentoo.org
7# 7#
8# Please direct your bugs to the current eclass maintainer :) 8# Please direct your bugs to the current eclass maintainer :)
11# @MAINTAINER: 11# @MAINTAINER:
12# kernel-misc@gentoo.org 12# kernel-misc@gentoo.org
13# @BLURB: eclass used for accessing kernel related information 13# @BLURB: eclass used for accessing kernel related information
14# @DESCRIPTION: 14# @DESCRIPTION:
15# This eclass is used as a central eclass for accessing kernel 15# This eclass is used as a central eclass for accessing kernel
16# related information for sources already installed. 16# related information for source or binary already installed.
17# It is vital for linux-mod.eclass to function correctly, and is split 17# It is vital for linux-mod.eclass to function correctly, and is split
18# out so that any ebuild behaviour "templates" are abstracted out 18# out so that any ebuild behaviour "templates" are abstracted out
19# using additional eclasses. 19# using additional eclasses.
20#
21# "kernel config" in this file means:
22# The .config of the currently installed sources is used as the first
23# preference, with a fall-back to bundled config (/proc/config.gz) if available.
20 24
21# A Couple of env vars are available to effect usage of this eclass 25# A Couple of env vars are available to effect usage of this eclass
22# These are as follows: 26# These are as follows:
23 27
24# @ECLASS-VARIABLE: KERNEL_DIR 28# @ECLASS-VARIABLE: KERNEL_DIR
36# You can also check that an option doesn't exist by 40# You can also check that an option doesn't exist by
37# prepending it with an exclamation mark (!). 41# prepending it with an exclamation mark (!).
38# 42#
39# e.g.: CONFIG_CHECK="!MTRR" 43# e.g.: CONFIG_CHECK="!MTRR"
40# 44#
41# To simply warn about a missing option, prepend a '~'. 45# To simply warn about a missing option, prepend a '~'.
46# It may be combined with '!'.
47#
48# In general, most checks should be non-fatal. The only time fatal checks should
49# be used is for building kernel modules or cases that a compile will fail
50# without the option.
51#
52# This is to allow usage of binary kernels, and minimal systems without kernel
53# sources.
42 54
43# @ECLASS-VARIABLE: ERROR_<CFG> 55# @ECLASS-VARIABLE: ERROR_<CFG>
44# @DESCRIPTION: 56# @DESCRIPTION:
45# A string containing the error message to display when the check against CONFIG_CHECK 57# A string containing the error message to display when the check against CONFIG_CHECK
46# fails. <CFG> should reference the appropriate option used in CONFIG_CHECK. 58# fails. <CFG> should reference the appropriate option used in CONFIG_CHECK.
87# @ECLASS-VARIABLE: KV_OUT_DIR 99# @ECLASS-VARIABLE: KV_OUT_DIR
88# @DESCRIPTION: 100# @DESCRIPTION:
89# A read-only variable. It's a string containing the kernel object directory, will be KV_DIR unless 101# A read-only variable. It's a string containing the kernel object directory, will be KV_DIR unless
90# KBUILD_OUTPUT is used. This should be used for referencing .config. 102# KBUILD_OUTPUT is used. This should be used for referencing .config.
91 103
104# @ECLASS-VARIABLE: I_KNOW_WHAT_I_AM_DOING
105# @DESCRIPTION:
106# Temporary variable for the migration to making linux-info non-fatal.
107
92# And to ensure all the weirdness with crosscompile 108# And to ensure all the weirdness with crosscompile
93inherit toolchain-funcs versionator 109inherit toolchain-funcs versionator
94 110
95EXPORT_FUNCTIONS pkg_setup 111EXPORT_FUNCTIONS pkg_setup
96 112
113DEPEND=""
114RDEPEND=""
115
116[ -z "${I_KNOW_WHAT_I_AM_DOING}" ] && \
97DEPEND="kernel_linux? ( virtual/linux-sources )" 117DEPEND="kernel_linux? ( virtual/linux-sources )"
98RDEPEND=""
99 118
100# Overwritable environment Var's 119# Overwritable environment Var's
101# --------------------------------------- 120# ---------------------------------------
102KERNEL_DIR="${KERNEL_DIR:-${ROOT}usr/src/linux}" 121KERNEL_DIR="${KERNEL_DIR:-${ROOT}usr/src/linux}"
103 122
143 162
144# @FUNCTION: getfilevar 163# @FUNCTION: getfilevar
145# @USAGE: variable configfile 164# @USAGE: variable configfile
146# @RETURN: the value of the variable 165# @RETURN: the value of the variable
147# @DESCRIPTION: 166# @DESCRIPTION:
148# It detects the value of the variable defined in the file configfile 167# It detects the value of the variable defined in the file configfile. This is
168# done by including the configfile, and printing the variable with Make.
169# It WILL break if your makefile has missing dependencies!
149getfilevar() { 170getfilevar() {
150local ERROR basefname basedname myARCH="${ARCH}" 171local ERROR basefname basedname myARCH="${ARCH}"
151 ERROR=0 172 ERROR=0
152 173
153 [ -z "${1}" ] && ERROR=1 174 [ -z "${1}" ] && ERROR=1
168 189
169 ARCH=${myARCH} 190 ARCH=${myARCH}
170 fi 191 fi
171} 192}
172 193
194# @FUNCTION: getfilevar_noexec
195# @USAGE: variable configfile
196# @RETURN: the value of the variable
197# @DESCRIPTION:
198# It detects the value of the variable defined in the file configfile.
199# This is done with sed matching an expression only. If the variable is defined,
200# you will run into problems. See getfilevar for those cases.
201getfilevar_noexec() {
202 local ERROR basefname basedname mycat myARCH="${ARCH}"
203 ERROR=0
204 mycat='cat'
205
206 [ -z "${1}" ] && ERROR=1
207 [ ! -f "${2}" ] && ERROR=1
208 [ "${2%.gz}" != "${2}" ] && mycat='zcat'
209
210 if [ "${ERROR}" = 1 ]
211 then
212 echo -e "\n"
213 eerror "getfilevar_noexec requires 2 variables, with the second a valid file."
214 eerror " getfilevar_noexec <VARIABLE> <CONFIGFILE>"
215 else
216 ${mycat} "${2}" | \
217 sed -n \
218 -e "/^[[:space:]]*${1}[[:space:]]*=[[:space:]]*\(.*\)\$/{
219 s,^[^=]*[[:space:]]*=[[:space:]]*,,g ;
220 s,[[:space:]]*\$,,g ;
221 p
222 }"
223 fi
224}
225
226
227# @FUNCTION: linux_config_src_exists
228# @RETURN: true or false
229# @DESCRIPTION:
230# It returns true if .config exists in a build directory otherwise false
231linux_config_src_exists() {
232 [ -s "${KV_OUT_DIR}/.config" ]
233}
234
235# @FUNCTION: linux_config_bin_exists
236# @RETURN: true or false
237# @DESCRIPTION:
238# It returns true if .config exists in /proc, otherwise false
239linux_config_bin_exists() {
240 [ -s "/proc/config.gz" ]
241}
173 242
174# @FUNCTION: linux_config_exists 243# @FUNCTION: linux_config_exists
175# @RETURN: true or false 244# @RETURN: true or false
176# @DESCRIPTION: 245# @DESCRIPTION:
177# It returns true if .config exists otherwise false 246# It returns true if .config exists otherwise false
247#
248# This function MUST be checked before using any of the linux_chkconfig_*
249# functions.
178linux_config_exists() { 250linux_config_exists() {
179 [ -s "${KV_OUT_DIR}/.config" ] 251 linux_config_src_exists || linux_config_bin_exists
180} 252}
181 253
182# @FUNCTION: require_configured_kernel 254# @FUNCTION: require_configured_kernel
183# @DESCRIPTION: 255# @DESCRIPTION:
184# This function verifies that the current kernel is configured (it checks against the existence of .config) 256# This function verifies that the current kernel is configured (it checks against the existence of .config)
185# otherwise it dies. 257# otherwise it dies.
186require_configured_kernel() { 258require_configured_kernel() {
187 if ! linux_config_exists; then 259 if ! linux_config_src_exists; then
188 qeerror "Could not find a usable .config in the kernel source directory." 260 qeerror "Could not find a usable .config in the kernel source directory."
189 qeerror "Please ensure that ${KERNEL_DIR} points to a configured set of Linux sources." 261 qeerror "Please ensure that ${KERNEL_DIR} points to a configured set of Linux sources."
190 qeerror "If you are using KBUILD_OUTPUT, please set the environment var so that" 262 qeerror "If you are using KBUILD_OUTPUT, please set the environment var so that"
191 qeerror "it points to the necessary object directory so that it might find .config." 263 qeerror "it points to the necessary object directory so that it might find .config."
192 die "Kernel not configured; no .config found in ${KV_OUT_DIR}" 264 die "Kernel not configured; no .config found in ${KV_OUT_DIR}"
196# @FUNCTION: linux_chkconfig_present 268# @FUNCTION: linux_chkconfig_present
197# @USAGE: option 269# @USAGE: option
198# @RETURN: true or false 270# @RETURN: true or false
199# @DESCRIPTION: 271# @DESCRIPTION:
200# It checks that CONFIG_<option>=y or CONFIG_<option>=m is present in the current kernel .config 272# It checks that CONFIG_<option>=y or CONFIG_<option>=m is present in the current kernel .config
273# If linux_config_exists returns false, the results of this are UNDEFINED. You
274# MUST call linux_config_exists first.
201linux_chkconfig_present() { 275linux_chkconfig_present() {
202local RESULT 276local RESULT
203 require_configured_kernel 277 [ -z "${I_KNOW_WHAT_I_AM_DOING}" ] && require_configured_kernel
278 local config
279 config="${KV_OUT_DIR}/.config"
280 [ ! -f "${config}" ] && config="/proc/config.gz"
204 RESULT="$(getfilevar CONFIG_${1} ${KV_OUT_DIR}/.config)" 281 RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")"
205 [ "${RESULT}" = "m" -o "${RESULT}" = "y" ] && return 0 || return 1 282 [ "${RESULT}" = "m" -o "${RESULT}" = "y" ] && return 0 || return 1
206} 283}
207 284
208# @FUNCTION: linux_chkconfig_module 285# @FUNCTION: linux_chkconfig_module
209# @USAGE: option 286# @USAGE: option
210# @RETURN: true or false 287# @RETURN: true or false
211# @DESCRIPTION: 288# @DESCRIPTION:
212# It checks that CONFIG_<option>=m is present in the current kernel .config 289# It checks that CONFIG_<option>=m is present in the current kernel .config
290# If linux_config_exists returns false, the results of this are UNDEFINED. You
291# MUST call linux_config_exists first.
213linux_chkconfig_module() { 292linux_chkconfig_module() {
214local RESULT 293local RESULT
215 require_configured_kernel 294 [ -z "${I_KNOW_WHAT_I_AM_DOING}" ] && require_configured_kernel
295 local config
296 config="${KV_OUT_DIR}/.config"
297 [ ! -f "${config}" ] && config="/proc/config.gz"
216 RESULT="$(getfilevar CONFIG_${1} ${KV_OUT_DIR}/.config)" 298 RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")"
217 [ "${RESULT}" = "m" ] && return 0 || return 1 299 [ "${RESULT}" = "m" ] && return 0 || return 1
218} 300}
219 301
220# @FUNCTION: linux_chkconfig_builtin 302# @FUNCTION: linux_chkconfig_builtin
221# @USAGE: option 303# @USAGE: option
222# @RETURN: true or false 304# @RETURN: true or false
223# @DESCRIPTION: 305# @DESCRIPTION:
224# It checks that CONFIG_<option>=y is present in the current kernel .config 306# It checks that CONFIG_<option>=y is present in the current kernel .config
307# If linux_config_exists returns false, the results of this are UNDEFINED. You
308# MUST call linux_config_exists first.
225linux_chkconfig_builtin() { 309linux_chkconfig_builtin() {
226local RESULT 310local RESULT
227 require_configured_kernel 311 [ -z "${I_KNOW_WHAT_I_AM_DOING}" ] && require_configured_kernel
312 local config
313 config="${KV_OUT_DIR}/.config"
314 [ ! -f "${config}" ] && config="/proc/config.gz"
228 RESULT="$(getfilevar CONFIG_${1} ${KV_OUT_DIR}/.config)" 315 RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")"
229 [ "${RESULT}" = "y" ] && return 0 || return 1 316 [ "${RESULT}" = "y" ] && return 0 || return 1
230} 317}
231 318
232# @FUNCTION: linux_chkconfig_string 319# @FUNCTION: linux_chkconfig_string
233# @USAGE: option 320# @USAGE: option
234# @RETURN: CONFIG_<option> 321# @RETURN: CONFIG_<option>
235# @DESCRIPTION: 322# @DESCRIPTION:
236# It prints the CONFIG_<option> value of the current kernel .config (it requires a configured kernel). 323# It prints the CONFIG_<option> value of the current kernel .config (it requires a configured kernel).
324# If linux_config_exists returns false, the results of this are UNDEFINED. You
325# MUST call linux_config_exists first.
237linux_chkconfig_string() { 326linux_chkconfig_string() {
238 require_configured_kernel 327 [ -z "${I_KNOW_WHAT_I_AM_DOING}" ] && require_configured_kernel
328 local config
329 config="${KV_OUT_DIR}/.config"
330 [ ! -f "${config}" ] && config="/proc/config.gz"
239 getfilevar "CONFIG_${1}" "${KV_OUT_DIR}/.config" 331 getfilevar_noexec "CONFIG_${1}" "${config}"
240} 332}
241 333
242# Versioning Functions 334# Versioning Functions
243# --------------------------------------- 335# ---------------------------------------
244 336
260 352
261# got the jist yet? 353# got the jist yet?
262 354
263kernel_is() { 355kernel_is() {
264 # if we haven't determined the version yet, we need to. 356 # if we haven't determined the version yet, we need to.
265 get_version 357 linux-info_get_any_version
358
266 local operator test value x=0 y=0 z=0 359 local operator test value x=0 y=0 z=0
267 360
268 case ${1} in 361 case ${1} in
269 lt) operator="-lt"; shift;; 362 -lt|lt) operator="-lt"; shift;;
270 gt) operator="-gt"; shift;; 363 -gt|gt) operator="-gt"; shift;;
271 le) operator="-le"; shift;; 364 -le|le) operator="-le"; shift;;
272 ge) operator="-ge"; shift;; 365 -ge|ge) operator="-ge"; shift;;
273 eq) operator="-eq"; shift;; 366 -eq|eq) operator="-eq"; shift;;
274 *) operator="-eq";; 367 *) operator="-eq";;
275 esac 368 esac
276 369
277 for x in ${@}; do 370 for x in ${@}; do
278 for((y=0; y<$((3 - ${#x})); y++)); do value="${value}0"; done 371 for((y=0; y<$((3 - ${#x})); y++)); do value="${value}0"; done
279 value="${value}${x}" 372 value="${value}${x}"
287 3) for((y=0; y<$((3 - ${#KV_PATCH})); y++)); do test="${test}0"; done; 380 3) for((y=0; y<$((3 - ${#KV_PATCH})); y++)); do test="${test}0"; done;
288 test="${test}${KV_PATCH}";; 381 test="${test}${KV_PATCH}";;
289 *) die "Error in kernel-2_kernel_is(): Too many parameters.";; 382 *) die "Error in kernel-2_kernel_is(): Too many parameters.";;
290 esac 383 esac
291 done 384 done
292 385
293 [ ${test} ${operator} ${value} ] && return 0 || return 1 386 [ ${test} ${operator} ${value} ] && return 0 || return 1
294} 387}
295 388
296get_localversion() { 389get_localversion() {
297 local lv_list i x 390 local lv_list i x
306 done 399 done
307 x=${x/ /} 400 x=${x/ /}
308 echo ${x} 401 echo ${x}
309} 402}
310 403
404# internal variable, so we know to only print the warning once
405get_version_warning_done=
406
311# @FUNCTION: get_version 407# @FUNCTION: get_version
312# @DESCRIPTION: 408# @DESCRIPTION:
313# It gets the version of the kernel inside KERNEL_DIR and populates the KV_FULL variable 409# It gets the version of the kernel inside KERNEL_DIR and populates the KV_FULL variable
314# (if KV_FULL is already set it does nothing). 410# (if KV_FULL is already set it does nothing).
315# 411#
328 # if we dont know KV_FULL, then we need too. 424 # if we dont know KV_FULL, then we need too.
329 # make sure KV_DIR isnt set since we need to work it out via KERNEL_DIR 425 # make sure KV_DIR isnt set since we need to work it out via KERNEL_DIR
330 unset KV_DIR 426 unset KV_DIR
331 427
332 # KV_DIR will contain the full path to the sources directory we should use 428 # KV_DIR will contain the full path to the sources directory we should use
429 [ -z "${get_version_warning_done}" ] && \
333 qeinfo "Determining the location of the kernel source code" 430 qeinfo "Determining the location of the kernel source code"
334 [ -h "${KERNEL_DIR}" ] && KV_DIR="$(readlink -f ${KERNEL_DIR})" 431 [ -h "${KERNEL_DIR}" ] && KV_DIR="$(readlink -f ${KERNEL_DIR})"
335 [ -d "${KERNEL_DIR}" ] && KV_DIR="${KERNEL_DIR}" 432 [ -d "${KERNEL_DIR}" ] && KV_DIR="${KERNEL_DIR}"
336 433
337 if [ -z "${KV_DIR}" ] 434 if [ -z "${KV_DIR}" ]
338 then 435 then
436 if [ -z "${get_version_warning_done}" ]; then
437 get_version_warning_done=1
339 qeerror "Unable to find kernel sources at ${KERNEL_DIR}" 438 qeerror "Unable to find kernel sources at ${KERNEL_DIR}"
340 qeinfo "This package requires Linux sources." 439 #qeinfo "This package requires Linux sources."
341 if [ "${KERNEL_DIR}" == "/usr/src/linux" ] ; then 440 if [ "${KERNEL_DIR}" == "/usr/src/linux" ] ; then
342 qeinfo "Please make sure that ${KERNEL_DIR} points at your running kernel, " 441 qeinfo "Please make sure that ${KERNEL_DIR} points at your running kernel, "
343 qeinfo "(or the kernel you wish to build against)." 442 qeinfo "(or the kernel you wish to build against)."
344 qeinfo "Alternatively, set the KERNEL_DIR environment variable to the kernel sources location" 443 qeinfo "Alternatively, set the KERNEL_DIR environment variable to the kernel sources location"
345 else 444 else
346 qeinfo "Please ensure that the KERNEL_DIR environment variable points at full Linux sources of the kernel you wish to compile against." 445 qeinfo "Please ensure that the KERNEL_DIR environment variable points at full Linux sources of the kernel you wish to compile against."
446 fi
347 fi 447 fi
348 return 1 448 return 1
349 fi 449 fi
350 450
451 if [ -z "${get_version_warning_done}" ]; then
351 qeinfo "Found kernel source directory:" 452 qeinfo "Found kernel source directory:"
352 qeinfo " ${KV_DIR}" 453 qeinfo " ${KV_DIR}"
454 fi
353 455
354 if [ ! -s "${KV_DIR}/Makefile" ] 456 if [ ! -s "${KV_DIR}/Makefile" ]
355 then 457 then
458 if [ -z "${get_version_warning_done}" ]; then
459 get_version_warning_done=1
356 qeerror "Could not find a Makefile in the kernel source directory." 460 qeerror "Could not find a Makefile in the kernel source directory."
357 qeerror "Please ensure that ${KERNEL_DIR} points to a complete set of Linux sources" 461 qeerror "Please ensure that ${KERNEL_DIR} points to a complete set of Linux sources"
462 fi
358 return 1 463 return 1
359 fi 464 fi
360 465
361 # OK so now we know our sources directory, but they might be using 466 # OK so now we know our sources directory, but they might be using
362 # KBUILD_OUTPUT, and we need this for .config and localversions-* 467 # KBUILD_OUTPUT, and we need this for .config and localversions-*
363 # so we better find it eh? 468 # so we better find it eh?
364 # do we pass KBUILD_OUTPUT on the CLI? 469 # do we pass KBUILD_OUTPUT on the CLI?
365 OUTPUT_DIR="${OUTPUT_DIR:-${KBUILD_OUTPUT}}" 470 OUTPUT_DIR="${OUTPUT_DIR:-${KBUILD_OUTPUT}}"
366 471
367 # And if we didn't pass it, we can take a nosey in the Makefile 472 # And if we didn't pass it, we can take a nosey in the Makefile
368 kbuild_output="$(getfilevar KBUILD_OUTPUT ${KV_DIR}/Makefile)" 473 kbuild_output="$(getfilevar_noexec KBUILD_OUTPUT ${KV_DIR}/Makefile)"
369 OUTPUT_DIR="${OUTPUT_DIR:-${kbuild_output}}" 474 OUTPUT_DIR="${OUTPUT_DIR:-${kbuild_output}}"
370 475
371 # And contrary to existing functions I feel we shouldn't trust the 476 # And contrary to existing functions I feel we shouldn't trust the
372 # directory name to find version information as this seems insane. 477 # directory name to find version information as this seems insane.
373 # so we parse ${KV_DIR}/Makefile 478 # so we parse ${KV_DIR}/Makefile
374 KV_MAJOR="$(getfilevar VERSION ${KV_DIR}/Makefile)" 479 KV_MAJOR="$(getfilevar_noexec VERSION ${KV_DIR}/Makefile)"
375 KV_MINOR="$(getfilevar PATCHLEVEL ${KV_DIR}/Makefile)" 480 KV_MINOR="$(getfilevar_noexec PATCHLEVEL ${KV_DIR}/Makefile)"
376 KV_PATCH="$(getfilevar SUBLEVEL ${KV_DIR}/Makefile)" 481 KV_PATCH="$(getfilevar_noexec SUBLEVEL ${KV_DIR}/Makefile)"
377 KV_EXTRA="$(getfilevar EXTRAVERSION ${KV_DIR}/Makefile)" 482 KV_EXTRA="$(getfilevar_noexec EXTRAVERSION ${KV_DIR}/Makefile)"
378 483
379 if [ -z "${KV_MAJOR}" -o -z "${KV_MINOR}" -o -z "${KV_PATCH}" ] 484 if [ -z "${KV_MAJOR}" -o -z "${KV_MINOR}" -o -z "${KV_PATCH}" ]
380 then 485 then
486 if [ -z "${get_version_warning_done}" ]; then
487 get_version_warning_done=1
381 qeerror "Could not detect kernel version." 488 qeerror "Could not detect kernel version."
382 qeerror "Please ensure that ${KERNEL_DIR} points to a complete set of Linux sources." 489 qeerror "Please ensure that ${KERNEL_DIR} points to a complete set of Linux sources."
490 fi
383 return 1 491 return 1
384 fi 492 fi
385 493
386 # and in newer versions we can also pull LOCALVERSION if it is set. 494 # and in newer versions we can also pull LOCALVERSION if it is set.
387 # but before we do this, we need to find if we use a different object directory. 495 # but before we do this, we need to find if we use a different object directory.
401 fi 509 fi
402 # and if we STILL have not got it, then we better just set it to KV_DIR 510 # and if we STILL have not got it, then we better just set it to KV_DIR
403 KV_OUT_DIR="${KV_OUT_DIR:-${KV_DIR}}" 511 KV_OUT_DIR="${KV_OUT_DIR:-${KV_DIR}}"
404 512
405 KV_LOCAL="${KV_LOCAL}$(get_localversion ${KV_DIR})" 513 KV_LOCAL="${KV_LOCAL}$(get_localversion ${KV_DIR})"
406 if linux_config_exists; then 514 if linux_config_src_exists; then
407 KV_LOCAL="${KV_LOCAL}$(linux_chkconfig_string LOCALVERSION)" 515 KV_LOCAL="${KV_LOCAL}$(linux_chkconfig_string LOCALVERSION)"
408 KV_LOCAL="${KV_LOCAL//\"/}" 516 KV_LOCAL="${KV_LOCAL//\"/}"
409 517
410 # For things like git that can append extra stuff: 518 # For things like git that can append extra stuff:
411 [ -e ${KV_DIR}/scripts/setlocalversion ] && 519 [ -e ${KV_DIR}/scripts/setlocalversion ] &&
448 && KV_EXTRA="-${KV_FULL#*-}" 556 && KV_EXTRA="-${KV_FULL#*-}"
449 fi 557 fi
450 return 0 558 return 0
451} 559}
452 560
561# This next function is named with the eclass prefix to avoid conflicts with
562# some old versionator-like eclass functions.
563
564# @FUNCTION: linux-info_get_any_version
565# @DESCRIPTION:
566# This attempts to find the version of the sources, and otherwise falls back to
567# the version of the running kernel.
568linux-info_get_any_version() {
569 get_version
570 if [[ $? -ne 0 ]]; then
571 ewarn "Unable to calculate Linux Kernel version for build, attempting to use running version"
572 get_running_version
573 fi
574}
575
453 576
454# ebuild check functions 577# ebuild check functions
455# --------------------------------------- 578# ---------------------------------------
456 579
457# @FUNCTION: check_kernel_built 580# @FUNCTION: check_kernel_built
501check_extra_config() { 624check_extra_config() {
502 local config negate die error reworkmodulenames 625 local config negate die error reworkmodulenames
503 local soft_errors_count=0 hard_errors_count=0 config_required=0 626 local soft_errors_count=0 hard_errors_count=0 config_required=0
504 627
505 # if we haven't determined the version yet, we need to 628 # if we haven't determined the version yet, we need to
506 get_version 629 linux-info_get_any_version
507 630
508 # Determine if we really need a .config. The only time when we don't need 631 # Determine if we really need a .config. The only time when we don't need
509 # one is when all of the CONFIG_CHECK options are prefixed with "~". 632 # one is when all of the CONFIG_CHECK options are prefixed with "~".
510 for config in ${CONFIG_CHECK} 633 for config in ${CONFIG_CHECK}
511 do 634 do
519 # In the case where we don't require a .config, we can now bail out 642 # In the case where we don't require a .config, we can now bail out
520 # if the user has no .config as there is nothing to do. Otherwise 643 # if the user has no .config as there is nothing to do. Otherwise
521 # code later will cause a failure due to missing .config. 644 # code later will cause a failure due to missing .config.
522 if ! linux_config_exists; then 645 if ! linux_config_exists; then
523 ewarn "Unable to check for the following kernel config options due" 646 ewarn "Unable to check for the following kernel config options due"
524 ewarn "to absence of any configured kernel sources:" 647 ewarn "to absence of any configured kernel sources or compiled"
648 ewarn "config:"
525 for config in ${CONFIG_CHECK}; do 649 for config in ${CONFIG_CHECK}; do
526 ewarn " - ${config#\~}" 650 ewarn " - ${config#\~}"
527 done 651 done
528 ewarn "You're on your own to make sure they are set if needed." 652 ewarn "You're on your own to make sure they are set if needed."
529 return 0 653 return 0
530 fi 654 fi
531 else 655 else
532 require_configured_kernel 656 [ -n "${I_KNOW_WHAT_I_AM_DOING}" ] && require_configured_kernel
533 fi 657 fi
534 658
535 einfo "Checking for suitable kernel configuration options..." 659 einfo "Checking for suitable kernel configuration options..."
536 660
537 for config in ${CONFIG_CHECK} 661 for config in ${CONFIG_CHECK}
639 local DEFLATE 763 local DEFLATE
640 764
641 einfo "Determining the usability of ZLIB_INFLATE support in your kernel" 765 einfo "Determining the usability of ZLIB_INFLATE support in your kernel"
642 766
643 ebegin "checking ZLIB_INFLATE" 767 ebegin "checking ZLIB_INFLATE"
644 getfilevar_isbuiltin CONFIG_ZLIB_INFLATE ${KV_DIR}/.config 768 linux_chkconfig_builtin CONFIG_ZLIB_INFLATE
645 eend $? 769 eend $?
646 [ "$?" != 0 ] && die 770 [ "$?" != 0 ] && die
647 771
648 ebegin "checking ZLIB_DEFLATE" 772 ebegin "checking ZLIB_DEFLATE"
649 getfilevar_isbuiltin CONFIG_ZLIB_DEFLATE ${KV_DIR}/.config 773 linux_chkconfig_builtin CONFIG_ZLIB_DEFLATE
650 eend $? 774 eend $?
651 [ "$?" != 0 ] && die 775 [ "$?" != 0 ] && die
652 776
653 local LINENO_START 777 local LINENO_START
654 local LINENO_END 778 local LINENO_END
697# @FUNCTION: linux-info_pkg_setup 821# @FUNCTION: linux-info_pkg_setup
698# @DESCRIPTION: 822# @DESCRIPTION:
699# Force a get_version() call when inherited from linux-mod.eclass and then check if the kernel is configured 823# Force a get_version() call when inherited from linux-mod.eclass and then check if the kernel is configured
700# to support the options specified in CONFIG_CHECK (if not null) 824# to support the options specified in CONFIG_CHECK (if not null)
701linux-info_pkg_setup() { 825linux-info_pkg_setup() {
702 get_version || die "Unable to calculate Linux Kernel version" 826 linux-info_get_any_version
703 827
704 if kernel_is 2 4; then 828 if kernel_is 2 4; then
705 if [ "$( gcc-major-version )" -eq "4" ] ; then 829 if [ "$( gcc-major-version )" -eq "4" ] ; then
706 echo 830 echo
707 ewarn "Be warned !! >=sys-devel/gcc-4.0.0 isn't supported with" 831 ewarn "Be warned !! >=sys-devel/gcc-4.0.0 isn't supported with"

Legend:
Removed from v.1.60  
changed lines
  Added in v.1.71

  ViewVC Help
Powered by ViewVC 1.1.20