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, 30 Aug 2009 17:28:11
Message-Id: E1Mht1H-0004vH-3o@stork.gentoo.org
1 robbat2 09/08/30 22:37:07
2
3 Modified: linux-info.eclass
4 Log:
5 Implement a variant of getfilevar that does not use Make to fetch the variable, and thusly does not fail out due to missing dependancies. Also fix totally broken checks in check_zlibinflate, that called a non-existing function.
6
7 Revision Changes Path
8 1.61 eclass/linux-info.eclass
9
10 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/linux-info.eclass?rev=1.61&view=markup
11 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/linux-info.eclass?rev=1.61&content-type=text/plain
12 diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/linux-info.eclass?r1=1.60&r2=1.61
13
14 Index: linux-info.eclass
15 ===================================================================
16 RCS file: /var/cvsroot/gentoo-x86/eclass/linux-info.eclass,v
17 retrieving revision 1.60
18 retrieving revision 1.61
19 diff -p -w -b -B -u -u -r1.60 -r1.61
20 --- linux-info.eclass 4 Jul 2009 18:39:33 -0000 1.60
21 +++ linux-info.eclass 30 Aug 2009 22:37:06 -0000 1.61
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.60 2009/07/04 18:39:33 robbat2 Exp $
26 +# $Header: /var/cvsroot/gentoo-x86/eclass/linux-info.eclass,v 1.61 2009/08/30 22:37:06 robbat2 Exp $
27 #
28 # Original author: John Mylchreest <johnm@g.o>
29 # Maintainer: kernel-misc@g.o
30 @@ -145,7 +145,9 @@ qeerror() { qout eerror "${@}" ; }
31 # @USAGE: variable configfile
32 # @RETURN: the value of the variable
33 # @DESCRIPTION:
34 -# It detects the value of the variable defined in the file configfile
35 +# It detects the value of the variable defined in the file configfile. This is
36 +# done by including the configfile, and printing the variable with Make.
37 +# It WILL break if your makefile has missing dependencies!
38 getfilevar() {
39 local ERROR basefname basedname myARCH="${ARCH}"
40 ERROR=0
41 @@ -170,6 +172,36 @@ local ERROR basefname basedname myARCH="
42 fi
43 }
44
45 +# @FUNCTION: getfilevar_noexec
46 +# @USAGE: variable configfile
47 +# @RETURN: the value of the variable
48 +# @DESCRIPTION:
49 +# It detects the value of the variable defined in the file configfile.
50 +# This is done with sed matching an expression only. If the variable is defined,
51 +# you will run into problems. See getfilevar for those cases.
52 +getfilevar_noexec() {
53 +local ERROR basefname basedname myARCH="${ARCH}"
54 + ERROR=0
55 +
56 + [ -z "${1}" ] && ERROR=1
57 + [ ! -f "${2}" ] && ERROR=1
58 +
59 + if [ "${ERROR}" = 1 ]
60 + then
61 + echo -e "\n"
62 + eerror "getfilevar_noexec requires 2 variables, with the second a valid file."
63 + eerror " getfilevar_noexec <VARIABLE> <CONFIGFILE>"
64 + else
65 + sed -n \
66 + -e "/^[[:space:]]*${1}[[:space:]]*=[[:space:]]*\(.*\)\$/{
67 + s,^[^=]*[[:space:]]*=[[:space:]]*,,g ;
68 + s,[[:space:]]*\$,,g ;
69 + p
70 + }" \
71 + "${2}"
72 + fi
73 +}
74 +
75
76 # @FUNCTION: linux_config_exists
77 # @RETURN: true or false
78 @@ -201,7 +233,7 @@ require_configured_kernel() {
79 linux_chkconfig_present() {
80 local RESULT
81 require_configured_kernel
82 - RESULT="$(getfilevar CONFIG_${1} ${KV_OUT_DIR}/.config)"
83 + RESULT="$(getfilevar_noexec CONFIG_${1} ${KV_OUT_DIR}/.config)"
84 [ "${RESULT}" = "m" -o "${RESULT}" = "y" ] && return 0 || return 1
85 }
86
87 @@ -213,7 +245,7 @@ local RESULT
88 linux_chkconfig_module() {
89 local RESULT
90 require_configured_kernel
91 - RESULT="$(getfilevar CONFIG_${1} ${KV_OUT_DIR}/.config)"
92 + RESULT="$(getfilevar_noexec CONFIG_${1} ${KV_OUT_DIR}/.config)"
93 [ "${RESULT}" = "m" ] && return 0 || return 1
94 }
95
96 @@ -225,7 +257,7 @@ local RESULT
97 linux_chkconfig_builtin() {
98 local RESULT
99 require_configured_kernel
100 - RESULT="$(getfilevar CONFIG_${1} ${KV_OUT_DIR}/.config)"
101 + RESULT="$(getfilevar_noexec CONFIG_${1} ${KV_OUT_DIR}/.config)"
102 [ "${RESULT}" = "y" ] && return 0 || return 1
103 }
104
105 @@ -236,7 +268,7 @@ local RESULT
106 # It prints the CONFIG_<option> value of the current kernel .config (it requires a configured kernel).
107 linux_chkconfig_string() {
108 require_configured_kernel
109 - getfilevar "CONFIG_${1}" "${KV_OUT_DIR}/.config"
110 + getfilevar_noexec "CONFIG_${1}" "${KV_OUT_DIR}/.config"
111 }
112
113 # Versioning Functions
114 @@ -365,16 +397,16 @@ get_version() {
115 OUTPUT_DIR="${OUTPUT_DIR:-${KBUILD_OUTPUT}}"
116
117 # And if we didn't pass it, we can take a nosey in the Makefile
118 - kbuild_output="$(getfilevar KBUILD_OUTPUT ${KV_DIR}/Makefile)"
119 + kbuild_output="$(getfilevar_noexec KBUILD_OUTPUT ${KV_DIR}/Makefile)"
120 OUTPUT_DIR="${OUTPUT_DIR:-${kbuild_output}}"
121
122 # And contrary to existing functions I feel we shouldn't trust the
123 # directory name to find version information as this seems insane.
124 # so we parse ${KV_DIR}/Makefile
125 - KV_MAJOR="$(getfilevar VERSION ${KV_DIR}/Makefile)"
126 - KV_MINOR="$(getfilevar PATCHLEVEL ${KV_DIR}/Makefile)"
127 - KV_PATCH="$(getfilevar SUBLEVEL ${KV_DIR}/Makefile)"
128 - KV_EXTRA="$(getfilevar EXTRAVERSION ${KV_DIR}/Makefile)"
129 + KV_MAJOR="$(getfilevar_noexec VERSION ${KV_DIR}/Makefile)"
130 + KV_MINOR="$(getfilevar_noexec PATCHLEVEL ${KV_DIR}/Makefile)"
131 + KV_PATCH="$(getfilevar_noexec SUBLEVEL ${KV_DIR}/Makefile)"
132 + KV_EXTRA="$(getfilevar_noexec EXTRAVERSION ${KV_DIR}/Makefile)"
133
134 if [ -z "${KV_MAJOR}" -o -z "${KV_MINOR}" -o -z "${KV_PATCH}" ]
135 then
136 @@ -641,12 +673,12 @@ check_zlibinflate() {
137 einfo "Determining the usability of ZLIB_INFLATE support in your kernel"
138
139 ebegin "checking ZLIB_INFLATE"
140 - getfilevar_isbuiltin CONFIG_ZLIB_INFLATE ${KV_DIR}/.config
141 + linux_chkconfig_builtin CONFIG_ZLIB_INFLATE
142 eend $?
143 [ "$?" != 0 ] && die
144
145 ebegin "checking ZLIB_DEFLATE"
146 - getfilevar_isbuiltin CONFIG_ZLIB_DEFLATE ${KV_DIR}/.config
147 + linux_chkconfig_builtin CONFIG_ZLIB_DEFLATE
148 eend $?
149 [ "$?" != 0 ] && die