diff options
Diffstat (limited to 'meta-oe/classes')
-rw-r--r-- | meta-oe/classes/gitver.bbclass | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/meta-oe/classes/gitver.bbclass b/meta-oe/classes/gitver.bbclass index 73521d538..a09c99749 100644 --- a/meta-oe/classes/gitver.bbclass +++ b/meta-oe/classes/gitver.bbclass | |||
@@ -13,16 +13,15 @@ def git_drop_tag_prefix(version): | |||
13 | return version | 13 | return version |
14 | 14 | ||
15 | GIT_TAGADJUST = "git_drop_tag_prefix(version)" | 15 | GIT_TAGADJUST = "git_drop_tag_prefix(version)" |
16 | GITVER = "${@get_git_pv('${S}', d, tagadjust=lambda version:${GIT_TAGADJUST})}" | 16 | GITVER = "${@get_git_pv(d, tagadjust=lambda version:${GIT_TAGADJUST})}" |
17 | GITSHA = "${@get_git_hash('${S}', d)}" | 17 | GITSHA = "${@get_git_hash(d)}" |
18 | 18 | ||
19 | def gitrev_run(cmd, path): | 19 | def gitrev_run(cmd, path): |
20 | (output, error) = bb.process.run(cmd, cwd=path) | 20 | (output, error) = bb.process.run(cmd, cwd=path) |
21 | return output.rstrip() | 21 | return output.rstrip() |
22 | 22 | ||
23 | def get_git_pv(path, d, tagadjust=None): | 23 | def get_git_pv(d, tagadjust=None): |
24 | import os | 24 | import os |
25 | import bb.process | ||
26 | 25 | ||
27 | srcdir = d.getVar("EXTERNALSRC") or d.getVar("S") | 26 | srcdir = d.getVar("EXTERNALSRC") or d.getVar("S") |
28 | gitdir = os.path.abspath(os.path.join(srcdir, ".git")) | 27 | gitdir = os.path.abspath(os.path.join(srcdir, ".git")) |
@@ -46,6 +45,17 @@ def get_git_pv(path, d, tagadjust=None): | |||
46 | ver = tagadjust(ver) | 45 | ver = tagadjust(ver) |
47 | return ver | 46 | return ver |
48 | 47 | ||
48 | def get_git_hash(d): | ||
49 | import os | ||
50 | |||
51 | srcdir = d.getVar("EXTERNALSRC") or d.getVar("S") | ||
52 | gitdir = os.path.abspath(os.path.join(srcdir, ".git")) | ||
53 | try: | ||
54 | rev = gitrev_run("git rev-list HEAD -1") | ||
55 | return rev[:7] | ||
56 | except Exception as exc: | ||
57 | bb.fatal(str(exc)) | ||
58 | |||
49 | def mark_recipe_dependencies(path, d): | 59 | def mark_recipe_dependencies(path, d): |
50 | from bb.parse import mark_dependency | 60 | from bb.parse import mark_dependency |
51 | 61 | ||