[Buildroot] [git commit branch/2018.11.x] support/scripts/setlocalversion: fix detection of hg revision when _not_ on branch 'default'

Peter Korsgaard peter at korsgaard.com
Mon Feb 18 16:12:41 UTC 2019


commit: https://git.buildroot.net/buildroot/commit/?id=a4fea6d9ffdc9c7e717ee0c208f1e837c5706e8c
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/2018.11.x

When Buildroot is stored in a Mercurial repository on a branch other than
'default' ('master' in git terms), setlocalversion (used to populate
/etc/os-release) will incorrectly think that this is a tagged version and
will NOT print out the revision hash.

This is due to the fact that the output of 'hg id' is assumed to be
    "<revision> <tags-if-any>"
but when on a branch it actually is:
    "<revision> (<branch>) <tags-if-any>"

To let setlocalversion receive the output it expects, explicitly ask 'hg id'
to retrieve only the revision hash and any tags, ommitting any branch
information.

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire at nokia.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni at bootlin.com>
(cherry picked from commit 57e6dcf5fbdbdd2079d92c8f6029ec7385e96e71)
Signed-off-by: Peter Korsgaard <peter at korsgaard.com>
---
 support/scripts/setlocalversion | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/support/scripts/setlocalversion b/support/scripts/setlocalversion
index 33cd605bf3..45f4283bb1 100755
--- a/support/scripts/setlocalversion
+++ b/support/scripts/setlocalversion
@@ -53,7 +53,7 @@ if head=`git rev-parse --verify --short HEAD 2>/dev/null`; then
 fi
 
 # Check for mercurial and a mercurial repo.
-if hgid=`hg id 2>/dev/null`; then
+if hgid=`hg id --id --tags 2>/dev/null`; then
 	tag=`printf '%s' "$hgid" | cut -d' ' -f2 --only-delimited`
 
 	# Do we have an untagged version?


More information about the buildroot mailing list