Gentoo Archives: gentoo-commits

From: "Robin H. Johnson (robbat2)" <robbat2@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in eclass: linux-info.eclass
Date: Sun, 06 Sep 2009 22:55:00
Message-Id: E1MkQdO-0003Ez-SE@stork.gentoo.org
1 robbat2 09/09/06 22:54:58
2
3 Modified: linux-info.eclass
4 Log:
5 Bug #283320: Part of the migration work to make linux-info non-fatal. Currently gets enabled with I_KNOW_WHAT_I_AM_DOING in the env for the .config reading. Also uses the currently running version if no sources at all available.
6
7 Revision Changes Path
8 1.62 eclass/linux-info.eclass
9
10 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/linux-info.eclass?rev=1.62&view=markup
11 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/linux-info.eclass?rev=1.62&content-type=text/plain
12 diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/linux-info.eclass?r1=1.61&r2=1.62
13
14 Index: linux-info.eclass
15 ===================================================================
16 RCS file: /var/cvsroot/gentoo-x86/eclass/linux-info.eclass,v
17 retrieving revision 1.61
18 retrieving revision 1.62
19 diff -p -w -b -B -u -u -r1.61 -r1.62
20 --- linux-info.eclass 30 Aug 2009 22:37:06 -0000 1.61
21 +++ linux-info.eclass 6 Sep 2009 22:54:58 -0000 1.62
22 @@ -1,6 +1,6 @@
23 # Copyright 1999-2006 Gentoo Foundation
24 # Distributed under the terms of the GNU General Public License v2
25 -# $Header: /var/cvsroot/gentoo-x86/eclass/linux-info.eclass,v 1.61 2009/08/30 22:37:06 robbat2 Exp $
26 +# $Header: /var/cvsroot/gentoo-x86/eclass/linux-info.eclass,v 1.62 2009/09/06 22:54:58 robbat2 Exp $
27 #
28 # Original author: John Mylchreest <johnm@g.o>
29 # Maintainer: kernel-misc@g.o
30 @@ -13,10 +13,14 @@
31 # @BLURB: eclass used for accessing kernel related information
32 # @DESCRIPTION:
33 # This eclass is used as a central eclass for accessing kernel
34 -# related information for sources already installed.
35 +# related information for source or binary already installed.
36 # It is vital for linux-mod.eclass to function correctly, and is split
37 # out so that any ebuild behaviour "templates" are abstracted out
38 # using additional eclasses.
39 +#
40 +# "kernel config" in this file means:
41 +# The .config of the currently installed sources is used as the first
42 +# preference, with a fall-back to bundled config (/proc/config.gz) if available.
43
44 # A Couple of env vars are available to effect usage of this eclass
45 # These are as follows:
46 @@ -39,6 +43,14 @@
47 # e.g.: CONFIG_CHECK="!MTRR"
48 #
49 # To simply warn about a missing option, prepend a '~'.
50 +# It may be combined with '!'.
51 +#
52 +# In general, most checks should be non-fatal. The only time fatal checks should
53 +# be used is for building kernel modules or cases that a compile will fail
54 +# without the option.
55 +#
56 +# This is to allow usage of binary kernels, and minimal systems without kernel
57 +# sources.
58
59 # @ECLASS-VARIABLE: ERROR_<CFG>
60 # @DESCRIPTION:
61 @@ -89,6 +101,10 @@
62 # A read-only variable. It's a string containing the kernel object directory, will be KV_DIR unless
63 # KBUILD_OUTPUT is used. This should be used for referencing .config.
64
65 +# @ECLASS-VARIABLE: I_KNOW_WHAT_I_AM_DOING
66 +# @DESCRIPTION:
67 +# Temporary variable for the migration to making linux-info non-fatal.
68 +
69 # And to ensure all the weirdness with crosscompile
70 inherit toolchain-funcs versionator
71
72 @@ -180,11 +196,13 @@ local ERROR basefname basedname myARCH="
73 # This is done with sed matching an expression only. If the variable is defined,
74 # you will run into problems. See getfilevar for those cases.
75 getfilevar_noexec() {
76 -local ERROR basefname basedname myARCH="${ARCH}"
77 + local ERROR basefname basedname mycat myARCH="${ARCH}"
78 ERROR=0
79 + mycat='cat'
80
81 [ -z "${1}" ] && ERROR=1
82 [ ! -f "${2}" ] && ERROR=1
83 + [ "${2#.gz}" != "${2}" ] && mycat='zcat'
84
85 if [ "${ERROR}" = 1 ]
86 then
87 @@ -192,23 +210,42 @@ local ERROR basefname basedname myARCH="
88 eerror "getfilevar_noexec requires 2 variables, with the second a valid file."
89 eerror " getfilevar_noexec <VARIABLE> <CONFIGFILE>"
90 else
91 + ${mycat} "${2}" | \
92 sed -n \
93 -e "/^[[:space:]]*${1}[[:space:]]*=[[:space:]]*\(.*\)\$/{
94 s,^[^=]*[[:space:]]*=[[:space:]]*,,g ;
95 s,[[:space:]]*\$,,g ;
96 p
97 - }" \
98 - "${2}"
99 + }"
100 fi
101 }
102
103
104 +# @FUNCTION: linux_config_src_exists
105 +# @RETURN: true or false
106 +# @DESCRIPTION:
107 +# It returns true if .config exists in a build directory otherwise false
108 +linux_config_src_exists() {
109 + [ -s "${KV_OUT_DIR}/.config" ]
110 +}
111 +
112 +# @FUNCTION: linux_config_bin_exists
113 +# @RETURN: true or false
114 +# @DESCRIPTION:
115 +# It returns true if .config exists in /proc, otherwise false
116 +linux_config_bin_exists() {
117 + [ -s "/proc/config.gz" ]
118 +}
119 +
120 # @FUNCTION: linux_config_exists
121 # @RETURN: true or false
122 # @DESCRIPTION:
123 # It returns true if .config exists otherwise false
124 +#
125 +# This function MUST be checked before using any of the linux_chkconfig_*
126 +# functions.
127 linux_config_exists() {
128 - [ -s "${KV_OUT_DIR}/.config" ]
129 + linux_config_src_exists || linux_config_bin_exists
130 }
131
132 # @FUNCTION: require_configured_kernel
133 @@ -216,7 +253,7 @@ linux_config_exists() {
134 # This function verifies that the current kernel is configured (it checks against the existence of .config)
135 # otherwise it dies.
136 require_configured_kernel() {
137 - if ! linux_config_exists; then
138 + if ! linux_config_src_exists; then
139 qeerror "Could not find a usable .config in the kernel source directory."
140 qeerror "Please ensure that ${KERNEL_DIR} points to a configured set of Linux sources."
141 qeerror "If you are using KBUILD_OUTPUT, please set the environment var so that"
142 @@ -230,10 +267,15 @@ require_configured_kernel() {
143 # @RETURN: true or false
144 # @DESCRIPTION:
145 # It checks that CONFIG_<option>=y or CONFIG_<option>=m is present in the current kernel .config
146 +# If linux_config_exists returns false, the results of this are UNDEFINED. You
147 +# MUST call linux_config_exists first.
148 linux_chkconfig_present() {
149 local RESULT
150 - require_configured_kernel
151 - RESULT="$(getfilevar_noexec CONFIG_${1} ${KV_OUT_DIR}/.config)"
152 + [ -z "${I_KNOW_WHAT_I_AM_DOING}" ] && require_configured_kernel
153 + local config
154 + config="${KV_OUT_DIR}/.config"
155 + [ ! -f "${config}" ] && config="/proc/config.gz"
156 + RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")"
157 [ "${RESULT}" = "m" -o "${RESULT}" = "y" ] && return 0 || return 1
158 }
159
160 @@ -242,10 +284,15 @@ local RESULT
161 # @RETURN: true or false
162 # @DESCRIPTION:
163 # It checks that CONFIG_<option>=m is present in the current kernel .config
164 +# If linux_config_exists returns false, the results of this are UNDEFINED. You
165 +# MUST call linux_config_exists first.
166 linux_chkconfig_module() {
167 local RESULT
168 - require_configured_kernel
169 - RESULT="$(getfilevar_noexec CONFIG_${1} ${KV_OUT_DIR}/.config)"
170 + [ -z "${I_KNOW_WHAT_I_AM_DOING}" ] && require_configured_kernel
171 + local config
172 + config="${KV_OUT_DIR}/.config"
173 + [ ! -f "${config}" ] && config="/proc/config.gz"
174 + RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")"
175 [ "${RESULT}" = "m" ] && return 0 || return 1
176 }
177
178 @@ -254,10 +301,15 @@ local RESULT
179 # @RETURN: true or false
180 # @DESCRIPTION:
181 # It checks that CONFIG_<option>=y is present in the current kernel .config
182 +# If linux_config_exists returns false, the results of this are UNDEFINED. You
183 +# MUST call linux_config_exists first.
184 linux_chkconfig_builtin() {
185 local RESULT
186 - require_configured_kernel
187 - RESULT="$(getfilevar_noexec CONFIG_${1} ${KV_OUT_DIR}/.config)"
188 + [ -z "${I_KNOW_WHAT_I_AM_DOING}" ] && require_configured_kernel
189 + local config
190 + config="${KV_OUT_DIR}/.config"
191 + [ ! -f "${config}" ] && config="/proc/config.gz"
192 + RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")"
193 [ "${RESULT}" = "y" ] && return 0 || return 1
194 }
195
196 @@ -266,9 +318,14 @@ local RESULT
197 # @RETURN: CONFIG_<option>
198 # @DESCRIPTION:
199 # It prints the CONFIG_<option> value of the current kernel .config (it requires a configured kernel).
200 +# If linux_config_exists returns false, the results of this are UNDEFINED. You
201 +# MUST call linux_config_exists first.
202 linux_chkconfig_string() {
203 - require_configured_kernel
204 - getfilevar_noexec "CONFIG_${1}" "${KV_OUT_DIR}/.config"
205 + [ -z "${I_KNOW_WHAT_I_AM_DOING}" ] && require_configured_kernel
206 + local config
207 + config="${KV_OUT_DIR}/.config"
208 + [ ! -f "${config}" ] && config="/proc/config.gz"
209 + getfilevar_noexec "CONFIG_${1}" "${config}"
210 }
211
212 # Versioning Functions
213 @@ -731,7 +788,11 @@ check_zlibinflate() {
214 # Force a get_version() call when inherited from linux-mod.eclass and then check if the kernel is configured
215 # to support the options specified in CONFIG_CHECK (if not null)
216 linux-info_pkg_setup() {
217 - get_version || die "Unable to calculate Linux Kernel version"
218 + get_version
219 + if [[ $rc -ne 0 ]]; then
220 + ewarn "Unable to calculate Linux Kernel version for build, attempting to use running version"
221 + get_running_version
222 + fi
223
224 if kernel_is 2 4; then
225 if [ "$( gcc-major-version )" -eq "4" ] ; then