/[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.20 Revision 1.21
1# Copyright 1999-2004 Gentoo Foundation 1# Copyright 1999-2004 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.20 2005/01/23 20:47:42 eradicator Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/linux-info.eclass,v 1.21 2005/01/31 20:03:47 johnm Exp $
4# 4#
5# Description: This eclass is used as a central eclass for accessing kernel 5# Description: This eclass is used as a central eclass for accessing kernel
6# related information for sources already installed. 6# related information for sources already installed.
7# It is vital for linux-mod to function correctly, and is split 7# It is vital for linux-mod to function correctly, and is split
8# out so that any ebuild behaviour "templates" are abstracted out 8# out so that any ebuild behaviour "templates" are abstracted out
14# Please direct your bugs to the current eclass maintainer :) 14# Please direct your bugs to the current eclass maintainer :)
15 15
16# A Couple of env vars are available to effect usage of this eclass 16# A Couple of env vars are available to effect usage of this eclass
17# These are as follows: 17# These are as follows:
18# 18#
19# Env Var Option Description 19# Env Var Option Description
20# KERNEL_DIR <string> The directory containing kernel the target kernel 20# KERNEL_DIR <string> The directory containing kernel the target kernel
21# sources. 21# sources.
22# CONFIG_CHECK <string> a list of .config options to check for before 22# CONFIG_CHECK <string> a list of .config options to check for before
23# proceeding with the install. ie: CONFIG_CHECK="MTRR" 23# proceeding with the install. ie: CONFIG_CHECK="MTRR"
24# You can also check that an option doesn't exist by 24# You can also check that an option doesn't exist by
25# prepending it with an exclamation mark (!). 25# prepending it with an exclamation mark (!).
26# ie: CONFIG_CHECK="!MTRR" 26# ie: CONFIG_CHECK="!MTRR"
27# <CFG>_ERROR <string> The error message to display when the above check 27# ERROR_CFG <string> The error message to display when the above check
28# fails. <CFG> should reference the appropriate option 28# fails. <CFG> should reference the appropriate option
29# as above. ie: MTRR_ERROR="MTRR exists in the .config 29# as above. ie: MTRR_ERROR="MTRR exists in the .config
30# but shouldn't!!" 30# but shouldn't!!"
31# KBUILD_OUTPUT <string> This is passed on commandline, or can be set from 31# KBUILD_OUTPUT <string> This is passed on commandline, or can be set from
32# the kernel makefile. This contains the directory 32# the kernel makefile. This contains the directory
33# which is to be used as the kernel object directory. 33# which is to be used as the kernel object directory.
34 34
35# There are also a couple of variables which are set by this, and shouldn't be 35# There are also a couple of variables which are set by this, and shouldn't be
36# set by hand. These are as follows: 36# set by hand. These are as follows:
37# 37#
38# Env Var Option Description 38# Env Var Option Description
41# KV_MINOR <integer> The kernel minor version. ie: 6 41# KV_MINOR <integer> The kernel minor version. ie: 6
42# KV_PATCH <integer> The kernel patch version. ie: 9 42# KV_PATCH <integer> The kernel patch version. ie: 9
43# KV_EXTRA <string> The kernel EXTRAVERSION. ie: -gentoo 43# KV_EXTRA <string> The kernel EXTRAVERSION. ie: -gentoo
44# KV_LOCAL <string> The kernel LOCALVERSION concatenation. ie: -johnm 44# KV_LOCAL <string> The kernel LOCALVERSION concatenation. ie: -johnm
45# KV_DIR <string> The kernel source directory, will be null if 45# KV_DIR <string> The kernel source directory, will be null if
46# KERNEL_DIR is invalid. 46# KERNEL_DIR is invalid.
47# KV_OUT_DIR <string> The kernel object directory. will be KV_DIR unless 47# KV_OUT_DIR <string> The kernel object directory. will be KV_DIR unless
48# koutput is used. This should be used for referencing 48# koutput is used. This should be used for referencing
49# .config. 49# .config.
50 50
51# And to ensure all the weirdness with crosscompile
52inherit toolchain-funcs
51 53
52ECLASS=linux-info 54ECLASS=linux-info
53INHERITED="$INHERITED $ECLASS" 55INHERITED="$INHERITED $ECLASS"
54EXPORT_FUNCTIONS pkg_setup 56EXPORT_FUNCTIONS pkg_setup
55 57
56inherit toolchain-funcs
57
58# Overwritable environment Var's 58# Overwritable environment Var's
59# --------------------------------------- 59# ---------------------------------------
60KERNEL_DIR="${KERNEL_DIR:-/usr/src/linux}" 60KERNEL_DIR="${KERNEL_DIR:-${ROOT}usr/src/linux}"
61 61
62 62
63# Bug fixes 63# Bug fixes
64
65# fix to bug #75034 64# fix to bug #75034
66case ${ARCH} in 65case ${ARCH} in
67 ppc) BUILD_FIXES="${BUILD_FIXES} TOUT=${T}/.tmp_gas_check";; 66 ppc) BUILD_FIXES="${BUILD_FIXES} TOUT=${T}/.tmp_gas_check";;
68 ppc64) BUILD_FIXES="${BUILD_FIXES} TOUT=${T}/.tmp_gas_check";; 67 ppc64) BUILD_FIXES="${BUILD_FIXES} TOUT=${T}/.tmp_gas_check";;
69esac 68esac
70 69
71# Pulled from eutils as it might be more useful only being here since 70# These are legacy wrappers for toolchain-funcs.
72# very few ebuilds which dont use this eclass will ever ever use these functions 71# I dont like them here, but oh well.
73set_arch_to_kernel() { 72set_arch_to_kernel() { $(tc-arch-kernel); }
74 export ARCH="$(tc-arch-kernel)"
75}
76
77# set's ARCH back to what portage expects
78set_arch_to_portage() { 73set_arch_to_portage() { $(tc-arch); }
79 export ARCH="$(tc-arch)"
80}
81 74
82
83#
84# qeinfo "Message" 75# qeinfo "Message"
85# ------------------- 76# -------------------
86# qeinfo is a queit einfo call when EBUILD_PHASE 77# qeinfo is a quiet einfo call when EBUILD_PHASE
87# should not have visible output. 78# should not have visible output.
88# 79qout() {
89qeinfo() {
90 local outputmsg 80 local outputmsg type
81 type=${1}
82 shift
91 outputmsg="${@}" 83 outputmsg="${@}"
92 case "${EBUILD_PHASE}" in 84 case "${EBUILD_PHASE}" in
93 depend) unset outputmsg;; 85 depend) unset outputmsg;;
94 clean) unset outputmsg;; 86 clean) unset outputmsg;;
95 preinst) unset outputmsg;; 87 preinst) unset outputmsg;;
96 esac 88 esac
97 [ -n "${outputmsg}" ] && einfo "${outputmsg}" 89 [ -n "${outputmsg}" ] && ${type} "${outputmsg}"
98} 90}
99 91
100qeerror() { 92qeinfo() { qout einfo "${@}" ; }
101 local outputmsg 93qeerror() { qout eerror "${@}" ; }
102 outputmsg="${@}"
103 case "${EBUILD_PHASE}" in
104 depend) unset outputmsg;;
105 clean) unset outputmsg;;
106 preinst) unset outputmsg;;
107 esac
108 [ -n "${outputmsg}" ] && einfo "${outputmsg}"
109}
110
111
112 94
113# File Functions 95# File Functions
114# --------------------------------------- 96# ---------------------------------------
115 97
116# getfilevar accepts 2 vars as follows: 98# getfilevar accepts 2 vars as follows:
117# getfilevar <VARIABLE> <CONFIGFILE> 99# getfilevar <VARIABLE> <CONFIGFILE>
118 100
119getfilevar() { 101getfilevar() {
120local ERROR workingdir basefname basedname xarch 102local ERROR workingdir basefname basedname myARCH="${ARCH}"
121 ERROR=0 103 ERROR=0
122 104
123 [ -z "${1}" ] && ERROR=1 105 [ -z "${1}" ] && ERROR=1
124 [ ! -f "${2}" ] && ERROR=1 106 [ ! -f "${2}" ] && ERROR=1
125 107
131 eerror " getfilevar <VARIABLE> <CONFIGFILE>" 113 eerror " getfilevar <VARIABLE> <CONFIGFILE>"
132 else 114 else
133 workingdir=${PWD} 115 workingdir=${PWD}
134 basefname=$(basename ${2}) 116 basefname=$(basename ${2})
135 basedname=$(dirname ${2}) 117 basedname=$(dirname ${2})
136 xarch=${ARCH}
137 unset ARCH 118 unset ARCH
138 119
139 cd ${basedname} 120 cd ${basedname}
140 echo -e "include ${basefname}\ne:\n\t@echo \$(${1})" | \ 121 echo -e "include ${basefname}\ne:\n\t@echo \$(${1})" | \
141 make ${BUILD_FIXES} -f - e 2>/dev/null 122 make ${BUILD_FIXES} -f - e 2>/dev/null
142 cd ${workingdir} 123 cd ${workingdir}
143 124
144 ARCH=${xarch} 125 ARCH=${myARCH}
145 fi 126 fi
146} 127}
147 128
148linux_chkconfig_present() { 129linux_chkconfig_present() {
149local RESULT 130local RESULT
325 306
326 KV_LOCAL="$(cat ${KV_OUT_DIR}/localversion* 2>/dev/null)" 307 KV_LOCAL="$(cat ${KV_OUT_DIR}/localversion* 2>/dev/null)"
327 fi 308 fi
328 # and if we STILL haven't got it, then we better just set it to KV_DIR 309 # and if we STILL haven't got it, then we better just set it to KV_DIR
329 KV_OUT_DIR="${KV_OUT_DIR:-${KV_DIR}}" 310 KV_OUT_DIR="${KV_OUT_DIR:-${KV_DIR}}"
330 311
331 KV_LOCAL="${KV_LOCAL}$(cat ${KV_DIR}/localversion* 2>/dev/null)" 312 KV_LOCAL="${KV_LOCAL}$(cat ${KV_DIR}/localversion* 2>/dev/null)"
332 KV_LOCAL="${KV_LOCAL}$(linux_chkconfig_string LOCALVERSION)" 313 KV_LOCAL="${KV_LOCAL}$(linux_chkconfig_string LOCALVERSION)"
333 KV_LOCAL="${KV_LOCAL//\"/}" 314 KV_LOCAL="${KV_LOCAL//\"/}"
334 315
335 # And we should set KV_FULL to the full expanded version 316 # And we should set KV_FULL to the full expanded version
336 KV_FULL="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}${KV_LOCAL}" 317 KV_FULL="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}${KV_LOCAL}"
337 318
338 qeinfo "Found sources for kernel version:" 319 qeinfo "Found sources for kernel version:"
339 qeinfo " ${KV_FULL}" 320 qeinfo " ${KV_FULL}"
340 321
341 if [ ! -s "${KV_OUT_DIR}/.config" ] 322 if [ ! -s "${KV_OUT_DIR}/.config" ]
342 then 323 then
343 qeerror "Could not find a usable .config in the kernel source directory." 324 qeerror "Could not find a usable .config in the kernel source directory."
344 qeerror "Please ensure that ${KERNEL_DIR} points to a configured set of Linux sources." 325 qeerror "Please ensure that ${KERNEL_DIR} points to a configured set of Linux sources."
345 qeerror "If you are using KBUILD_OUTPUT, please set the environment var so that" 326 qeerror "If you are using KBUILD_OUTPUT, please set the environment var so that"
346 qeerror "it points to the necessary object directory so that it might find .config." 327 qeerror "it points to the necessary object directory so that it might find .config."
347 return 1 328 return 1
348 fi 329 fi
349 330
350 return 0 331 return 0
351} 332}
352 333
353 334
354 335
431 error=0 412 error=0
432 fi 413 fi
433 else 414 else
434 if ! linux_chkconfig_present ${config} 415 if ! linux_chkconfig_present ${config}
435 then 416 then
417 # Support the new syntax first.
436 local_error="${config}_ERROR" 418 local_error="ERROR_${config}"
437 local_error="${!local_error}" 419 local_error="${!local_error}"
438 [ -n "${local_error}" ] && eerror " ${local_error}" || \ 420
421 # then fall back on the older syntax.
422 if [[ -z ${local_error} ]] ; then
423 local_error="${config}_ERROR"
424 local_error="${!local_error}"
425 fi
426
427 [[ -n ${local_error} ]] && eerror " ${local_error}" || \
439 eerror " CONFIG_${config}:\tshould be set in the kernel configuration, but isn't" 428 eerror " CONFIG_${config}:\tshould be set in the kernel configuration, but isn't"
440 error=1 429 error=1
441 fi 430 fi
442 fi 431 fi
443 done 432 done

Legend:
Removed from v.1.20  
changed lines
  Added in v.1.21

  ViewVC Help
Powered by ViewVC 1.1.20