aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2010-10-27 17:22:38 -0700
committerChris Larson <chris_larson@mentor.com>2010-10-27 17:24:20 -0700
commit8264858d8c038030dcbd713cfad1f564c10e1e84 (patch)
tree79d2dda7d721cb31b6918c54fce950830beb1482
parent1a7c215aaf0ce46cbabf06fbdaa9d69b9d1ef29c (diff)
downloadopenembedded-8264858d8c038030dcbd713cfad1f564c10e1e84.tar.gz
openembedded-8264858d8c038030dcbd713cfad1f564c10e1e84.tar.bz2
openembedded-8264858d8c038030dcbd713cfad1f564c10e1e84.zip
gitver: add GITSHA variable
There's a case where git describe produces output which is not pleasant, to put it mildly, and it's better to just set PV to "0.0+${GITSHA}" or similar, including the short form of the commit hash for HEAD. Signed-off-by: Chris Larson <chris_larson@mentor.com>
-rw-r--r--classes/gitver.bbclass45
1 files changed, 32 insertions, 13 deletions
diff --git a/classes/gitver.bbclass b/classes/gitver.bbclass
index 28256c6d4c..ee8323d6f4 100644
--- a/classes/gitver.bbclass
+++ b/classes/gitver.bbclass
@@ -14,11 +14,13 @@ def git_drop_tag_prefix(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)}"
+
+def get_git_hash(path, d):
+ return oe_run(d, ["git", "rev-parse", "--short", "HEAD"], cwd=path).rstrip()
def get_git_pv(path, d, tagadjust=None):
import os
- from bb import error
- from bb.parse import mark_dependency
import oe.process
gitdir = os.path.abspath(os.path.join(d.getVar("S", True), ".git"))
@@ -28,6 +30,31 @@ def get_git_pv(path, d, tagadjust=None):
except oe.process.CmdError, exc:
bb.fatal(str(exc))
+ try:
+ ver = oe_run(d, ["git", "describe", "--tags"], cwd=gitdir).rstrip()
+ except Exception, exc:
+ bb.fatal(str(exc))
+
+ if not ver:
+ try:
+ ver = get_git_hash(gitdir, d)
+ except Exception, exc:
+ bb.fatal(str(exc))
+
+ if ver:
+ return "0.0+%s" % ver
+ else:
+ return "0.0"
+ else:
+ if tagadjust:
+ ver = tagadjust(ver)
+ return ver
+
+def mark_recipe_dependencies(path, d):
+ from bb.parse import mark_dependency
+
+ gitdir = os.path.join(path, ".git")
+
# Force the recipe to be reparsed so the version gets bumped
# if the active branch is switched, or if the branch changes.
mark_dependency(d, os.path.join(gitdir, "HEAD"))
@@ -48,14 +75,6 @@ def get_git_pv(path, d, tagadjust=None):
if os.path.exists(tagdir):
mark_dependency(d, tagdir)
- ver = git(["describe", "--tags"])
- if not ver:
- ver = git(["rev-parse", "--short", "HEAD"])
- if ver:
- return "0.0-%s" % ver
- else:
- return "0.0"
- else:
- if tagadjust:
- ver = tagadjust(ver)
- return ver
+python () {
+ mark_recipe_dependencies(d.getVar("S", True), d)
+}