aboutsummaryrefslogtreecommitdiffstats
path: root/classes/gitver.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'classes/gitver.bbclass')
-rw-r--r--classes/gitver.bbclass28
1 files changed, 8 insertions, 20 deletions
diff --git a/classes/gitver.bbclass b/classes/gitver.bbclass
index 445067ec80..b67a017dcd 100644
--- a/classes/gitver.bbclass
+++ b/classes/gitver.bbclass
@@ -9,35 +9,23 @@
GITVER = "${@get_git_pv('${S}', d)}"
def get_git_pv(path, d, tagadjust=None):
- from subprocess import Popen, PIPE
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"))
- env = { "GIT_DIR": gitdir }
-
- def popen(cmd, **kwargs):
- kwargs["stderr"] = PIPE
- kwargs["stdout"] = PIPE
- kwargs["env"] = env
+ def git(cmd):
try:
- pipe = Popen(cmd, **kwargs)
- except OSError, e:
- #error("Execution of %s failed: %s" % (cmd, e))
- return
-
- (stdout, stderr) = pipe.communicate(None)
- if pipe.returncode != 0:
- #error("Execution of %s failed: %s" % (cmd, stderr))
- return
- return stdout.rstrip()
+ return oe_run(d, ["git"] + cmd, cwd=gitdir).rstrip()
+ except oe.process.CmdError, exc:
+ bb.fatal(str(exc))
# 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"))
- ref = popen(["git", "symbolic-ref", "HEAD"])
+ ref = git(["symbolic-ref", "HEAD"])
if ref:
reffile = os.path.join(gitdir, ref)
if os.path.exists(reffile):
@@ -54,9 +42,9 @@ def get_git_pv(path, d, tagadjust=None):
if os.path.exists(tagdir):
mark_dependency(d, tagdir)
- ver = popen(["git", "describe", "--tags"], cwd=path)
+ ver = git(["describe", "--tags"])
if not ver:
- ver = popen(["git", "rev-parse", "--short", "HEAD"], cwd=path)
+ ver = git(["rev-parse", "--short", "HEAD"])
if ver:
return "0.0-%s" % ver
else: