The bootlog in Ubuntu/Android images provide minimal information about the current HEAD from which the kernel was built. This patchset enables us to get detailed version info of the kernel.
Tested both on Ubuntu and Android images.
Patch 1 is already submitted to kernel-build ML and has been rejected. Hence review of this patchset is required w.r.t. Android/Ubuntu LEB and linux-linaro in mind.
Tushar Behera (3): kbuild: setlocalversion: ignore private tags while reporting local version kbuild: Add support to extract information about current git commit HEAD init: Add additional print for detailed kernel version
Makefile | 7 +++++-- include/linux/printk.h | 1 + init/main.c | 3 +++ init/version.c | 3 +++ scripts/setlocalversion | 5 +++-- 5 files changed, 15 insertions(+), 4 deletions(-)
Signed-off-by: Tushar Behera tushar.behera@linaro.org --- Makefile | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile index 0f66f14..7e83768 100644 --- a/Makefile +++ b/Makefile @@ -374,6 +374,7 @@ KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds # Read KERNELRELEASE from include/config/kernel.release (if it exists) KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) +KERNELVERSIONLOCAL= $(shell cat .scmversion 2> /dev/null)
export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC @@ -778,7 +779,8 @@ $(vmlinux-dirs): prepare scripts include/config/kernel.release: include/config/auto.conf FORCE $(Q)rm -f $@ $(Q)echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))" > $@ - + $(Q)rm -f .scmversion + $(Q)($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion --save-scmversion $(srctree))
# Things we need to do before we recursively start building the kernel # or the modules are listed in "prepare". @@ -829,7 +831,8 @@ define filechk_utsrelease.h echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \ exit 1; \ fi; \ - (echo #define UTS_RELEASE "$(KERNELRELEASE)";) + (echo #define UTS_RELEASE "$(KERNELRELEASE)"; \ + echo #define KERNEL_VERSION_LOCAL "$(KERNELVERSIONLOCAL)";) endef
define filechk_version.h
When CONFIG_LOCALVERSION_AUTO is not defined, kernel boot log prints only short version. This doesn't have any information regarding the commit at which the kernel was compiled.
Adding an additional print statement to explicitly tell the current HEAD.
Signed-off-by: Tushar Behera tushar.behera@linaro.org --- include/linux/printk.h | 1 + init/main.c | 3 +++ init/version.c | 3 +++ 3 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/include/linux/printk.h b/include/linux/printk.h index 9afc01e..a2560f6 100644 --- a/include/linux/printk.h +++ b/include/linux/printk.h @@ -6,6 +6,7 @@
extern const char linux_banner[]; extern const char linux_proc_banner[]; +extern const char linux_scm_version_banner[];
static inline int printk_get_level(const char *buffer) { diff --git a/init/main.c b/init/main.c index b286730..bad6b9b 100644 --- a/init/main.c +++ b/init/main.c @@ -494,6 +494,9 @@ asmlinkage void __init start_kernel(void) boot_cpu_init(); page_address_init(); printk(KERN_NOTICE "%s", linux_banner); +#if !IS_ENABLED(CONFIG_LOCALVERSION_AUTO) + printk(KERN_NOTICE "%s", linux_scm_version_banner); +#endif setup_arch(&command_line); mm_init_owner(&init_mm, &init_task); mm_init_cpumask(&init_mm); diff --git a/init/version.c b/init/version.c index 86fe0cc..e86cce9 100644 --- a/init/version.c +++ b/init/version.c @@ -46,3 +46,6 @@ const char linux_proc_banner[] = "%s version %s" " (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ")" " (" LINUX_COMPILER ") %s\n"; + +const char linux_scm_version_banner [] = + "Detailed version Linux "UTS_RELEASE "" KERNEL_VERSION_LOCAL "\n";