/[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.10 Revision 1.11
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.10 2004/12/14 18:56:46 johnm Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/linux-info.eclass,v 1.11 2004/12/17 15:12:07 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
74# set's ARCH back to what portage expects 74# set's ARCH back to what portage expects
75set_arch_to_portage() { 75set_arch_to_portage() {
76 export ARCH="${PORTAGE_ARCH}" 76 export ARCH="${PORTAGE_ARCH}"
77} 77}
78 78
79
80#
81# qeinfo "Message"
82# -------------------
83# qeinfo is a queit einfo call when EBUILD_PHASE
84# should not have visible output.
85#
86qeinfo() {
87 local outputmsg
88 outputmsg="${@}"
89 case "${EBUILD_PHASE}" in
90 depend) unset outputmsg;;
91 clean) unset outputmsg;;
92 preinst) unset outputmsg;;
93 esac
94 [ -n "${outputmsg}" ] && einfo "${outputmsg}"
95}
96
97qeerror() {
98 local outputmsg
99 outputmsg="${@}"
100 case "${EBUILD_PHASE}" in
101 depend) unset outputmsg;;
102 clean) unset outputmsg;;
103 preinst) unset outputmsg;;
104 esac
105 [ -n "${outputmsg}" ] && einfo "${outputmsg}"
106}
107
108
109
79# File Functions 110# File Functions
80# --------------------------------------- 111# ---------------------------------------
81 112
82# getfilevar accepts 2 vars as follows: 113# getfilevar accepts 2 vars as follows:
83# getfilevar <VARIABLE> <CONFIGFILE> 114# getfilevar <VARIABLE> <CONFIGFILE>
183 # if we dont know KV_FULL, then we need too. 214 # if we dont know KV_FULL, then we need too.
184 # make sure KV_DIR isnt set since we need to work it out via KERNEL_DIR 215 # make sure KV_DIR isnt set since we need to work it out via KERNEL_DIR
185 unset KV_DIR 216 unset KV_DIR
186 217
187 # KV_DIR will contain the full path to the sources directory we should use 218 # KV_DIR will contain the full path to the sources directory we should use
188 einfo "Determining the location of the kernel source code" 219 qeinfo "Determining the location of the kernel source code"
189 [ -h "${KERNEL_DIR}" ] && KV_DIR="$(readlink -f ${KERNEL_DIR})" 220 [ -h "${KERNEL_DIR}" ] && KV_DIR="$(readlink -f ${KERNEL_DIR})"
190 [ -d "${KERNEL_DIR}" ] && KV_DIR="${KERNEL_DIR}" 221 [ -d "${KERNEL_DIR}" ] && KV_DIR="${KERNEL_DIR}"
191 222
192 if [ -z "${KV_DIR}" ] 223 if [ -z "${KV_DIR}" ]
193 then 224 then
194 eerror "Unable to find kernel sources at ${KERNEL_DIR}" 225 qeerror "Unable to find kernel sources at ${KERNEL_DIR}"
195 einfo "This package requires Linux sources." 226 qeinfo "This package requires Linux sources."
196 if [ "${KERNEL_DIR}" == "/usr/src/linux" ] ; then 227 if [ "${KERNEL_DIR}" == "/usr/src/linux" ] ; then
197 einfo "Please make sure that ${KERNEL_DIR} points at your running kernel, " 228 qeinfo "Please make sure that ${KERNEL_DIR} points at your running kernel, "
198 einfo "(or the kernel you wish to build against)." 229 qeinfo "(or the kernel you wish to build against)."
199 einfo "Alternatively, set the KERNEL_DIR environment variable to the kernel sources location" 230 qeinfo "Alternatively, set the KERNEL_DIR environment variable to the kernel sources location"
200 else 231 else
201 einfo "Please ensure that the KERNEL_DIR environment variable points at full Linux sources of the kernel you wish to compile against." 232 qeinfo "Please ensure that the KERNEL_DIR environment variable points at full Linux sources of the kernel you wish to compile against."
202 fi 233 fi
203 die "Cannot locate Linux sources at ${KERNEL_DIR}" 234 die "Cannot locate Linux sources at ${KERNEL_DIR}"
204 fi 235 fi
205 236
206 einfo "Found kernel source directory:" 237 qeinfo "Found kernel source directory:"
207 einfo " ${KV_DIR}" 238 qeinfo " ${KV_DIR}"
208 239
209 if [ ! -s "${KV_DIR}/Makefile" ] 240 if [ ! -s "${KV_DIR}/Makefile" ]
210 then 241 then
211 eerror "Could not find a Makefile in the kernel source directory." 242 qeerror "Could not find a Makefile in the kernel source directory."
212 eerror "Please ensure that ${KERNEL_DIR} points to a complete set of Linux sources" 243 qeerror "Please ensure that ${KERNEL_DIR} points to a complete set of Linux sources"
213 die "Makefile not found in ${KV_DIR}" 244 die "Makefile not found in ${KV_DIR}"
214 fi 245 fi
215 246
216 # OK so now we know our sources directory, but they might be using 247 # OK so now we know our sources directory, but they might be using
217 # KBUILD_OUTPUT, and we need this for .config and localversions-* 248 # KBUILD_OUTPUT, and we need this for .config and localversions-*
231 KV_PATCH="$(getfilevar SUBLEVEL ${KV_DIR}/Makefile)" 262 KV_PATCH="$(getfilevar SUBLEVEL ${KV_DIR}/Makefile)"
232 KV_EXTRA="$(getfilevar EXTRAVERSION ${KV_DIR}/Makefile)" 263 KV_EXTRA="$(getfilevar EXTRAVERSION ${KV_DIR}/Makefile)"
233 264
234 if [ -z "${KV_MAJOR}" -o -z "${KV_MINOR}" -o -z "${KV_PATCH}" ] 265 if [ -z "${KV_MAJOR}" -o -z "${KV_MINOR}" -o -z "${KV_PATCH}" ]
235 then 266 then
236 eerror "Could not detect kernel version." 267 qeerror "Could not detect kernel version."
237 eerror "Please ensure that ${KERNEL_DIR} points to a complete set of Linux sources" 268 qeerror "Please ensure that ${KERNEL_DIR} points to a complete set of Linux sources"
238 die "Could not parse version info from ${KV_DIR}/Makefile" 269 die "Could not parse version info from ${KV_DIR}/Makefile"
239 fi 270 fi
240 271
241 # and in newer versions we can also pull LOCALVERSION if it is set. 272 # and in newer versions we can also pull LOCALVERSION if it is set.
242 # but before we do this, we need to find if we use a different object directory. 273 # but before we do this, we need to find if we use a different object directory.
247 278
248 [ -h "${OUTPUT_DIR}" ] && KV_OUT_DIR="$(readlink -f ${OUTPUT_DIR})" 279 [ -h "${OUTPUT_DIR}" ] && KV_OUT_DIR="$(readlink -f ${OUTPUT_DIR})"
249 [ -d "${OUTPUT_DIR}" ] && KV_OUT_DIR="${OUTPUT_DIR}" 280 [ -d "${OUTPUT_DIR}" ] && KV_OUT_DIR="${OUTPUT_DIR}"
250 if [ -n "${KV_OUT_DIR}" ]; 281 if [ -n "${KV_OUT_DIR}" ];
251 then 282 then
252 einfo "Found kernel object directory:" 283 qeinfo "Found kernel object directory:"
253 einfo " ${KV_OUT_DIR}" 284 qeinfo " ${KV_OUT_DIR}"
254 285
255 KV_LOCAL="$(cat ${KV_OUT_DIR}/localversion* 2>/dev/null)" 286 KV_LOCAL="$(cat ${KV_OUT_DIR}/localversion* 2>/dev/null)"
256 fi 287 fi
257 # and if we STILL haven't got it, then we better just set it to KV_DIR 288 # and if we STILL haven't got it, then we better just set it to KV_DIR
258 KV_OUT_DIR="${KV_OUT_DIR:-${KV_DIR}}" 289 KV_OUT_DIR="${KV_OUT_DIR:-${KV_DIR}}"
262 KV_LOCAL="${KV_LOCAL//\"/}" 293 KV_LOCAL="${KV_LOCAL//\"/}"
263 294
264 # And we should set KV_FULL to the full expanded version 295 # And we should set KV_FULL to the full expanded version
265 KV_FULL="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}${KV_LOCAL}" 296 KV_FULL="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}${KV_LOCAL}"
266 297
267 einfo "Found sources for kernel version:" 298 qeinfo "Found sources for kernel version:"
268 einfo " ${KV_FULL}" 299 qeinfo " ${KV_FULL}"
269 300
270 if [ ! -s "${KV_OUT_DIR}/.config" ] 301 if [ ! -s "${KV_OUT_DIR}/.config" ]
271 then 302 then
272 eerror "Could not find a usable .config in the kernel source directory." 303 qeerror "Could not find a usable .config in the kernel source directory."
273 eerror "Please ensure that ${KERNEL_DIR} points to a configured set of Linux sources" 304 qeerror "Please ensure that ${KERNEL_DIR} points to a configured set of Linux sources"
274 die ".config not found in ${KV_OUT_DIR}" 305 die ".config not found in ${KV_OUT_DIR}"
275 fi 306 fi
276} 307}
277 308
278 309

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

  ViewVC Help
Powered by ViewVC 1.1.20