backport gitver.bbclass improvements
cover backport gitver.bbclass improvements
Please consider the following changes cherry-picked from master allowing the usage of gitver.bbclass combined with EXTERNALSRC
For your convenience they are available in the git repository at:
https://github.com/amery/meta-openembedded for-pyro
Thank you
Alejandro Mery (3):
gitver: extend class to use EXTERNALSRC if set
gitver: fix broken ${GITSHA} and recursion in S when PV="${GITVER}"
gitver: skip packages instead of panic()ing if ${GITVER} fails to
expand
meta-oe/classes/gitver.bbclass | 47 +++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 19 deletions(-)
Signature · 1 line
2.13.0
PATCH 1/3 gitver: extend class to use EXTERNALSRC if set
--- meta-oe/classes/gitver.bbclass | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
meta-oe/classes/gitver.bbclass +4 -2
@@ -24,7 +24,8 @@ def get_git_pv(path, d, tagadjust=None): import os import bb.process - gitdir = os.path.abspath(os.path.join(d.getVar("S"), ".git")) + srcdir = d.getVar("EXTERNALSRC") or d.getVar("S") + gitdir = os.path.abspath(os.path.join(srcdir, ".git")) try: ver = gitrev_run("git describe --tags", gitdir) except Exception as exc:
@@ -71,5 +72,6 @@ def mark_recipe_dependencies(path, d): mark_dependency(d, tagdir) python () { - mark_recipe_dependencies(d.getVar("S"), d) + srcdir = d.getVar("EXTERNALSRC") or d.getVar("S") + mark_recipe_dependencies(srcdir, d) }
Signature · 1 line
2.13.0
Re: [meta-oe][pyro][PATCH 1/3] gitver: extend class to use EXTERNALSRC if set
in current pyro-next pull request.
thanks.
Armin
Quoted 28 lines · Alejandro Mery
Signed-off-by Alejandro Mery <[email protected]>Signed-off-by Martin Jansa <[email protected]>--- meta-oe/classes/gitver.bbclass | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)meta-oe/classes/gitver.bbclass +4
-2@@ -24,7 +24,8 @@ def get_git_pv(path, d, tagadjust=None): import os import bb.process - gitdir = os.path.abspath(os.path.join(d.getVar("S"), ".git")) + srcdir = d.getVar("EXTERNALSRC") or d.getVar("S") + gitdir = os.path.abspath(os.path.join(srcdir, ".git")) try: ver = gitrev_run("git describe --tags", gitdir) except Exception as exc:@@ -71,5 +72,6 @@ def mark_recipe_dependencies(path, d): mark_dependency(d, tagdir) python () { - mark_recipe_dependencies(d.getVar("S"), d) + srcdir = d.getVar("EXTERNALSRC") or d.getVar("S") + mark_recipe_dependencies(srcdir, d) }
PATCH 2/3 gitver: fix broken ${GITSHA} and recursion in S when PV="${GITVER}"
In reply to Alejandro Mery--- meta-oe/classes/gitver.bbclass | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
meta-oe/classes/gitver.bbclass +14 -4
@@ -13,16 +13,15 @@ def git_drop_tag_prefix(version): return version GIT_TAGADJUST = "git_drop_tag_prefix(version)" -GITVER = "${@get_git_pv('${S}', d, tagadjust=lambda version:${GIT_TAGADJUST})}" -GITSHA = "${@get_git_hash('${S}', d)}" +GITVER = "${@get_git_pv(d, tagadjust=lambda version:${GIT_TAGADJUST})}" +GITSHA = "${@get_git_hash(d)}" def gitrev_run(cmd, path): (output, error) = bb.process.run(cmd, cwd=path) return output.rstrip() -def get_git_pv(path, d, tagadjust=None): +def get_git_pv(d, tagadjust=None): import os - import bb.process srcdir = d.getVar("EXTERNALSRC") or d.getVar("S") gitdir = os.path.abspath(os.path.join(srcdir, ".git"))
@@ -46,6 +45,17 @@ def get_git_pv(path, d, tagadjust=None): ver = tagadjust(ver) return ver +def get_git_hash(d): + import os + + srcdir = d.getVar("EXTERNALSRC") or d.getVar("S") + gitdir = os.path.abspath(os.path.join(srcdir, ".git")) + try: + rev = gitrev_run("git rev-list HEAD -1") + return rev[:7] + except Exception as exc: + bb.fatal(str(exc)) + def mark_recipe_dependencies(path, d): from bb.parse import mark_dependency
Signature · 1 line
2.13.0
PATCH 3/3 gitver: skip packages instead of panic()ing if ${GITVER} fails to expand
In reply to Alejandro Meryinherit externalsrc gitver is a very useful combo to get development trees in your workspace having a ${PN}_git.bb with PV=${GITVER} coexisting with a regular ${PN}_${PV}.bb
but not everyone wants to checkout all developments sources and managinging different layers for each options is quite troublesome.
making gitver skip the .bb instead of panic()ing every time EXTERNALSRC is missing allows people to have a single development layer where packages get enabled if the right sources are present or falling back to the last release if not
--- meta-oe/classes/gitver.bbclass | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-)
meta-oe/classes/gitver.bbclass +10 -13
@@ -27,23 +27,20 @@ def get_git_pv(d, tagadjust=None): gitdir = os.path.abspath(os.path.join(srcdir, ".git")) try: ver = gitrev_run("git describe --tags", gitdir) - except Exception as exc: - bb.fatal(str(exc)) - - if not ver: + except: try: ver = gitrev_run("git rev-parse --short HEAD", gitdir) + if ver: + return "0.0+%s" % ver + else: + return "0.0" + except Exception as exc: - bb.fatal(str(exc)) + raise bb.parse.SkipPackage(str(exc)) - if ver: - return "0.0+%s" % ver - else: - return "0.0" - else: - if tagadjust: - ver = tagadjust(ver) - return ver + if ver and tagadjust: + ver = tagadjust(ver) + return ver def get_git_hash(d): import os
Signature · 1 line
2.13.0