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 <utsavbalar1231@gmail.com>
Signed-off-by: Yaroslav Furman <yaro330@gmail.com>
Signed-off-by: UtsavBalar1231 <utsavbalar1231@gmail.com>
This commit is contained in:
Yaroslav Furman
2020-04-04 16:57:36 +05:30
committed by UtsavBalar1231
parent 54f17b8cbe
commit c99a0005f8
3 changed files with 17 additions and 0 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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