aboutsummaryrefslogtreecommitdiffstats
path: root/classes/gitver.bbclass
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2010-10-12 19:05:19 -0700
committerChris Larson <chris_larson@mentor.com>2010-10-13 17:20:10 -0700
commit14b7ca062d96ab6b44f1b2bd192649db36ae6263 (patch)
tree9e5e6886c85667b56760d9c091b4d00e572d4758 /classes/gitver.bbclass
parent8b2cac31bec0b97c8bc66ff3e6d2c9903f2ae8dc (diff)
downloadopenembedded-14b7ca062d96ab6b44f1b2bd192649db36ae6263.tar.gz
oe.process: pull some common bits over
Also update gitver to use the subprocess wrappers Signed-off-by: Chris Larson <chris_larson@mentor.com>
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: