/[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.71 Revision 1.76
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.71 2009/09/08 12:34:21 robbat2 Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/linux-info.eclass,v 1.76 2009/12/11 21:33:30 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 :)
221 p 221 p
222 }" 222 }"
223 fi 223 fi
224} 224}
225 225
226# @PRIVATE-VARIABLE: _LINUX_CONFIG_EXISTS_DONE
227# @DESCRIPTION:
228# This is only set if one of the linux_config_*exists functions has been called.
229# We use it for a QA warning that the check for a config has not been performed,
230# as linux_chkconfig* in non-legacy mode WILL return an undefined value if no
231# config is available at all.
232_LINUX_CONFIG_EXISTS_DONE=
233
234linux_config_qa_check() {
235 local f="$1"
236 if [ -z "${_LINUX_CONFIG_EXISTS_DONE}" ]; then
237 ewarn "QA: You called $f before any linux_config_exists!"
238 ewarn "QA: The return value of $f will NOT gaurenteed later!"
239 fi
240}
226 241
227# @FUNCTION: linux_config_src_exists 242# @FUNCTION: linux_config_src_exists
228# @RETURN: true or false 243# @RETURN: true or false
229# @DESCRIPTION: 244# @DESCRIPTION:
230# It returns true if .config exists in a build directory otherwise false 245# It returns true if .config exists in a build directory otherwise false
231linux_config_src_exists() { 246linux_config_src_exists() {
247 export _LINUX_CONFIG_EXISTS_DONE=1
232 [ -s "${KV_OUT_DIR}/.config" ] 248 [ -s "${KV_OUT_DIR}/.config" ]
233} 249}
234 250
235# @FUNCTION: linux_config_bin_exists 251# @FUNCTION: linux_config_bin_exists
236# @RETURN: true or false 252# @RETURN: true or false
237# @DESCRIPTION: 253# @DESCRIPTION:
238# It returns true if .config exists in /proc, otherwise false 254# It returns true if .config exists in /proc, otherwise false
239linux_config_bin_exists() { 255linux_config_bin_exists() {
240 [ -s "/proc/config.gz" ] 256 export _LINUX_CONFIG_EXISTS_DONE=1
257 [ -n "${I_KNOW_WHAT_I_AM_DOING}" -a -s "/proc/config.gz" ]
241} 258}
242 259
243# @FUNCTION: linux_config_exists 260# @FUNCTION: linux_config_exists
244# @RETURN: true or false 261# @RETURN: true or false
245# @DESCRIPTION: 262# @DESCRIPTION:
271# @DESCRIPTION: 288# @DESCRIPTION:
272# It checks that CONFIG_<option>=y or CONFIG_<option>=m is present in the current kernel .config 289# 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 290# If linux_config_exists returns false, the results of this are UNDEFINED. You
274# MUST call linux_config_exists first. 291# MUST call linux_config_exists first.
275linux_chkconfig_present() { 292linux_chkconfig_present() {
293 linux_config_qa_check linux_chkconfig_present
276local RESULT 294 local RESULT
277 [ -z "${I_KNOW_WHAT_I_AM_DOING}" ] && require_configured_kernel 295 [ -z "${I_KNOW_WHAT_I_AM_DOING}" ] && require_configured_kernel
278 local config 296 local config
279 config="${KV_OUT_DIR}/.config" 297 config="${KV_OUT_DIR}/.config"
280 [ ! -f "${config}" ] && config="/proc/config.gz" 298 [ ! -f "${config}" ] && config="/proc/config.gz"
281 RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")" 299 RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")"
288# @DESCRIPTION: 306# @DESCRIPTION:
289# It checks that CONFIG_<option>=m is present in the current kernel .config 307# 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 308# If linux_config_exists returns false, the results of this are UNDEFINED. You
291# MUST call linux_config_exists first. 309# MUST call linux_config_exists first.
292linux_chkconfig_module() { 310linux_chkconfig_module() {
311 linux_config_qa_check linux_chkconfig_module
293local RESULT 312 local RESULT
294 [ -z "${I_KNOW_WHAT_I_AM_DOING}" ] && require_configured_kernel 313 [ -z "${I_KNOW_WHAT_I_AM_DOING}" ] && require_configured_kernel
295 local config 314 local config
296 config="${KV_OUT_DIR}/.config" 315 config="${KV_OUT_DIR}/.config"
297 [ ! -f "${config}" ] && config="/proc/config.gz" 316 [ ! -f "${config}" ] && config="/proc/config.gz"
298 RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")" 317 RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")"
305# @DESCRIPTION: 324# @DESCRIPTION:
306# It checks that CONFIG_<option>=y is present in the current kernel .config 325# 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 326# If linux_config_exists returns false, the results of this are UNDEFINED. You
308# MUST call linux_config_exists first. 327# MUST call linux_config_exists first.
309linux_chkconfig_builtin() { 328linux_chkconfig_builtin() {
329 linux_config_qa_check linux_chkconfig_builtin
310local RESULT 330 local RESULT
311 [ -z "${I_KNOW_WHAT_I_AM_DOING}" ] && require_configured_kernel 331 [ -z "${I_KNOW_WHAT_I_AM_DOING}" ] && require_configured_kernel
312 local config 332 local config
313 config="${KV_OUT_DIR}/.config" 333 config="${KV_OUT_DIR}/.config"
314 [ ! -f "${config}" ] && config="/proc/config.gz" 334 [ ! -f "${config}" ] && config="/proc/config.gz"
315 RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")" 335 RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")"
322# @DESCRIPTION: 342# @DESCRIPTION:
323# It prints the CONFIG_<option> value of the current kernel .config (it requires a configured kernel). 343# 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 344# If linux_config_exists returns false, the results of this are UNDEFINED. You
325# MUST call linux_config_exists first. 345# MUST call linux_config_exists first.
326linux_chkconfig_string() { 346linux_chkconfig_string() {
347 linux_config_qa_check linux_chkconfig_string
327 [ -z "${I_KNOW_WHAT_I_AM_DOING}" ] && require_configured_kernel 348 [ -z "${I_KNOW_WHAT_I_AM_DOING}" ] && require_configured_kernel
328 local config 349 local config
329 config="${KV_OUT_DIR}/.config" 350 config="${KV_OUT_DIR}/.config"
330 [ ! -f "${config}" ] && config="/proc/config.gz" 351 [ ! -f "${config}" ] && config="/proc/config.gz"
331 getfilevar_noexec "CONFIG_${1}" "${config}" 352 getfilevar_noexec "CONFIG_${1}" "${config}"
380 3) for((y=0; y<$((3 - ${#KV_PATCH})); y++)); do test="${test}0"; done; 401 3) for((y=0; y<$((3 - ${#KV_PATCH})); y++)); do test="${test}0"; done;
381 test="${test}${KV_PATCH}";; 402 test="${test}${KV_PATCH}";;
382 *) die "Error in kernel-2_kernel_is(): Too many parameters.";; 403 *) die "Error in kernel-2_kernel_is(): Too many parameters.";;
383 esac 404 esac
384 done 405 done
385 406
386 [ ${test} ${operator} ${value} ] && return 0 || return 1 407 [ ${test} ${operator} ${value} ] && return 0 || return 1
387} 408}
388 409
389get_localversion() { 410get_localversion() {
390 local lv_list i x 411 local lv_list i x
564# @FUNCTION: linux-info_get_any_version 585# @FUNCTION: linux-info_get_any_version
565# @DESCRIPTION: 586# @DESCRIPTION:
566# This attempts to find the version of the sources, and otherwise falls back to 587# This attempts to find the version of the sources, and otherwise falls back to
567# the version of the running kernel. 588# the version of the running kernel.
568linux-info_get_any_version() { 589linux-info_get_any_version() {
569 get_version 590 get_version
570 if [[ $? -ne 0 ]]; then 591 if [[ $? -ne 0 ]]; then
571 ewarn "Unable to calculate Linux Kernel version for build, attempting to use running version" 592 ewarn "Unable to calculate Linux Kernel version for build, attempting to use running version"
572 get_running_version 593 get_running_version
573 fi 594 fi
574} 595}
575 596
576 597
577# ebuild check functions 598# ebuild check functions
622# It checks the kernel config options specified by CONFIG_CHECK. It dies only when a required config option (i.e. 643# It checks the kernel config options specified by CONFIG_CHECK. It dies only when a required config option (i.e.
623# the prefix ~ is not used) doesn't satisfy the directive. 644# the prefix ~ is not used) doesn't satisfy the directive.
624check_extra_config() { 645check_extra_config() {
625 local config negate die error reworkmodulenames 646 local config negate die error reworkmodulenames
626 local soft_errors_count=0 hard_errors_count=0 config_required=0 647 local soft_errors_count=0 hard_errors_count=0 config_required=0
648 # store the value of the QA check, because otherwise we won't catch usages
649 # after if check_extra_config is called AND other direct calls are done
650 # later.
651 local old_LINUX_CONFIG_EXISTS_DONE="${_LINUX_CONFIG_EXISTS_DONE}"
627 652
628 # if we haven't determined the version yet, we need to 653 # if we haven't determined the version yet, we need to
629 linux-info_get_any_version 654 linux-info_get_any_version
630 655
631 # Determine if we really need a .config. The only time when we don't need 656 # Determine if we really need a .config. The only time when we don't need
636 config_required=1 661 config_required=1
637 break 662 break
638 fi 663 fi
639 done 664 done
640 665
666 # TODO: After we enable the new code for /proc/config.gz, we need to
667 # change this back to linux_config_exists.
641 if [[ ${config_required} == 0 ]]; then 668 if [[ ${config_required} == 0 ]]; then
642 # In the case where we don't require a .config, we can now bail out 669 # In the case where we don't require a .config, we can now bail out
643 # if the user has no .config as there is nothing to do. Otherwise 670 # if the user has no .config as there is nothing to do. Otherwise
644 # code later will cause a failure due to missing .config. 671 # code later will cause a failure due to missing .config.
645 if ! linux_config_exists; then 672 if ! linux_config_src_exists; then
646 ewarn "Unable to check for the following kernel config options due" 673 ewarn "Unable to check for the following kernel config options due"
647 ewarn "to absence of any configured kernel sources or compiled" 674 ewarn "to absence of any configured kernel sources or compiled"
648 ewarn "config:" 675 ewarn "config:"
649 for config in ${CONFIG_CHECK}; do 676 for config in ${CONFIG_CHECK}; do
650 ewarn " - ${config#\~}" 677 ewarn " - ${config#\~}"
651 done 678 done
652 ewarn "You're on your own to make sure they are set if needed." 679 ewarn "You're on your own to make sure they are set if needed."
680 export LINUX_CONFIG_EXISTS_DONE="${old_LINUX_CONFIG_EXISTS_DONE}"
653 return 0 681 return 0
654 fi 682 fi
655 else 683 else
656 [ -n "${I_KNOW_WHAT_I_AM_DOING}" ] && require_configured_kernel 684 [ -n "${I_KNOW_WHAT_I_AM_DOING}" ] && require_configured_kernel
657 fi 685 fi
734 if [[ ${hard_errors_count} > 0 ]]; then 762 if [[ ${hard_errors_count} > 0 ]]; then
735 eerror "Please check to make sure these options are set correctly." 763 eerror "Please check to make sure these options are set correctly."
736 eerror "Failure to do so may cause unexpected problems." 764 eerror "Failure to do so may cause unexpected problems."
737 eerror "Once you have satisfied these options, please try merging" 765 eerror "Once you have satisfied these options, please try merging"
738 eerror "this package again." 766 eerror "this package again."
767 export LINUX_CONFIG_EXISTS_DONE="${old_LINUX_CONFIG_EXISTS_DONE}"
739 die "Incorrect kernel configuration options" 768 die "Incorrect kernel configuration options"
740 elif [[ ${soft_errors_count} > 0 ]]; then 769 elif [[ ${soft_errors_count} > 0 ]]; then
741 ewarn "Please check to make sure these options are set correctly." 770 ewarn "Please check to make sure these options are set correctly."
742 ewarn "Failure to do so may cause unexpected problems." 771 ewarn "Failure to do so may cause unexpected problems."
743 else 772 else
744 eend 0 773 eend 0
745 fi 774 fi
775 export LINUX_CONFIG_EXISTS_DONE="${old_LINUX_CONFIG_EXISTS_DONE}"
746} 776}
747 777
748check_zlibinflate() { 778check_zlibinflate() {
749 # if we haven't determined the version yet, we need to 779 # if we haven't determined the version yet, we need to
750 require_configured_kernel 780 require_configured_kernel

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

  ViewVC Help
Powered by ViewVC 1.1.20