summaryrefslogtreecommitdiffstats
path: root/meta-oe/classes
diff options
context:
space:
mode:
authorEnrico Scholz <enrico.scholz@sigma-chemnitz.de>2012-11-16 18:11:31 +0000
committerMartin Jansa <Martin.Jansa@gmail.com>2013-01-18 10:49:44 +0100
commit1b5e1c9551406d3e5d98e0468ee140c26851ab09 (patch)
treeb0a35d952aa9a511d4aafd5a064e0dd814071ab6 /meta-oe/classes
parent9fabce58acb7585664ebdded4588a283a399d22b (diff)
downloadmeta-openembedded-1b5e1c9551406d3e5d98e0468ee140c26851ab09.tar.gz
gitpkgv.bbclass: cache GITPKGV result
gitpkgv runs the 'git rev-list | wc -l' several times when processing a package using GITPKGV. This takes ages for packages like the linux kernel which has a) a large repository and b) lots of subpackages. This patch caches the result of 'git rev-list' and uses it on the next run. Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de> Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Diffstat (limited to 'meta-oe/classes')
-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: