diff options
author | Enrico Scholz <enrico.scholz@sigma-chemnitz.de> | 2012-11-16 18:11:31 +0000 |
---|---|---|
committer | Martin Jansa <Martin.Jansa@gmail.com> | 2013-01-18 10:49:44 +0100 |
commit | 1b5e1c9551406d3e5d98e0468ee140c26851ab09 (patch) | |
tree | b0a35d952aa9a511d4aafd5a064e0dd814071ab6 /meta-oe/classes | |
parent | 9fabce58acb7585664ebdded4588a283a399d22b (diff) | |
download | meta-openembedded-contrib-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.bbclass | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/meta-oe/classes/gitpkgv.bbclass b/meta-oe/classes/gitpkgv.bbclass index 165ba1e8de..7bdc538939 100644 --- a/meta-oe/classes/gitpkgv.bbclass +++ b/meta-oe/classes/gitpkgv.bbclass @@ -50,6 +50,7 @@ def gitpkgv_drop_tag_prefix(version): def get_git_pkgv(d, use_tags): import os import bb + from pipes import quote src_uri = d.getVar('SRC_URI', 1).split() fetcher = bb.fetch2.Fetch(src_uri, d) @@ -71,22 +72,39 @@ def get_git_pkgv(d, use_tags): found = True - cwd = os.getcwd() - os.chdir(url.localpath) + vars = { 'repodir' : quote(url.localpath), + 'rev' : quote(rev) } - commits = bb.fetch2.runfetchcmd("git rev-list %s -- 2> /dev/null | wc -l" % rev, d, quiet=True).strip() + rev = bb.fetch2.get_srcrev(d).split('+')[1] + rev_file = os.path.join(url.localpath, "oe-gitpkgv_" + rev) + + if not os.path.exists(rev_file) or os.path.getsize(rev_file)==0: + commits = bb.fetch2.runfetchcmd( + "cd %(repodir)s && " + "git rev-list %(rev)s -- 2> /dev/null " + "| wc -l" % vars, + d, quiet=True).strip().lstrip('0') + + if commits != "": + oe.path.remove(rev_file, recurse=False) + open(rev_file, "w").write("%d\n" % int(commits)) + else: + commits = "0" + else: + commits = open(rev_file, "r").readline(128).strip() if use_tags: try: - output = bb.fetch2.runfetchcmd("git describe %s 2>/dev/null" % rev, d, quiet=True).strip() + output = bb.fetch2.runfetchcmd( + "cd %(repodir)s && " + "git describe %(rev)s 2>/dev/null" % vars, + d, quiet=True).strip() ver = gitpkgv_drop_tag_prefix(output) except Exception: ver = "0.0-%s-g%s" % (commits, rev[:7]) else: ver = "%s+%s" % (commits, rev[:7]) - os.chdir(cwd) - format = format.replace(name, ver) if found: |