summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta-oe/classes/gitpkgv.bbclass30
1 files changed, 24 insertions, 6 deletions
diff --git a/meta-oe/classes/gitpkgv.bbclass b/meta-oe/classes/gitpkgv.bbclass
index 165ba1e8d..7bdc53893 100644
--- a/meta-oe/classes/gitpkgv.bbclass
+++ b/meta-oe/classes/gitpkgv.bbclass
@@ -50,6 +50,7 @@ def gitpkgv_drop_tag_prefix(version):
50def get_git_pkgv(d, use_tags): 50def get_git_pkgv(d, use_tags):
51 import os 51 import os
52 import bb 52 import bb
53 from pipes import quote
53 54
54 src_uri = d.getVar('SRC_URI', 1).split() 55 src_uri = d.getVar('SRC_URI', 1).split()
55 fetcher = bb.fetch2.Fetch(src_uri, d) 56 fetcher = bb.fetch2.Fetch(src_uri, d)
@@ -71,22 +72,39 @@ def get_git_pkgv(d, use_tags):
71 72
72 found = True 73 found = True
73 74
74 cwd = os.getcwd() 75 vars = { 'repodir' : quote(url.localpath),
75 os.chdir(url.localpath) 76 'rev' : quote(rev) }
76 77
77 commits = bb.fetch2.runfetchcmd("git rev-list %s -- 2> /dev/null | wc -l" % rev, d, quiet=True).strip() 78 rev = bb.fetch2.get_srcrev(d).split('+')[1]
79 rev_file = os.path.join(url.localpath, "oe-gitpkgv_" + rev)
80
81 if not os.path.exists(rev_file) or os.path.getsize(rev_file)==0:
82 commits = bb.fetch2.runfetchcmd(
83 "cd %(repodir)s && "
84 "git rev-list %(rev)s -- 2> /dev/null "
85 "| wc -l" % vars,
86 d, quiet=True).strip().lstrip('0')
87
88 if commits != "":
89 oe.path.remove(rev_file, recurse=False)
90 open(rev_file, "w").write("%d\n" % int(commits))
91 else:
92 commits = "0"
93 else:
94 commits = open(rev_file, "r").readline(128).strip()
78 95
79 if use_tags: 96 if use_tags:
80 try: 97 try:
81 output = bb.fetch2.runfetchcmd("git describe %s 2>/dev/null" % rev, d, quiet=True).strip() 98 output = bb.fetch2.runfetchcmd(
99 "cd %(repodir)s && "
100 "git describe %(rev)s 2>/dev/null" % vars,
101 d, quiet=True).strip()
82 ver = gitpkgv_drop_tag_prefix(output) 102 ver = gitpkgv_drop_tag_prefix(output)
83 except Exception: 103 except Exception:
84 ver = "0.0-%s-g%s" % (commits, rev[:7]) 104 ver = "0.0-%s-g%s" % (commits, rev[:7])
85 else: 105 else:
86 ver = "%s+%s" % (commits, rev[:7]) 106 ver = "%s+%s" % (commits, rev[:7])
87 107
88 os.chdir(cwd)
89
90 format = format.replace(name, ver) 108 format = format.replace(name, ver)
91 109
92 if found: 110 if found: