summaryrefslogtreecommitdiffstats
path: root/external/meta-openembedded/meta-oe/classes/gitpkgv.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'external/meta-openembedded/meta-oe/classes/gitpkgv.bbclass')
-rw-r--r--external/meta-openembedded/meta-oe/classes/gitpkgv.bbclass29
1 files changed, 16 insertions, 13 deletions
diff --git a/external/meta-openembedded/meta-oe/classes/gitpkgv.bbclass b/external/meta-openembedded/meta-oe/classes/gitpkgv.bbclass
index 2d9680a3..180421ed 100644
--- a/external/meta-openembedded/meta-oe/classes/gitpkgv.bbclass
+++ b/external/meta-openembedded/meta-oe/classes/gitpkgv.bbclass
@@ -7,8 +7,8 @@
# NN equals the total number of revs up to SRCREV
# GITHASH is SRCREV's (full) hash
#
-# - GITPKGVTAG which is the output of 'git describe' allowing for
-# automatic versioning
+# - GITPKGVTAG which is the output of 'git describe --tags --exact-match'
+# allowing for automatic versioning
#
# gitpkgv.bbclass assumes the git repository has been cloned, and
# contains SRCREV. So ${GITPKGV} and ${GITPKGVTAG} should never be
@@ -40,10 +40,16 @@
GITPKGV = "${@get_git_pkgv(d, False)}"
GITPKGVTAG = "${@get_git_pkgv(d, True)}"
-def gitpkgv_drop_tag_prefix(version):
+# This regexp is used to drop unwanted parts of the found tags. Any matching
+# groups will be concatenated to yield the final version.
+GITPKGV_TAG_REGEXP ??= "v(\d.*)"
+
+def gitpkgv_drop_tag_prefix(d, version):
import re
- if re.match("v\d", version):
- return version[1:]
+
+ m = re.match(d.getVar('GITPKGV_TAG_REGEXP'), version)
+ if m:
+ return ''.join(group for group in m.groups() if group)
else:
return version
@@ -87,10 +93,8 @@ def get_git_pkgv(d, use_tags):
if not os.path.exists(rev_file) or os.path.getsize(rev_file)==0:
commits = bb.fetch2.runfetchcmd(
- "cd %(repodir)s && "
- "git rev-list %(rev)s -- 2> /dev/null "
- "| wc -l" % vars,
- d, quiet=True).strip().lstrip('0')
+ "git --git-dir=%(repodir)s rev-list %(rev)s -- 2>/dev/null | wc -l"
+ % vars, d, quiet=True).strip().lstrip('0')
if commits != "":
oe.path.remove(rev_file, recurse=False)
@@ -105,10 +109,9 @@ def get_git_pkgv(d, use_tags):
if use_tags:
try:
output = bb.fetch2.runfetchcmd(
- "cd %(repodir)s && "
- "git describe %(rev)s 2>/dev/null" % vars,
- d, quiet=True).strip()
- ver = gitpkgv_drop_tag_prefix(output)
+ "git --git-dir=%(repodir)s describe %(rev)s --tags --exact-match 2>/dev/null"
+ % vars, d, quiet=True).strip()
+ ver = gitpkgv_drop_tag_prefix(d, output)
except Exception:
ver = "0.0-%s-g%s" % (commits, vars['rev'][:7])
else: