From 572e852fd02bc492e22bc6d14b9bc6d1ba492db4 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 9 Apr 2013 23:25:50 +0200 Subject: [PATCH] git tracker: add special version string to build In output trees created with the git tracker, we avoid changing the "versions" file all the time and just put "(see git)" into the versions. However, it's useful to still be able to identify it, and when using this the backport is (usually) built in the git tree. Use this fact and add the git tree commit into a new variable to put it into the MODULE_VERSION and also print it at runtime. Signed-off-by: Johannes Berg --- backport/Makefile.kernel | 1 + backport/Makefile.real | 5 +++++ backport/compat/main.c | 23 ++++++++++++++++++++--- backport/include/linux/compat-2.6.h | 15 +++++++++++---- devel/git-tracker.py | 3 +-- gentree.py | 14 ++++++++++---- 6 files changed, 48 insertions(+), 13 deletions(-) diff --git a/backport/Makefile.kernel b/backport/Makefile.kernel index 54a121872dcf..91e7dd6b864a 100644 --- a/backport/Makefile.kernel +++ b/backport/Makefile.kernel @@ -12,6 +12,7 @@ NOSTDINC_FLAGS := \ -DBACKPORTS_VERSION=\"$(BACKPORTS_VERSION)\" \ -DBACKPORTED_KERNEL_VERSION=\"$(BACKPORTED_KERNEL_VERSION)\" \ -DBACKPORTED_KERNEL_NAME=\"$(BACKPORTED_KERNEL_NAME)\" \ + $(BACKPORTS_GIT_TRACKER_DEF) \ $(CFLAGS) obj-y += compat/ diff --git a/backport/Makefile.real b/backport/Makefile.real index 954fc8691d98..40668c24d785 100644 --- a/backport/Makefile.real +++ b/backport/Makefile.real @@ -1,5 +1,10 @@ include versions export BACKPORTS_VERSION BACKPORTED_KERNEL_VERSION BACKPORTED_KERNEL_NAME +ifdef BACKPORTS_GIT_TRACKED +export BACKPORTS_GIT_TRACKER_DEF=-DBACKPORTS_GIT_TRACKED=\"$(BACKPORTS_GIT_TRACKED)\" +else +export BACKPORTS_GIT_TRACKER_DEF= +endif # disable built-in rules for this file .SUFFIXES: diff --git a/backport/compat/main.c b/backport/compat/main.c index 6f1bfb751828..7818d73aa583 100644 --- a/backport/compat/main.c +++ b/backport/compat/main.c @@ -18,13 +18,20 @@ MODULE_LICENSE("GPL"); #endif static char *backported_kernel_name = BACKPORTED_KERNEL_NAME; -static char *backported_kernel_version = BACKPORTED_KERNEL_VERSION; -static char *backports_version = BACKPORTS_VERSION; module_param(backported_kernel_name, charp, 0400); MODULE_PARM_DESC(backported_kernel_name, "The kernel tree name that was used for this backport (" BACKPORTED_KERNEL_NAME ")"); +#ifdef BACKPORTS_GIT_TRACKED +static char *backports_tracker_id = BACKPORTS_GIT_TRACKED; +module_param(backports_tracker_id, charp, 0400); +MODULE_PARM_DESC(backports_tracker_id, + "The version of the tree containing this backport (" BACKPORTS_GIT_TRACKED ")"); +#else +static char *backported_kernel_version = BACKPORTED_KERNEL_VERSION; +static char *backports_version = BACKPORTS_VERSION; + module_param(backported_kernel_version, charp, 0400); MODULE_PARM_DESC(backported_kernel_version, "The kernel version that was used for this backport (" BACKPORTED_KERNEL_VERSION ")"); @@ -33,6 +40,8 @@ module_param(backports_version, charp, 0400); MODULE_PARM_DESC(backports_version, "The git version of the backports tree used to generate this backport (" BACKPORTS_VERSION ")"); +#endif + void backport_dependency_symbol(void) { } @@ -45,8 +54,16 @@ static int __init backport_init(void) backport_system_workqueue_create(); backport_init_mmc_pm_flags(); - printk(KERN_INFO "Loading modules backported from " BACKPORTED_KERNEL_NAME " version " BACKPORTED_KERNEL_VERSION "\n"); + printk(KERN_INFO "Loading modules backported from " BACKPORTED_KERNEL_NAME +#ifndef BACKPORTS_GIT_TRACKED + " version " BACKPORTED_KERNEL_VERSION +#endif + "\n"); +#ifdef BACKPORTS_GIT_TRACKED + printk(KERN_INFO BACKPORTS_GIT_TRACKED "\n"); +#else printk(KERN_INFO "Backport generated by backports.git " BACKPORTS_VERSION "\n"); +#endif return 0; } diff --git a/backport/include/linux/compat-2.6.h b/backport/include/linux/compat-2.6.h index 408fc6072b4f..b19376b0f859 100644 --- a/backport/include/linux/compat-2.6.h +++ b/backport/include/linux/compat-2.6.h @@ -31,6 +31,16 @@ */ void backport_dependency_symbol(void); +#ifdef BACKPORTS_GIT_TRACKED +#define BACKPORT_MOD_VERSIONS MODULE_VERSION(BACKPORTS_GIT_TRACKED); +#else +#define BACKPORT_MOD_VERSIONS \ + MODULE_VERSION("backports: " BACKPORTS_VERSION); \ + MODULE_VERSION("backported from: " \ + BACKPORTED_KERNEL_NAME " (" \ + BACKPORTED_KERNEL_VERSION ")"); +#endif + #undef module_init #define module_init(initfn) \ static int __init __init_backport(void) \ @@ -39,10 +49,7 @@ void backport_dependency_symbol(void); return initfn(); \ } \ int init_module(void) __attribute__((alias("__init_backport")));\ - MODULE_VERSION("backports: " BACKPORTS_VERSION); \ - MODULE_VERSION("backported from: " \ - BACKPORTED_KERNEL_NAME " (" \ - BACKPORTED_KERNEL_VERSION ")"); + BACKPORT_MOD_VERSIONS /* * Each compat file represents compatibility code for new kernel diff --git a/devel/git-tracker.py b/devel/git-tracker.py index 7bf4c605de59..0771703c602a 100755 --- a/devel/git-tracker.py +++ b/devel/git-tracker.py @@ -56,8 +56,7 @@ def handle_commit(args, msg, branch, treename, kernelobjdir, tmpdir, wgitdir, ba failure = gentree.process(kernelobjdir, wdir, open(args.copy_list, 'r'), git_revision=kernel_rev, base_name=tree, logwrite=logwrite, - kernel_version_name="(see git)", - backport_version_name="(see git)") + git_tracked_version=True) newline = '\n' if failure: diff --git a/gentree.py b/gentree.py index a223b4765755..adef899c84f5 100755 --- a/gentree.py +++ b/gentree.py @@ -294,7 +294,7 @@ def _main(): def process(kerneldir, outdir, copy_list_file, git_revision=None, clean=False, refresh=False, base_name="Linux", gitdebug=False, verbose=False, extra_driver=[], logwrite=lambda x:None, - kernel_version_name=None, backport_version_name=None): + git_tracked_version=False): class Args(object): def __init__(self, kerneldir, outdir, copy_list_file, git_revision, clean, refresh, base_name, @@ -437,13 +437,19 @@ def process(kerneldir, outdir, copy_list_file, git_revision=None, git_debug_snapshot(args, "convert select to depends on") # write the versioning file - backports_version = backport_version_name or git.describe(tree=source_dir) - kernel_version = kernel_version_name or git.describe(rev=args.git_revision or 'HEAD', - tree=args.kerneldir) + if git_tracked_version: + backports_version = "(see git)" + kernel_version = "(see git)" + else: + backports_version = git.describe(tree=source_dir) + kernel_version = git.describe(rev=args.git_revision or 'HEAD', + tree=args.kerneldir) f = open(os.path.join(args.outdir, 'versions'), 'w') f.write('BACKPORTS_VERSION="%s"\n' % backports_version) f.write('BACKPORTED_KERNEL_VERSION="%s"\n' % kernel_version) f.write('BACKPORTED_KERNEL_NAME="%s"\n' % args.base_name) + if git_tracked_version: + f.write('BACKPORTS_GIT_TRACKED="backport tracker ID: $(shell git rev-parse HEAD 2>/dev/null || echo \'not built in git tree\')"\n') f.close() symbols = configtree.symbols() -- 2.30.2