summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStuart Herbert <stuart@gentoo.org>2003-08-27 10:55:55 +0000
committerStuart Herbert <stuart@gentoo.org>2003-08-27 10:55:55 +0000
commit1ee91189c41d5166f429566cfea1d7180d120547 (patch)
treef87e54d97d0b4a12eb12bd8665660a213a4109de /eclass/kernel-mod.eclass
parentCompile and link with dietlibc (sys-apps/busybox) (diff)
downloadhistorical-1ee91189c41d5166f429566cfea1d7180d120547.tar.gz
historical-1ee91189c41d5166f429566cfea1d7180d120547.tar.bz2
historical-1ee91189c41d5166f429566cfea1d7180d120547.zip
More tests to catch problems listed in bug #27343
Diffstat (limited to 'eclass/kernel-mod.eclass')
-rw-r--r--eclass/kernel-mod.eclass56
1 files changed, 47 insertions, 9 deletions
diff --git a/eclass/kernel-mod.eclass b/eclass/kernel-mod.eclass
index c586c7309861..543f00cedd8d 100644
--- a/eclass/kernel-mod.eclass
+++ b/eclass/kernel-mod.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2003 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/kernel-mod.eclass,v 1.2 2003/08/26 13:42:45 stuart Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/kernel-mod.eclass,v 1.3 2003/08/27 10:55:55 stuart Exp $
# This eclass provides help for compiling external kernel modules from
# source.
@@ -13,9 +13,14 @@ INHERITED="$INHERITED $ECLASS"
S=${WORKDIR}/${P}
DESCRIPTION="Based on the $ECLASS eclass"
-SRC_URI="unknown - please fix me!!"
+SRC_URI="${SRC_URI:-unknown - please fix me!!}"
KERNEL_DIR="${KERNEL_DIR:-/usr/src/linux}"
+kernel-mod_getmakefilevar ()
+{
+ grep $1 $2 | head -n 1 | cut -d = -f 2- | awk '{ print $1 }'
+}
+
kernel-mod_getversion ()
{
# yes, this is horrible, but it is effective
@@ -27,24 +32,57 @@ kernel-mod_getversion ()
einfo "${KERNEL_DIR} is a symbolic link"
einfo "Determining the real directory of the Linux kernel source code"
KV_DIR="`ls -ld ${KERNEL_DIR} | awk '{ print $11 }'`"
- else
+ elif [ -d ${KERNEL_DIR} ] ; then
einfo "${KERNEL_DIR} is a real directory"
KV_DIR="`ls -ld ${KERNEL_DIR} | awk '{ print $9 }'`"
+ else
+ eerror "Directory '${KERNEL_DIR}' cannot be found"
+ die
fi
KV_DIR="`basename $KV_DIR`"
# now, we need to break that down into versions
- KV_VERSION_FULL="`echo $KV_DIR | cut -f 2- -d -`"
- einfo "Building for Linux ${KV_VERSION_FULL} found in ${KERNEL_DIR}"
+ KV_DIR_VERSION_FULL="`echo $KV_DIR | cut -f 2- -d -`"
+
+ KV_DIR_MAJOR="`echo $KV_DIR_VERSION_FULL | cut -f 1 -d .`"
+ KV_DIR_MINOR="`echo $KV_DIR_VERSION_FULL | cut -f 2 -d .`"
+ KV_DIR_PATCH="`echo $KV_DIR_VERSION_FULL | cut -f 3 -d . | cut -f 3 -d -`"
+ KV_DIR_TYPE="`echo $KV_DIR_VERSION_FULL | cut -f 2- -d -`"
+
+ # sanity check - do the settings in the kernel's makefile match
+ # the directory that the kernel src is stored in?
- KV_MAJOR="`echo $KV_VERSION_FULL | cut -f 1 -d .`"
- KV_MINOR="`echo $KV_VERSION_FULL | cut -f 2 -d .`"
- KV_PATCH="`echo $KV_VERSION_FULL | cut -f 3 -d . | cut -f 3 -d -`"
- KV_TYPE="`echo $KV_VERSION_FULL | cut -f 2- -d -`"
+ KV_MK_FILE="${KERNEL_DIR}/Makefile"
+ KV_MK_MAJOR="`kernel-mod_getmakefilevar VERSION $KV_MK_FILE`"
+ KV_MK_MINOR="`kernel-mod_getmakefilevar PATCHLEVEL $KV_MK_FILE`"
+ KV_MK_PATCH="`kernel-mod_getmakefilevar SUBLEVEL $KV_MK_FILE`"
+ KV_MK_TYPE="`kernel-mod_getmakefilevar EXTRAVERSION $KV_MK_FILE`"
+
+ KV_MK_VERSION_FULL="$KV_MK_MAJOR.$KV_MK_MINOR.$KV_MK_PATCH$KV_MK_TYPE"
+
+ if [ "$KV_MK_VERSION_FULL" != "$KV_DIR_VERSION_FULL" ]; then
+ ewarn
+ ewarn "The kernel Makefile says that this is a $KV_MK_VERSION_FULL kernel"
+ ewarn "but the source is in a directory for a $KV_DIR_VERSION_FULL kernel."
+ ewarn
+ ewarn "This goes against the recommended Gentoo naming convention."
+ ewarn "Please rename your source directory to 'linux-${KV_MK_VERSION_FULL}'"
+ ewarn
+ fi
# these variables can be used by ebuilds to determine whether they
# will work with the targetted kernel or not
+ #
+ # do not rely on any of the variables above being available
+
+ KV_VERSION_FULL="$KV_MK_VERSION_FULL"
+ KV_MAJOR="$KV_MK_MAJOR"
+ KV_MINOR="$KV_MK_MINOR"
+ KV_PATCH="$KV_MK_PATCH"
+ KV_TYPE="$KV_MK_TYPE"
+
+ einfo "Building for Linux ${KV_VERSION_FULL} found in ${KERNEL_DIR}"
}
kernel-mod_src_compile ()