linux-image: Include package version in utsname version string (Closes: #638878)

There is not enough space for both timestamp and package version, so
replace the timestamp by setting KBUILD_BUILD_TIMESTAMP.

We now need to get the distribution name in debian/rules.real, but
we already have DISTRIBUTION as the suite name so use DISTRIBUTOR for
the distribution name (!).

The utsname version string also appears in /proc/version and the init
banner, so don't bother including it again explicitly.  This means we
no longer need to patch init/version.c and scripts/mkcompile_h at all.
Instead, split maintainer at the '@' and set KBUILD_BUILD_USER and
KBUILD_BUILD_HOST accordingly.

Carry on generating <generated/package.h>, but drop the parentheses
from LINUX_PACKAGE_ID now that it's not used in init/version.c.

Drop support for version.$DISTRIBUTION files.  Any derived
distribution can set KBUILD_BUILD_* in the same way we are doing.

svn path=/dists/sid/linux/; revision=19289
This commit is contained in:
Ben Hutchings 2012-07-24 01:52:31 +00:00
parent f24a365c2a
commit aca61360d7
3 changed files with 22 additions and 84 deletions

8
debian/changelog vendored
View File

@ -1,3 +1,11 @@
linux (3.2.23-2) UNRELEASED; urgency=low
* linux-image: Include package version in utsname version string
('uname -v' output) (Closes: #638878)
* linux-source: Drop support for version.$DISTRIBUTION
-- Ben Hutchings <ben@decadent.org.uk> Tue, 24 Jul 2012 02:20:37 +0100
linux (3.2.23-1) unstable; urgency=low
* New upstream stable update:

View File

@ -1,75 +1,11 @@
From: Bastian Blank <waldi@debian.org>
Subject: Add debian version information to kernel version string
Date: Sun, 20 May 2007 11:46:51 +0200
Include the package version in /proc/version and the initial log
banner.
Determine the target distribution ($DISTRIBUTION) with lsb_release,
defaulting to Debian.
From: Ben Hutchings <ben@decadent.org.uk>
Subject: Add header file with package version information
Date: Tue, 24 Jul 2012 02:15:43 +0100
For distribution binary packages we assume
$DISTRIBUTION_OFFICIAL_BUILD is set. Add $DISTRIBUTION and
$DISTRIBUTION_VERSION after the kernel version (UTS_RELEASE), and
replace the account name used to build the package with
$DISTRIBUTION_UPLOADER.
$DISTRIBUTION_OFFICIAL_BUILD, $DISTRIBUTOR and $DISTRIBUTION_VERSION
are set.
[bwh: Changed $DISTRIBUTION_UPLOADER to $DISTRIBUTION_MAINTAINER.]
For custom packages built from a linux-source package, read the
package version from version.$DISTRIBUTION and add that after
the kernel version string.
--- a/init/version.c
+++ b/init/version.c
@@ -11,6 +11,7 @@
#include <linux/uts.h>
#include <linux/utsname.h>
#include <generated/utsrelease.h>
+#include <generated/package.h>
#include <linux/version.h>
#ifndef CONFIG_KALLSYMS
@@ -37,12 +38,12 @@ struct uts_namespace init_uts_ns = {
};
EXPORT_SYMBOL_GPL(init_uts_ns);
-/* FIXED STRINGS! Don't touch! */
const char linux_banner[] =
- "Linux version " UTS_RELEASE " (" LINUX_COMPILE_BY "@"
- LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") " UTS_VERSION "\n";
+ "Linux version " UTS_RELEASE LINUX_PACKAGE_ID
+ LINUX_COMPILE_ID " (" LINUX_COMPILER ") " UTS_VERSION "\n";
const char linux_proc_banner[] =
"%s version %s"
- " (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ")"
+ LINUX_PACKAGE_ID
+ LINUX_COMPILE_ID
" (" LINUX_COMPILER ") %s\n";
--- a/scripts/mkcompile_h
+++ b/scripts/mkcompile_h
@@ -73,8 +73,18 @@ UTS_TRUNCATE="cut -b -$UTS_LEN"
echo \#define UTS_VERSION \"`echo $UTS_VERSION | $UTS_TRUNCATE`\"
- echo \#define LINUX_COMPILE_BY \"`echo $LINUX_COMPILE_BY | $UTS_TRUNCATE`\"
- echo \#define LINUX_COMPILE_HOST \"`echo $LINUX_COMPILE_HOST | $UTS_TRUNCATE`\"
+ DISTRIBUTION=$(lsb_release -is 2>/dev/null)
+ DISTRIBUTION=${DISTRIBUTION:-Debian}
+
+ if [ "$DISTRIBUTION_OFFICIAL_BUILD" ]; then
+ echo \#define LINUX_COMPILE_BY \"unknown\"
+ echo \#define LINUX_COMPILE_HOST \"$DISTRIBUTION\"
+ echo \#define LINUX_COMPILE_ID \" \($DISTRIBUTION_MAINTAINER\)\"
+ else
+ echo \#define LINUX_COMPILE_BY \"`echo $LINUX_COMPILE_BY | $UTS_TRUNCATE`\"
+ echo \#define LINUX_COMPILE_HOST \"`echo $LINUX_COMPILE_HOST | $UTS_TRUNCATE`\"
+ echo \#define LINUX_COMPILE_ID \" \(\" LINUX_COMPILE_BY \"@\" LINUX_COMPILE_HOST \"\)\"
+ fi
echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | tail -n 1`\"
) > .tmpcompile
--- a/Makefile
+++ b/Makefile
@@ -976,7 +976,7 @@ endif
@ -81,30 +17,19 @@ the kernel version string.
$(cmd_crmodverdir)
archprepare: archscripts prepare1 scripts_basic
@@ -1008,12 +1008,36 @@ define filechk_version.h
@@ -1008,12 +1008,25 @@ define filechk_version.h
echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))';)
endef
+DISTRIBUTION := $(shell lsb_release -is 2>/dev/null)
+ifeq ($(DISTRIBUTION),)
+DISTRIBUTION := Debian
+endif
+
+ifneq ($(DISTRIBUTION_OFFICIAL_BUILD),)
+define filechk_package.h
+ echo \#define LINUX_PACKAGE_ID \" \($(DISTRIBUTION) $(DISTRIBUTION_VERSION)\)\"
+endef
+else
+ifneq ($(wildcard version.$(DISTRIBUTION)),)
+define filechk_package.h
+ echo \#define LINUX_PACKAGE_ID \" \($$(cut -d" " -f1 version.$(DISTRIBUTION))\)\"
+ echo \#define LINUX_PACKAGE_ID \"$(DISTRIBUTOR) $(DISTRIBUTION_VERSION)\"
+endef
+else
+define filechk_package.h
+ echo \#define LINUX_PACKAGE_ID \" \(unknown\)\"
+ echo \#define LINUX_PACKAGE_ID \"\"
+endef
+endif
+endif
+
include/linux/version.h: $(srctree)/Makefile FORCE
$(call filechk,version.h)

7
debian/rules.real vendored
View File

@ -13,6 +13,11 @@ DEB_BUILD_ARCH := $(shell dpkg-architecture -a'$(ARCH)' -qDEB_BUILD_ARCH)
MAINTAINER := $(shell sed -ne 's,^Maintainer: .[^<]*<\([^>]*\)>,\1,p' debian/control)
DISTRIBUTION := $(shell dpkg-parsechangelog | sed -ne 's,^Distribution: ,,p')
DISTRIBUTOR := $(shell lsb_release -is 2>/dev/null)
ifeq ($(DISTRIBUTOR),)
DISTRIBUTOR := Debian
endif
export PYTHONPATH = $(CURDIR)/debian/lib/python
export DH_OPTIONS
export DEB_HOST_ARCH DEB_HOST_GNU_TYPE DEB_BUILD_ARCH
@ -33,7 +38,7 @@ include debian/rules.defs
stamp = [ -d $(dir $@) ] || mkdir $(dir $@); touch $@
setup_env := env -u ABINAME -u ABINAME_PART -u ARCH -u FEATURESET -u FLAVOUR -u VERSION -u LOCALVERSION
setup_env += DISTRIBUTION_OFFICIAL_BUILD=1 DISTRIBUTION_MAINTAINER=$(MAINTAINER) DISTRIBUTION_VERSION="$(SOURCEVERSION)"
setup_env += DISTRIBUTION_OFFICIAL_BUILD=1 DISTRIBUTOR="$(DISTRIBUTOR)" DISTRIBUTION_VERSION="$(SOURCEVERSION)" KBUILD_BUILD_TIMESTAMP="$(DISTRIBUTOR) $(SOURCEVERSION)" KBUILD_BUILD_USER="$(word 1,$(subst @, ,$(MAINTAINER)))" KBUILD_BUILD_HOST="$(word 2,$(subst @, ,$(MAINTAINER)))"
MAKE_CLEAN = $(setup_env) $(MAKE)
MAKE_SELF := $(MAKE) -f debian/rules.real $(MAKEOVERRIDES)