From 8c7a2fec349331db9674906c0a8649326718a79e Mon Sep 17 00:00:00 2001 From: Will McVicker Date: Thu, 11 Feb 2021 11:33:42 -0800 Subject: [PATCH] ANDROID: scripts/setlocalversion: allow running in a subdir Getting the scmversion using scripts/setlocalversion currently only works when run at the root of a git or mecurial project. This was introduced in commit 8558f59edf93 ("setlocalversion: Ignote SCMs above the linux source tree") so that if one is building within a subdir of a git tree that isn't the kernel git project, then the vermagic wouldn't include that git sha1. For Android purposes, this isn't a concern. So let's bring back this functionality so that we can use scripts/setlocalversion to capture the SCM version of external modules that reside within subdirectories of an SCM project. Bug: 180027765 Link: https://lore.kernel.org/lkml/20201125010541.309848-2-willmcvicker@google.com Signed-off-by: Will McVicker Change-Id: If12ea75c6be0c0167f29f69b7cf13d1d85b7331c --- scripts/setlocalversion | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/setlocalversion b/scripts/setlocalversion index 627c6e289597..3f8a8ee14b10 100755 --- a/scripts/setlocalversion +++ b/scripts/setlocalversion @@ -64,8 +64,7 @@ scm_version() fi # Check for git and a git repo. - if test -z "$(git rev-parse --show-cdup 2>/dev/null)" && - head=$(git rev-parse --verify HEAD 2>/dev/null); then + if head=$(git rev-parse --verify HEAD 2>/dev/null); then if [ -n "$android_release" ] && [ -n "$kmi_generation" ]; then printf '%s' "-$android_release-$kmi_generation" @@ -126,7 +125,7 @@ scm_version() fi # Check for mercurial and a mercurial repo. - if test -d .hg && hgid=$(hg id 2>/dev/null); then + if hgid=$(hg id 2>/dev/null); then # Do we have an tagged version? If so, latesttagdistance == 1 if [ "$(hg log -r . --template '{latesttagdistance}')" = "1" ]; then id=$(hg log -r . --template '{latesttag}')