Skip to contentSkip to conversation

gitver: extend class to use EXTERNALSRC if set

PATCH New Alejandro Mery 1 participant 2 messages Jun 13, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 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
index a16429aa8..73521d538 100644
@@ -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
#1 lore raw

PATCH 2/2 gitver: fix broken ${GITSHA} and recursion in S when PV="${GITVER}"

---
 meta-oe/classes/gitver.bbclass | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
meta-oe/classes/gitver.bbclass +14 -4
index 73521d538..a09c99749 100644
@@ -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