/[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.60 Revision 1.61
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.60 2009/07/04 18:39:33 robbat2 Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/linux-info.eclass,v 1.61 2009/08/30 22:37:06 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 :)
143 143
144# @FUNCTION: getfilevar 144# @FUNCTION: getfilevar
145# @USAGE: variable configfile 145# @USAGE: variable configfile
146# @RETURN: the value of the variable 146# @RETURN: the value of the variable
147# @DESCRIPTION: 147# @DESCRIPTION:
148# It detects the value of the variable defined in the file configfile 148# It detects the value of the variable defined in the file configfile. This is
149# done by including the configfile, and printing the variable with Make.
150# It WILL break if your makefile has missing dependencies!
149getfilevar() { 151getfilevar() {
150local ERROR basefname basedname myARCH="${ARCH}" 152local ERROR basefname basedname myARCH="${ARCH}"
151 ERROR=0 153 ERROR=0
152 154
153 [ -z "${1}" ] && ERROR=1 155 [ -z "${1}" ] && ERROR=1
168 170
169 ARCH=${myARCH} 171 ARCH=${myARCH}
170 fi 172 fi
171} 173}
172 174
175# @FUNCTION: getfilevar_noexec
176# @USAGE: variable configfile
177# @RETURN: the value of the variable
178# @DESCRIPTION:
179# It detects the value of the variable defined in the file configfile.
180# This is done with sed matching an expression only. If the variable is defined,
181# you will run into problems. See getfilevar for those cases.
182getfilevar_noexec() {
183local ERROR basefname basedname myARCH="${ARCH}"
184 ERROR=0
185
186 [ -z "${1}" ] && ERROR=1
187 [ ! -f "${2}" ] && ERROR=1
188
189 if [ "${ERROR}" = 1 ]
190 then
191 echo -e "\n"
192 eerror "getfilevar_noexec requires 2 variables, with the second a valid file."
193 eerror " getfilevar_noexec <VARIABLE> <CONFIGFILE>"
194 else
195 sed -n \
196 -e "/^[[:space:]]*${1}[[:space:]]*=[[:space:]]*\(.*\)\$/{
197 s,^[^=]*[[:space:]]*=[[:space:]]*,,g ;
198 s,[[:space:]]*\$,,g ;
199 p
200 }" \
201 "${2}"
202 fi
203}
204
173 205
174# @FUNCTION: linux_config_exists 206# @FUNCTION: linux_config_exists
175# @RETURN: true or false 207# @RETURN: true or false
176# @DESCRIPTION: 208# @DESCRIPTION:
177# It returns true if .config exists otherwise false 209# It returns true if .config exists otherwise false
199# @DESCRIPTION: 231# @DESCRIPTION:
200# It checks that CONFIG_<option>=y or CONFIG_<option>=m is present in the current kernel .config 232# It checks that CONFIG_<option>=y or CONFIG_<option>=m is present in the current kernel .config
201linux_chkconfig_present() { 233linux_chkconfig_present() {
202local RESULT 234local RESULT
203 require_configured_kernel 235 require_configured_kernel
204 RESULT="$(getfilevar CONFIG_${1} ${KV_OUT_DIR}/.config)" 236 RESULT="$(getfilevar_noexec CONFIG_${1} ${KV_OUT_DIR}/.config)"
205 [ "${RESULT}" = "m" -o "${RESULT}" = "y" ] && return 0 || return 1 237 [ "${RESULT}" = "m" -o "${RESULT}" = "y" ] && return 0 || return 1
206} 238}
207 239
208# @FUNCTION: linux_chkconfig_module 240# @FUNCTION: linux_chkconfig_module
209# @USAGE: option 241# @USAGE: option
211# @DESCRIPTION: 243# @DESCRIPTION:
212# It checks that CONFIG_<option>=m is present in the current kernel .config 244# It checks that CONFIG_<option>=m is present in the current kernel .config
213linux_chkconfig_module() { 245linux_chkconfig_module() {
214local RESULT 246local RESULT
215 require_configured_kernel 247 require_configured_kernel
216 RESULT="$(getfilevar CONFIG_${1} ${KV_OUT_DIR}/.config)" 248 RESULT="$(getfilevar_noexec CONFIG_${1} ${KV_OUT_DIR}/.config)"
217 [ "${RESULT}" = "m" ] && return 0 || return 1 249 [ "${RESULT}" = "m" ] && return 0 || return 1
218} 250}
219 251
220# @FUNCTION: linux_chkconfig_builtin 252# @FUNCTION: linux_chkconfig_builtin
221# @USAGE: option 253# @USAGE: option
223# @DESCRIPTION: 255# @DESCRIPTION:
224# It checks that CONFIG_<option>=y is present in the current kernel .config 256# It checks that CONFIG_<option>=y is present in the current kernel .config
225linux_chkconfig_builtin() { 257linux_chkconfig_builtin() {
226local RESULT 258local RESULT
227 require_configured_kernel 259 require_configured_kernel
228 RESULT="$(getfilevar CONFIG_${1} ${KV_OUT_DIR}/.config)" 260 RESULT="$(getfilevar_noexec CONFIG_${1} ${KV_OUT_DIR}/.config)"
229 [ "${RESULT}" = "y" ] && return 0 || return 1 261 [ "${RESULT}" = "y" ] && return 0 || return 1
230} 262}
231 263
232# @FUNCTION: linux_chkconfig_string 264# @FUNCTION: linux_chkconfig_string
233# @USAGE: option 265# @USAGE: option
234# @RETURN: CONFIG_<option> 266# @RETURN: CONFIG_<option>
235# @DESCRIPTION: 267# @DESCRIPTION:
236# It prints the CONFIG_<option> value of the current kernel .config (it requires a configured kernel). 268# It prints the CONFIG_<option> value of the current kernel .config (it requires a configured kernel).
237linux_chkconfig_string() { 269linux_chkconfig_string() {
238 require_configured_kernel 270 require_configured_kernel
239 getfilevar "CONFIG_${1}" "${KV_OUT_DIR}/.config" 271 getfilevar_noexec "CONFIG_${1}" "${KV_OUT_DIR}/.config"
240} 272}
241 273
242# Versioning Functions 274# Versioning Functions
243# --------------------------------------- 275# ---------------------------------------
244 276
287 3) for((y=0; y<$((3 - ${#KV_PATCH})); y++)); do test="${test}0"; done; 319 3) for((y=0; y<$((3 - ${#KV_PATCH})); y++)); do test="${test}0"; done;
288 test="${test}${KV_PATCH}";; 320 test="${test}${KV_PATCH}";;
289 *) die "Error in kernel-2_kernel_is(): Too many parameters.";; 321 *) die "Error in kernel-2_kernel_is(): Too many parameters.";;
290 esac 322 esac
291 done 323 done
292 324
293 [ ${test} ${operator} ${value} ] && return 0 || return 1 325 [ ${test} ${operator} ${value} ] && return 0 || return 1
294} 326}
295 327
296get_localversion() { 328get_localversion() {
297 local lv_list i x 329 local lv_list i x
363 # so we better find it eh? 395 # so we better find it eh?
364 # do we pass KBUILD_OUTPUT on the CLI? 396 # do we pass KBUILD_OUTPUT on the CLI?
365 OUTPUT_DIR="${OUTPUT_DIR:-${KBUILD_OUTPUT}}" 397 OUTPUT_DIR="${OUTPUT_DIR:-${KBUILD_OUTPUT}}"
366 398
367 # And if we didn't pass it, we can take a nosey in the Makefile 399 # And if we didn't pass it, we can take a nosey in the Makefile
368 kbuild_output="$(getfilevar KBUILD_OUTPUT ${KV_DIR}/Makefile)" 400 kbuild_output="$(getfilevar_noexec KBUILD_OUTPUT ${KV_DIR}/Makefile)"
369 OUTPUT_DIR="${OUTPUT_DIR:-${kbuild_output}}" 401 OUTPUT_DIR="${OUTPUT_DIR:-${kbuild_output}}"
370 402
371 # And contrary to existing functions I feel we shouldn't trust the 403 # And contrary to existing functions I feel we shouldn't trust the
372 # directory name to find version information as this seems insane. 404 # directory name to find version information as this seems insane.
373 # so we parse ${KV_DIR}/Makefile 405 # so we parse ${KV_DIR}/Makefile
374 KV_MAJOR="$(getfilevar VERSION ${KV_DIR}/Makefile)" 406 KV_MAJOR="$(getfilevar_noexec VERSION ${KV_DIR}/Makefile)"
375 KV_MINOR="$(getfilevar PATCHLEVEL ${KV_DIR}/Makefile)" 407 KV_MINOR="$(getfilevar_noexec PATCHLEVEL ${KV_DIR}/Makefile)"
376 KV_PATCH="$(getfilevar SUBLEVEL ${KV_DIR}/Makefile)" 408 KV_PATCH="$(getfilevar_noexec SUBLEVEL ${KV_DIR}/Makefile)"
377 KV_EXTRA="$(getfilevar EXTRAVERSION ${KV_DIR}/Makefile)" 409 KV_EXTRA="$(getfilevar_noexec EXTRAVERSION ${KV_DIR}/Makefile)"
378 410
379 if [ -z "${KV_MAJOR}" -o -z "${KV_MINOR}" -o -z "${KV_PATCH}" ] 411 if [ -z "${KV_MAJOR}" -o -z "${KV_MINOR}" -o -z "${KV_PATCH}" ]
380 then 412 then
381 qeerror "Could not detect kernel version." 413 qeerror "Could not detect kernel version."
382 qeerror "Please ensure that ${KERNEL_DIR} points to a complete set of Linux sources." 414 qeerror "Please ensure that ${KERNEL_DIR} points to a complete set of Linux sources."
639 local DEFLATE 671 local DEFLATE
640 672
641 einfo "Determining the usability of ZLIB_INFLATE support in your kernel" 673 einfo "Determining the usability of ZLIB_INFLATE support in your kernel"
642 674
643 ebegin "checking ZLIB_INFLATE" 675 ebegin "checking ZLIB_INFLATE"
644 getfilevar_isbuiltin CONFIG_ZLIB_INFLATE ${KV_DIR}/.config 676 linux_chkconfig_builtin CONFIG_ZLIB_INFLATE
645 eend $? 677 eend $?
646 [ "$?" != 0 ] && die 678 [ "$?" != 0 ] && die
647 679
648 ebegin "checking ZLIB_DEFLATE" 680 ebegin "checking ZLIB_DEFLATE"
649 getfilevar_isbuiltin CONFIG_ZLIB_DEFLATE ${KV_DIR}/.config 681 linux_chkconfig_builtin CONFIG_ZLIB_DEFLATE
650 eend $? 682 eend $?
651 [ "$?" != 0 ] && die 683 [ "$?" != 0 ] && die
652 684
653 local LINENO_START 685 local LINENO_START
654 local LINENO_END 686 local LINENO_END

Legend:
Removed from v.1.60  
changed lines
  Added in v.1.61

  ViewVC Help
Powered by ViewVC 1.1.20