git tracker: add special version string to build
authorJohannes Berg <johannes.berg@intel.com>
Tue, 9 Apr 2013 21:25:50 +0000 (23:25 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 9 Apr 2013 21:45:50 +0000 (23:45 +0200)
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 <johannes.berg@intel.com>
backport/Makefile.kernel
backport/Makefile.real
backport/compat/main.c
backport/include/linux/compat-2.6.h
devel/git-tracker.py
gentree.py

index 54a121872dcf452675e5a76230b3fe1c887b988c..91e7dd6b864a0484a2d99510ed0b141a6afedecd 100644 (file)
@@ -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/
index 954fc8691d987156c602ad7e8d010824544860dd..40668c24d785bcb83b1f8c964bb8aace6c58330e 100644 (file)
@@ -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:
index 6f1bfb7518281cf9b163799a77f97a2f098e3693..7818d73aa5835efe4da4b8883bc1fdbcaac05ee4 100644 (file)
@@ -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;
 }
index 408fc6072b4fd7f9271930ec98bd7627d6dbffb4..b19376b0f8593ab026a1d6fecfc463ccc4933c86 100644 (file)
  */
 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
index 7bf4c605de598e8e66e846cd1cb236d19dc4f6c8..0771703c602a826bd2c8c04f5032c79b29578f1c 100755 (executable)
@@ -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:
index a223b4765755a2e188d3b4bbad1c9d37ef7326b4..adef899c84f5ecced602e76d2a9a3e75f092b22e 100755 (executable)
@@ -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()