/[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.91 Revision 1.96
1# Copyright 1999-2011 Gentoo Foundation 1# Copyright 1999-2013 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.91 2011/12/12 22:01:37 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/linux-info.eclass,v 1.96 2013/01/24 20:47:23 vapier Exp $
4 4
5# @ECLASS: linux-info.eclass 5# @ECLASS: linux-info.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# kernel-misc@gentoo.org 7# kernel-misc@gentoo.org
8# @AUTHOR: 8# @AUTHOR:
16# using additional eclasses. 16# using additional eclasses.
17# 17#
18# "kernel config" in this file means: 18# "kernel config" in this file means:
19# The .config of the currently installed sources is used as the first 19# The .config of the currently installed sources is used as the first
20# preference, with a fall-back to bundled config (/proc/config.gz) if available. 20# preference, with a fall-back to bundled config (/proc/config.gz) if available.
21#
22# Before using any of the config-handling functions in this eclass, you must
23# ensure that one of the following functions has been called (in order of
24# preference), otherwise you will get bugs like #364041):
25# linux-info_pkg_setup
26# linux-info_get_any_version
27# get_version
28# get_running_version
21 29
22# A Couple of env vars are available to effect usage of this eclass 30# A Couple of env vars are available to effect usage of this eclass
23# These are as follows: 31# These are as follows:
24 32
25# @ECLASS-VARIABLE: KERNEL_DIR 33# @ECLASS-VARIABLE: KERNEL_DIR
157# @DESCRIPTION: 165# @DESCRIPTION:
158# It detects the value of the variable defined in the file configfile. This is 166# It detects the value of the variable defined in the file configfile. This is
159# done by including the configfile, and printing the variable with Make. 167# done by including the configfile, and printing the variable with Make.
160# It WILL break if your makefile has missing dependencies! 168# It WILL break if your makefile has missing dependencies!
161getfilevar() { 169getfilevar() {
162local ERROR basefname basedname myARCH="${ARCH}" 170 local ERROR basefname basedname myARCH="${ARCH}"
163 ERROR=0 171 ERROR=0
164 172
165 [ -z "${1}" ] && ERROR=1 173 [ -z "${1}" ] && ERROR=1
166 [ ! -f "${2}" ] && ERROR=1 174 [ ! -f "${2}" ] && ERROR=1
167 175
188# @DESCRIPTION: 196# @DESCRIPTION:
189# It detects the value of the variable defined in the file configfile. 197# It detects the value of the variable defined in the file configfile.
190# This is done with sed matching an expression only. If the variable is defined, 198# This is done with sed matching an expression only. If the variable is defined,
191# you will run into problems. See getfilevar for those cases. 199# you will run into problems. See getfilevar for those cases.
192getfilevar_noexec() { 200getfilevar_noexec() {
193 local ERROR basefname basedname mycat myARCH="${ARCH}" 201 local ERROR basefname basedname mycat myARCH="${ARCH}"
194 ERROR=0 202 ERROR=0
195 mycat='cat' 203 mycat='cat'
196 204
197 [ -z "${1}" ] && ERROR=1 205 [ -z "${1}" ] && ERROR=1
198 [ ! -f "${2}" ] && ERROR=1 206 [ ! -f "${2}" ] && ERROR=1
281# 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
282# 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
283# MUST call linux_config_exists first. 291# MUST call linux_config_exists first.
284linux_chkconfig_present() { 292linux_chkconfig_present() {
285 linux_config_qa_check linux_chkconfig_present 293 linux_config_qa_check linux_chkconfig_present
286 local RESULT
287 local config 294 local RESULT config
288 config="${KV_OUT_DIR}/.config" 295 config="${KV_OUT_DIR}/.config"
289 [ ! -f "${config}" ] && config="/proc/config.gz" 296 [ ! -f "${config}" ] && config="/proc/config.gz"
290 RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")" 297 RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")"
291 [ "${RESULT}" = "m" -o "${RESULT}" = "y" ] && return 0 || return 1 298 [ "${RESULT}" = "m" -o "${RESULT}" = "y" ] && return 0 || return 1
292} 299}
298# It checks that CONFIG_<option>=m is present in the current kernel .config 305# It checks that CONFIG_<option>=m is present in the current kernel .config
299# If linux_config_exists returns false, the results of this are UNDEFINED. You 306# If linux_config_exists returns false, the results of this are UNDEFINED. You
300# MUST call linux_config_exists first. 307# MUST call linux_config_exists first.
301linux_chkconfig_module() { 308linux_chkconfig_module() {
302 linux_config_qa_check linux_chkconfig_module 309 linux_config_qa_check linux_chkconfig_module
303 local RESULT
304 local config 310 local RESULT config
305 config="${KV_OUT_DIR}/.config" 311 config="${KV_OUT_DIR}/.config"
306 [ ! -f "${config}" ] && config="/proc/config.gz" 312 [ ! -f "${config}" ] && config="/proc/config.gz"
307 RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")" 313 RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")"
308 [ "${RESULT}" = "m" ] && return 0 || return 1 314 [ "${RESULT}" = "m" ] && return 0 || return 1
309} 315}
315# It checks that CONFIG_<option>=y is present in the current kernel .config 321# It checks that CONFIG_<option>=y is present in the current kernel .config
316# If linux_config_exists returns false, the results of this are UNDEFINED. You 322# If linux_config_exists returns false, the results of this are UNDEFINED. You
317# MUST call linux_config_exists first. 323# MUST call linux_config_exists first.
318linux_chkconfig_builtin() { 324linux_chkconfig_builtin() {
319 linux_config_qa_check linux_chkconfig_builtin 325 linux_config_qa_check linux_chkconfig_builtin
320 local RESULT
321 local config 326 local RESULT config
322 config="${KV_OUT_DIR}/.config" 327 config="${KV_OUT_DIR}/.config"
323 [ ! -f "${config}" ] && config="/proc/config.gz" 328 [ ! -f "${config}" ] && config="/proc/config.gz"
324 RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")" 329 RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")"
325 [ "${RESULT}" = "y" ] && return 0 || return 1 330 [ "${RESULT}" = "y" ] && return 0 || return 1
326} 331}
579 KERNEL_DIR=$(readlink -f ${ROOT}/lib/modules/${KV_FULL}/build) 584 KERNEL_DIR=$(readlink -f ${ROOT}/lib/modules/${KV_FULL}/build)
580 unset KV_FULL 585 unset KV_FULL
581 get_version 586 get_version
582 return $? 587 return $?
583 else 588 else
589 # This handles a variety of weird kernel versions. Make sure to update
590 # tests/linux-info:get_running_version.sh if you want to change this.
591 local kv_full=${KV_FULL//[-+_]*}
584 KV_MAJOR=$(get_version_component_range 1 ${KV_FULL}) 592 KV_MAJOR=$(get_version_component_range 1 ${kv_full})
585 KV_MINOR=$(get_version_component_range 2 ${KV_FULL}) 593 KV_MINOR=$(get_version_component_range 2 ${kv_full})
586 KV_PATCH=$(get_version_component_range 3 ${KV_FULL}) 594 KV_PATCH=$(get_version_component_range 3 ${kv_full})
587 KV_PATCH=${KV_PATCH//-*}
588 KV_EXTRA="${KV_FULL#${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}}" 595 KV_EXTRA="${KV_FULL#${KV_MAJOR}.${KV_MINOR}${KV_PATCH:+.${KV_PATCH}}}"
596 : ${KV_PATCH:=0}
589 fi 597 fi
590 return 0 598 return 0
591} 599}
592 600
593# This next function is named with the eclass prefix to avoid conflicts with 601# This next function is named with the eclass prefix to avoid conflicts with
615check_kernel_built() { 623check_kernel_built() {
616 # if we haven't determined the version yet, we need to 624 # if we haven't determined the version yet, we need to
617 require_configured_kernel 625 require_configured_kernel
618 get_version 626 get_version
619 627
628 local versionh_path
629 if kernel_is -ge 3 7; then
630 versionh_path="include/generated/uapi/linux/version.h"
631 else
632 versionh_path="include/linux/version.h"
633 fi
634
620 if [ ! -f "${KV_OUT_DIR}/include/linux/version.h" ] 635 if [ ! -f "${KV_OUT_DIR}/${versionh_path}" ]
621 then 636 then
622 eerror "These sources have not yet been prepared." 637 eerror "These sources have not yet been prepared."
623 eerror "We cannot build against an unprepared tree." 638 eerror "We cannot build against an unprepared tree."
624 eerror "To resolve this, please type the following:" 639 eerror "To resolve this, please type the following:"
625 eerror 640 eerror
638check_modules_supported() { 653check_modules_supported() {
639 # if we haven't determined the version yet, we need too. 654 # if we haven't determined the version yet, we need too.
640 require_configured_kernel 655 require_configured_kernel
641 get_version 656 get_version
642 657
643 if ! linux_chkconfig_builtin "MODULES" 658 if ! linux_chkconfig_builtin "MODULES"; then
644 then
645 eerror "These sources do not support loading external modules." 659 eerror "These sources do not support loading external modules."
646 eerror "to be able to use this module please enable \"Loadable modules support\"" 660 eerror "to be able to use this module please enable \"Loadable modules support\""
647 eerror "in your kernel, recompile and then try merging this module again." 661 eerror "in your kernel, recompile and then try merging this module again."
648 die "No support for external modules in ${KV_FULL} config" 662 die "No support for external modules in ${KV_FULL} config"
649 fi 663 fi
652# @FUNCTION: check_extra_config 666# @FUNCTION: check_extra_config
653# @DESCRIPTION: 667# @DESCRIPTION:
654# It checks the kernel config options specified by CONFIG_CHECK. It dies only when a required config option (i.e. 668# It checks the kernel config options specified by CONFIG_CHECK. It dies only when a required config option (i.e.
655# the prefix ~ is not used) doesn't satisfy the directive. 669# the prefix ~ is not used) doesn't satisfy the directive.
656check_extra_config() { 670check_extra_config() {
657 local config negate die error reworkmodulenames 671 local config negate die error reworkmodulenames
658 local soft_errors_count=0 hard_errors_count=0 config_required=0 672 local soft_errors_count=0 hard_errors_count=0 config_required=0
659 # store the value of the QA check, because otherwise we won't catch usages 673 # store the value of the QA check, because otherwise we won't catch usages
660 # after if check_extra_config is called AND other direct calls are done 674 # after if check_extra_config is called AND other direct calls are done
661 # later. 675 # later.
662 local old_LINUX_CONFIG_EXISTS_DONE="${_LINUX_CONFIG_EXISTS_DONE}" 676 local old_LINUX_CONFIG_EXISTS_DONE="${_LINUX_CONFIG_EXISTS_DONE}"
663 677
664 # if we haven't determined the version yet, we need to 678 # if we haven't determined the version yet, we need to
665 linux-info_get_any_version 679 linux-info_get_any_version
666 680
667 # Determine if we really need a .config. The only time when we don't need 681 # Determine if we really need a .config. The only time when we don't need
668 # one is when all of the CONFIG_CHECK options are prefixed with "~". 682 # one is when all of the CONFIG_CHECK options are prefixed with "~".
669 for config in ${CONFIG_CHECK} 683 for config in ${CONFIG_CHECK}; do
670 do
671 if [[ "${config:0:1}" != "~" ]]; then 684 if [[ "${config:0:1}" != "~" ]]; then
672 config_required=1 685 config_required=1
673 break 686 break
674 fi 687 fi
675 done 688 done

Legend:
Removed from v.1.91  
changed lines
  Added in v.1.96

  ViewVC Help
Powered by ViewVC 1.1.20