scripts: Add a prettier version of autolocalversion

Enable CONFIG_LOCALVERSION_BRANCH_SHA if you want to see kernel version like this:
4.14.175-F1xy-Q-raphael/2a7e9d16cd - CONFIG_LOCALVERSION-branch name-commit sha.

I had this in the build script for a few years but since there is a surge of ROMs
using my kernel it's good to have this in the kernel code for the ease of tracking
which version ROMs ship.

Signed-off-by: Yaroslav Furman <yaro330@gmail.com>
Signed-off-by: KenHV <yo@kenharris.xyz>
Signed-off-by: Forenche <prahul2003@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
This commit is contained in:
Yaroslav Furman 2020-04-04 19:31:33 +03:00 committed by azrim
parent 320116bc62
commit 3f31303623
No known key found for this signature in database
GPG Key ID: 497F8FB059B45D1C
2 changed files with 17 additions and 0 deletions

View File

@ -114,6 +114,15 @@ config LOCALVERSION_AUTO
which is done within the script "scripts/setlocalversion".)
config LOCALVERSION_BRANCH_SHA
bool "Leave only branch name and current tree"
default y
depends on LOCALVERSION_AUTO
depends on !COMPILE_TEST
help
A cleaner version of LOCALVERSION_AUTO, contains branch name
and current tree.
config HAVE_KERNEL_GZIP
bool

View File

@ -47,6 +47,14 @@ scm_version()
if test -z "$(git rev-parse --show-cdup 2>/dev/null)" &&
head=$(git rev-parse --verify HEAD 2>/dev/null); then
# Get branch name, get commit sha, leave.
if test "$CONFIG_LOCALVERSION_BRANCH_SHA" = "y"; then
branch_name=$(git rev-parse --abbrev-ref HEAD)
last_commit=$(git rev-parse --verify --short=10 HEAD)
printf '%s' "-$branch_name/$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