gitpkgv.bbclass: Add support for extending the supported tag formats
PATCH 1/1 gitpkgv.bbclass: Add support for extending the supported tag formats
Introduce GITPKGV_TAG_REGEXP (which defaults to "v(\d.*)") to support dropping other unwanted parts of the found tags than just a leading "v". Any matching groups in the regexp will be concatenated to yield the final version.
---
In our case, the tags looks like either R1.2.3 or IR1.2.3-4, so we want to use GITPKGV_TAG_REGEXP = "(?:[vR]|IR)(\d.*)" to drop our prefixes.
meta-oe/classes/gitpkgv.bbclass | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
meta-oe/classes/gitpkgv.bbclass +10 -4
@@ -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
@@ -105,7 +111,7 @@ def get_git_pkgv(d, use_tags): output = bb.fetch2.runfetchcmd( "git --git-dir=%(repodir)s describe %(rev)s --tags --exact-match 2>/dev/null" % vars, d, quiet=True).strip() - ver = gitpkgv_drop_tag_prefix(output) + ver = gitpkgv_drop_tag_prefix(d, output) except Exception: ver = "0.0-%s-g%s" % (commits, vars['rev'][:7]) else:
Signature · 1 line
2.21.1
Please cherry-pick this to zeus.
//Peter
Quoted 67 lines
-----Original Message-----
From: [email protected] <openembedded- [email protected]> On Behalf Of Peter Kjellerstedt
Sent: den 17 januari 2020 21:34
To: [email protected]
Subject: [oe] [meta-oe][master][zeus][PATCH] gitpkgv.bbclass: Add support for extending the supported tag formatsIntroduce
GITPKGV_TAG_REGEXP(which defaults to "v(\d.*)") to support dropping other unwanted parts of the found tags than just a leading "v". Any matching groups in the regexp will be concatenated to yield the final version.Signed-off-by Peter Kjellerstedt <[email protected]>---
In our case, the tags looks like either R1.2.3 or IR1.2.3-4, so we want to use
GITPKGV_TAG_REGEXP= "(?:[vR]|IR)(\d.*)" to drop our prefixes.meta-oe/classes/gitpkgv.bbclass | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)meta- renamed from meta-oe/classes/gitpkgv.bbclass +0
-0oe/classes/gitpkgv.bbclass
indexab591bd45..180421ed3100644meta-oe/classes/gitpkgv.bbclass +1
-1@@ -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. Anymatching
meta-oe/classes/gitpkgv.bbclass +9
-5+# 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@@ -105,7 +111,7 @@ def get_git_pkgv(d, use_tags): output = bb.fetch2.runfetchcmd( "git --git-dir=%(repodir)s describe %(rev)s - -tags --exact-match 2>/dev/null" % vars, d, quiet=True).strip() - ver = gitpkgv_drop_tag_prefix(output) + ver = gitpkgv_drop_tag_prefix(d, output) except Exception: ver = "0.0-%s-g%s" % (commits, vars['rev'][:7]) else: --2.21.1
--
_______________________________________________
Openembedded-devel mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-devel