Kernel versioning [was Re: Kernel package and modules]

Mike (mwester) mwester at
Tue Aug 5 18:17:49 CEST 2008

For the record, here's the patch to permit the build script to
override the "hostname" in the (user at hostname) portion of the
kernel's identification area.  Build scripts can use this to
provide build-system-specific ID information, which should usually
identify the origin of the kernel (i.e. what build system built
it) and some identifier that can be used to determine what version
of sources the kernel was built from.

Here's a fragment, based on what we've seen earlier, that works
with the OM git repo:

if [ -d .git ] ; then
  HEAD=`git show --pretty=oneline | head -n1 | cut -d' ' -f1 | cut -b1-16`
  BRANCH=`git branch | grep ^\* | cut -d' ' -f2`

(The above can be easily incorporated into a bitbake recipe to
insert the OE equivalent information, of course.)

And here's the patch to the kernel scripts/mkcompile_h file
that makes this possible:

commit 246698ff32d26f1d2cef157a2aec31052afbd427
Author: Mike Westerhof <mwester at>
Date:   Sun Aug 3 16:07:08 2008 -0500


    This change permits the "hostname" portion of the kernel identification
    (user at hostname) to be overridden by setting a value for the environment
    variable $HOSTNAME_OVERRIDE at build time.

    This permits encoding of the branch and version number (for example)
    into the kernel, without impacting the ability of the kernel to
    link with modules on the rootfs (unlike the use of EXTRAVERSION in
    the kernel makefile).

    Signed-off-by: Mike Westerhof <mwester at>

diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h
index a8740df..132ac5d 100755
--- a/scripts/mkcompile_h
+++ b/scripts/mkcompile_h
@@ -61,7 +61,11 @@ UTS_TRUNCATE="sed -e s/\(.\{1,$UTS_LEN\}\).*/\1/"

   echo \#define LINUX_COMPILE_TIME \"`date +%T`\"
   echo \#define LINUX_COMPILE_BY \"`whoami`\"
-  echo \#define LINUX_COMPILE_HOST \"`hostname | $UTS_TRUNCATE`\"
+  if [ -n "$HOSTNAME_OVERRIDE" ]; then
+  else
+    echo \#define LINUX_COMPILE_HOST \"`hostname | $UTS_TRUNCATE`\"
+  fi

   if [ -x /bin/dnsdomainname ]; then
     echo \#define LINUX_COMPILE_DOMAIN \"`dnsdomainname | $UTS_TRUNCATE`\"

More information about the devel mailing list