From c99a0005f8ebdc5d4e2f36a479d7971d03b948bc Mon Sep 17 00:00:00 2001 From: Yaroslav Furman Date: Sat, 4 Apr 2020 16:57:36 +0530 Subject: [PATCH] scripts: add a prettier version of autolocalversion Enable CONFIG_LOCALVERSION_COMMIT_SHA if you want to see kernel version like this: - before : 4.14.176-iMMENSITY-gb0d7253a - after : 4.14.176-iMMENSITY//4f70b3a2d0 Co-Authored-by: UtsavBalar1231 Signed-off-by: Yaroslav Furman Signed-off-by: UtsavBalar1231 --- arch/arm64/configs/raphael_defconfig | 1 + init/Kconfig | 9 +++++++++ scripts/setlocalversion | 7 +++++++ 3 files changed, 17 insertions(+) diff --git a/arch/arm64/configs/raphael_defconfig b/arch/arm64/configs/raphael_defconfig index 4cb605b1e06d..a79298da475e 100644 --- a/arch/arm64/configs/raphael_defconfig +++ b/arch/arm64/configs/raphael_defconfig @@ -51,6 +51,7 @@ CONFIG_CROSS_COMPILE="" # CONFIG_COMPILE_TEST is not set CONFIG_LOCALVERSION="-iMMENSITY" CONFIG_LOCALVERSION_AUTO=y +CONFIG_LOCALVERSION_COMMIT_SHA=y CONFIG_DEFAULT_HOSTNAME="(none)" CONFIG_SWAP=y # CONFIG_SYSVIPC is not set diff --git a/init/Kconfig b/init/Kconfig index f38d241dc9d5..ef38f5ecfb71 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -115,6 +115,15 @@ config LOCALVERSION_AUTO which is done within the script "scripts/setlocalversion".) +config LOCALVERSION_COMMIT_SHA + bool "Leave only commit sha" + default y + depends on LOCALVERSION_AUTO + depends on !COMPILE_TEST + help + A cleaner version of LOCALVERSION_AUTO, contains + commit sha of HEAD. + config HAVE_KERNEL_GZIP bool diff --git a/scripts/setlocalversion b/scripts/setlocalversion index 49f4f7c6f74c..1b2b966b452a 100755 --- a/scripts/setlocalversion +++ b/scripts/setlocalversion @@ -47,6 +47,13 @@ scm_version() if test -z "$(git rev-parse --show-cdup 2>/dev/null)" && head=`git rev-parse --verify --short HEAD 2>/dev/null`; then + # get commit sha and leave. + if test "$CONFIG_LOCALVERSION_COMMIT_SHA" = "y"; then + last_commit=$(git rev-parse --verify --short=10 HEAD) + printf '%s' "//$last_commit" + return + fi + # If we are at a tagged commit (like "v2.6.30-rc6"), we ignore # it, because this version is defined in the top level Makefile. if [ -z "`git describe --exact-match 2>/dev/null`" ]; then