/[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.56 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.56 2008/10/31 22:01:32 dsd 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 workingdir 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
154 [ ! -f "${2}" ] && ERROR=1 175 [ ! -f "${2}" ] && ERROR=1
155 176
157 then 178 then
158 echo -e "\n" 179 echo -e "\n"
159 eerror "getfilevar requires 2 variables, with the second a valid file." 180 eerror "getfilevar requires 2 variables, with the second a valid file."
160 eerror " getfilevar <VARIABLE> <CONFIGFILE>" 181 eerror " getfilevar <VARIABLE> <CONFIGFILE>"
161 else 182 else
162 workingdir="${PWD}"
163 basefname="$(basename ${2})" 183 basefname="$(basename ${2})"
164 basedname="$(dirname ${2})" 184 basedname="$(dirname ${2})"
165 unset ARCH 185 unset ARCH
166 186
167 cd "${basedname}"
168 echo -e "e:\\n\\t@echo \$(${1})\\ninclude ${basefname}" | \ 187 echo -e "e:\\n\\t@echo \$(${1})\\ninclude ${basefname}" | \
169 make M="${S}" ${BUILD_FIXES} -s -f - 2>/dev/null 188 make -C "${basedname}" M="${S}" ${BUILD_FIXES} -s -f - 2>/dev/null
170 cd "${workingdir}"
171 189
172 ARCH=${myARCH} 190 ARCH=${myARCH}
173 fi 191 fi
174} 192}
175 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}
176 242
177# @FUNCTION: linux_config_exists 243# @FUNCTION: linux_config_exists
178# @RETURN: true or false 244# @RETURN: true or false
179# @DESCRIPTION: 245# @DESCRIPTION:
180# 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.
181linux_config_exists() { 250linux_config_exists() {
182 [ -s "${KV_OUT_DIR}/.config" ] 251 linux_config_src_exists || linux_config_bin_exists
183} 252}
184 253
185# @FUNCTION: require_configured_kernel 254# @FUNCTION: require_configured_kernel
186# @DESCRIPTION: 255# @DESCRIPTION:
187# 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)
188# otherwise it dies. 257# otherwise it dies.
189require_configured_kernel() { 258require_configured_kernel() {
190 if ! linux_config_exists; then 259 if ! linux_config_src_exists; then
191 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."
192 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."
193 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"
194 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."
195 die "Kernel not configured; no .config found in ${KV_OUT_DIR}" 264 die "Kernel not configured; no .config found in ${KV_OUT_DIR}"
198 267
199# @FUNCTION: linux_chkconfig_present 268# @FUNCTION: linux_chkconfig_present
200# @USAGE: option 269# @USAGE: option
201# @RETURN: true or false 270# @RETURN: true or false
202# @DESCRIPTION: 271# @DESCRIPTION:
203# It checks that CONFIG_<option>=y or CONFIG_<option>=n 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.
204linux_chkconfig_present() { 275linux_chkconfig_present() {
205local RESULT 276local RESULT
206 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"
207 RESULT="$(getfilevar CONFIG_${1} ${KV_OUT_DIR}/.config)" 281 RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")"
208 [ "${RESULT}" = "m" -o "${RESULT}" = "y" ] && return 0 || return 1 282 [ "${RESULT}" = "m" -o "${RESULT}" = "y" ] && return 0 || return 1
209} 283}
210 284
211# @FUNCTION: linux_chkconfig_module 285# @FUNCTION: linux_chkconfig_module
212# @USAGE: option 286# @USAGE: option
213# @RETURN: true or false 287# @RETURN: true or false
214# @DESCRIPTION: 288# @DESCRIPTION:
215# 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.
216linux_chkconfig_module() { 292linux_chkconfig_module() {
217local RESULT 293local RESULT
218 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"
219 RESULT="$(getfilevar CONFIG_${1} ${KV_OUT_DIR}/.config)" 298 RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")"
220 [ "${RESULT}" = "m" ] && return 0 || return 1 299 [ "${RESULT}" = "m" ] && return 0 || return 1
221} 300}
222 301
223# @FUNCTION: linux_chkconfig_builtin 302# @FUNCTION: linux_chkconfig_builtin
224# @USAGE: option 303# @USAGE: option
225# @RETURN: true or false 304# @RETURN: true or false
226# @DESCRIPTION: 305# @DESCRIPTION:
227# 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.
228linux_chkconfig_builtin() { 309linux_chkconfig_builtin() {
229local RESULT 310local RESULT
230 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"
231 RESULT="$(getfilevar CONFIG_${1} ${KV_OUT_DIR}/.config)" 315 RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")"
232 [ "${RESULT}" = "y" ] && return 0 || return 1 316 [ "${RESULT}" = "y" ] && return 0 || return 1
233} 317}
234 318
235# @FUNCTION: linux_chkconfig_string 319# @FUNCTION: linux_chkconfig_string
236# @USAGE: option 320# @USAGE: option
237# @RETURN: CONFIG_<option> 321# @RETURN: CONFIG_<option>
238# @DESCRIPTION: 322# @DESCRIPTION:
239# 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.
240linux_chkconfig_string() { 326linux_chkconfig_string() {
241 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"
242 getfilevar "CONFIG_${1}" "${KV_OUT_DIR}/.config" 331 getfilevar_noexec "CONFIG_${1}" "${config}"
243} 332}
244 333
245# Versioning Functions 334# Versioning Functions
246# --------------------------------------- 335# ---------------------------------------
247 336
263 352
264# got the jist yet? 353# got the jist yet?
265 354
266kernel_is() { 355kernel_is() {
267 # if we haven't determined the version yet, we need to. 356 # if we haven't determined the version yet, we need to.
268 get_version 357 linux-info_get_any_version
358
269 local operator test value x=0 y=0 z=0 359 local operator test value x=0 y=0 z=0
270 360
271 case ${1} in 361 case ${1} in
272 lt) operator="-lt"; shift;; 362 -lt|lt) operator="-lt"; shift;;
273 gt) operator="-gt"; shift;; 363 -gt|gt) operator="-gt"; shift;;
274 le) operator="-le"; shift;; 364 -le|le) operator="-le"; shift;;
275 ge) operator="-ge"; shift;; 365 -ge|ge) operator="-ge"; shift;;
276 eq) operator="-eq"; shift;; 366 -eq|eq) operator="-eq"; shift;;
277 *) operator="-eq";; 367 *) operator="-eq";;
278 esac 368 esac
279 369
280 for x in ${@}; do 370 for x in ${@}; do
281 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
282 value="${value}${x}" 372 value="${value}${x}"
290 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;
291 test="${test}${KV_PATCH}";; 381 test="${test}${KV_PATCH}";;
292 *) die "Error in kernel-2_kernel_is(): Too many parameters.";; 382 *) die "Error in kernel-2_kernel_is(): Too many parameters.";;
293 esac 383 esac
294 done 384 done
295 385
296 [ ${test} ${operator} ${value} ] && return 0 || return 1 386 [ ${test} ${operator} ${value} ] && return 0 || return 1
297} 387}
298 388
299get_localversion() { 389get_localversion() {
300 local lv_list i x 390 local lv_list i x
309 done 399 done
310 x=${x/ /} 400 x=${x/ /}
311 echo ${x} 401 echo ${x}
312} 402}
313 403
404# internal variable, so we know to only print the warning once
405get_version_warning_done=
406
314# @FUNCTION: get_version 407# @FUNCTION: get_version
315# @DESCRIPTION: 408# @DESCRIPTION:
316# 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
317# (if KV_FULL is already set it does nothing). 410# (if KV_FULL is already set it does nothing).
318# 411#
331 # if we dont know KV_FULL, then we need too. 424 # if we dont know KV_FULL, then we need too.
332 # 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
333 unset KV_DIR 426 unset KV_DIR
334 427
335 # 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}" ] && \
336 qeinfo "Determining the location of the kernel source code" 430 qeinfo "Determining the location of the kernel source code"
337 [ -h "${KERNEL_DIR}" ] && KV_DIR="$(readlink -f ${KERNEL_DIR})" 431 [ -h "${KERNEL_DIR}" ] && KV_DIR="$(readlink -f ${KERNEL_DIR})"
338 [ -d "${KERNEL_DIR}" ] && KV_DIR="${KERNEL_DIR}" 432 [ -d "${KERNEL_DIR}" ] && KV_DIR="${KERNEL_DIR}"
339 433
340 if [ -z "${KV_DIR}" ] 434 if [ -z "${KV_DIR}" ]
341 then 435 then
436 if [ -z "${get_version_warning_done}" ]; then
437 get_version_warning_done=1
342 qeerror "Unable to find kernel sources at ${KERNEL_DIR}" 438 qeerror "Unable to find kernel sources at ${KERNEL_DIR}"
343 qeinfo "This package requires Linux sources." 439 #qeinfo "This package requires Linux sources."
344 if [ "${KERNEL_DIR}" == "/usr/src/linux" ] ; then 440 if [ "${KERNEL_DIR}" == "/usr/src/linux" ] ; then
345 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, "
346 qeinfo "(or the kernel you wish to build against)." 442 qeinfo "(or the kernel you wish to build against)."
347 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"
348 else 444 else
349 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
350 fi 447 fi
351 return 1 448 return 1
352 fi 449 fi
353 450
451 if [ -z "${get_version_warning_done}" ]; then
354 qeinfo "Found kernel source directory:" 452 qeinfo "Found kernel source directory:"
355 qeinfo " ${KV_DIR}" 453 qeinfo " ${KV_DIR}"
454 fi
356 455
357 if [ ! -s "${KV_DIR}/Makefile" ] 456 if [ ! -s "${KV_DIR}/Makefile" ]
358 then 457 then
458 if [ -z "${get_version_warning_done}" ]; then
459 get_version_warning_done=1
359 qeerror "Could not find a Makefile in the kernel source directory." 460 qeerror "Could not find a Makefile in the kernel source directory."
360 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
361 return 1 463 return 1
362 fi 464 fi
363 465
364 # 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
365 # KBUILD_OUTPUT, and we need this for .config and localversions-* 467 # KBUILD_OUTPUT, and we need this for .config and localversions-*
366 # so we better find it eh? 468 # so we better find it eh?
367 # do we pass KBUILD_OUTPUT on the CLI? 469 # do we pass KBUILD_OUTPUT on the CLI?
368 OUTPUT_DIR="${OUTPUT_DIR:-${KBUILD_OUTPUT}}" 470 OUTPUT_DIR="${OUTPUT_DIR:-${KBUILD_OUTPUT}}"
369 471
370 # 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
371 kbuild_output="$(getfilevar KBUILD_OUTPUT ${KV_DIR}/Makefile)" 473 kbuild_output="$(getfilevar_noexec KBUILD_OUTPUT ${KV_DIR}/Makefile)"
372 OUTPUT_DIR="${OUTPUT_DIR:-${kbuild_output}}" 474 OUTPUT_DIR="${OUTPUT_DIR:-${kbuild_output}}"
373 475
374 # 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
375 # directory name to find version information as this seems insane. 477 # directory name to find version information as this seems insane.
376 # so we parse ${KV_DIR}/Makefile 478 # so we parse ${KV_DIR}/Makefile
377 KV_MAJOR="$(getfilevar VERSION ${KV_DIR}/Makefile)" 479 KV_MAJOR="$(getfilevar_noexec VERSION ${KV_DIR}/Makefile)"
378 KV_MINOR="$(getfilevar PATCHLEVEL ${KV_DIR}/Makefile)" 480 KV_MINOR="$(getfilevar_noexec PATCHLEVEL ${KV_DIR}/Makefile)"
379 KV_PATCH="$(getfilevar SUBLEVEL ${KV_DIR}/Makefile)" 481 KV_PATCH="$(getfilevar_noexec SUBLEVEL ${KV_DIR}/Makefile)"
380 KV_EXTRA="$(getfilevar EXTRAVERSION ${KV_DIR}/Makefile)" 482 KV_EXTRA="$(getfilevar_noexec EXTRAVERSION ${KV_DIR}/Makefile)"
381 483
382 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}" ]
383 then 485 then
486 if [ -z "${get_version_warning_done}" ]; then
487 get_version_warning_done=1
384 qeerror "Could not detect kernel version." 488 qeerror "Could not detect kernel version."
385 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
386 return 1 491 return 1
387 fi 492 fi
388 493
389 # 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.
390 # 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.
404 fi 509 fi
405 # 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
406 KV_OUT_DIR="${KV_OUT_DIR:-${KV_DIR}}" 511 KV_OUT_DIR="${KV_OUT_DIR:-${KV_DIR}}"
407 512
408 KV_LOCAL="${KV_LOCAL}$(get_localversion ${KV_DIR})" 513 KV_LOCAL="${KV_LOCAL}$(get_localversion ${KV_DIR})"
409 if linux_config_exists; then 514 if linux_config_src_exists; then
410 KV_LOCAL="${KV_LOCAL}$(linux_chkconfig_string LOCALVERSION)" 515 KV_LOCAL="${KV_LOCAL}$(linux_chkconfig_string LOCALVERSION)"
411 KV_LOCAL="${KV_LOCAL//\"/}" 516 KV_LOCAL="${KV_LOCAL//\"/}"
412 517
413 # For things like git that can append extra stuff: 518 # For things like git that can append extra stuff:
414 [ -e ${KV_DIR}/scripts/setlocalversion ] && 519 [ -e ${KV_DIR}/scripts/setlocalversion ] &&
451 && KV_EXTRA="-${KV_FULL#*-}" 556 && KV_EXTRA="-${KV_FULL#*-}"
452 fi 557 fi
453 return 0 558 return 0
454} 559}
455 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
456 576
457# ebuild check functions 577# ebuild check functions
458# --------------------------------------- 578# ---------------------------------------
459 579
460# @FUNCTION: check_kernel_built 580# @FUNCTION: check_kernel_built
504check_extra_config() { 624check_extra_config() {
505 local config negate die error reworkmodulenames 625 local config negate die error reworkmodulenames
506 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
507 627
508 # if we haven't determined the version yet, we need to 628 # if we haven't determined the version yet, we need to
509 get_version 629 linux-info_get_any_version
510 630
511 # 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
512 # 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 "~".
513 for config in ${CONFIG_CHECK} 633 for config in ${CONFIG_CHECK}
514 do 634 do
521 if [[ ${config_required} == 0 ]]; then 641 if [[ ${config_required} == 0 ]]; then
522 # 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
523 # 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
524 # code later will cause a failure due to missing .config. 644 # code later will cause a failure due to missing .config.
525 if ! linux_config_exists; then 645 if ! linux_config_exists; then
646 ewarn "Unable to check for the following kernel config options due"
647 ewarn "to absence of any configured kernel sources or compiled"
648 ewarn "config:"
649 for config in ${CONFIG_CHECK}; do
650 ewarn " - ${config#\~}"
651 done
652 ewarn "You're on your own to make sure they are set if needed."
526 return 0 653 return 0
527 fi 654 fi
528 else 655 else
529 require_configured_kernel 656 [ -n "${I_KNOW_WHAT_I_AM_DOING}" ] && require_configured_kernel
530 fi 657 fi
531 658
532 einfo "Checking for suitable kernel configuration options..." 659 einfo "Checking for suitable kernel configuration options..."
533 660
534 for config in ${CONFIG_CHECK} 661 for config in ${CONFIG_CHECK}
535 do 662 do
536 # if we specify any fatal, ensure we honor them 663 # if we specify any fatal, ensure we honor them
537 die=1 664 die=1
538 error=0 665 error=0
636 local DEFLATE 763 local DEFLATE
637 764
638 einfo "Determining the usability of ZLIB_INFLATE support in your kernel" 765 einfo "Determining the usability of ZLIB_INFLATE support in your kernel"
639 766
640 ebegin "checking ZLIB_INFLATE" 767 ebegin "checking ZLIB_INFLATE"
641 getfilevar_isbuiltin CONFIG_ZLIB_INFLATE ${KV_DIR}/.config 768 linux_chkconfig_builtin CONFIG_ZLIB_INFLATE
642 eend $? 769 eend $?
643 [ "$?" != 0 ] && die 770 [ "$?" != 0 ] && die
644 771
645 ebegin "checking ZLIB_DEFLATE" 772 ebegin "checking ZLIB_DEFLATE"
646 getfilevar_isbuiltin CONFIG_ZLIB_DEFLATE ${KV_DIR}/.config 773 linux_chkconfig_builtin CONFIG_ZLIB_DEFLATE
647 eend $? 774 eend $?
648 [ "$?" != 0 ] && die 775 [ "$?" != 0 ] && die
649 776
650 local LINENO_START 777 local LINENO_START
651 local LINENO_END 778 local LINENO_END
694# @FUNCTION: linux-info_pkg_setup 821# @FUNCTION: linux-info_pkg_setup
695# @DESCRIPTION: 822# @DESCRIPTION:
696# 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
697# to support the options specified in CONFIG_CHECK (if not null) 824# to support the options specified in CONFIG_CHECK (if not null)
698linux-info_pkg_setup() { 825linux-info_pkg_setup() {
699 get_version || die "Unable to calculate Linux Kernel version" 826 linux-info_get_any_version
700 827
701 if kernel_is 2 4; then 828 if kernel_is 2 4; then
702 if [ "$( gcc-major-version )" -eq "4" ] ; then 829 if [ "$( gcc-major-version )" -eq "4" ] ; then
703 echo 830 echo
704 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.56  
changed lines
  Added in v.1.71

  ViewVC Help
Powered by ViewVC 1.1.20