summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorMike Looijmans <milo-software@users.sourceforge.net>2015-05-22 08:29:04 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-05-24 07:20:56 +0100
commit5170177719a93a69cc6c7c1218b3f26eed82d6e0 (patch)
tree620a703056494fc50847cb98d20184f9d5fc450c /bitbake
parentf03e108fb15aae76d4b6258658e6d540540214f2 (diff)
downloadpoky-5170177719a93a69cc6c7c1218b3f26eed82d6e0.tar.gz
bitbake: fetch2/git.py: Add gitpkgv_revision alternative version information
gitpkgv_revision returns a sortable revision number that can be used in the PKGV variable for example. To mimic meta-openembedded gitpkgv behaviour to provide a sortable revision numner, one could set the following: PKGV = "1.0+${@bb.fetch2.get_srcrev(d, 'gitpkgv_revision')}" This would yield a package version like "1.0+69+fb5eb80". (Bitbake rev: 989c08f62aff7b707c25c692c23284f16506b7bc) Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/fetch2/git.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py
index 45bdec0553..2e5388221f 100644
--- a/bitbake/lib/bb/fetch2/git.py
+++ b/bitbake/lib/bb/fetch2/git.py
@@ -398,6 +398,31 @@ class Git(FetchMethod):
398 def _build_revision(self, ud, d, name): 398 def _build_revision(self, ud, d, name):
399 return ud.revisions[name] 399 return ud.revisions[name]
400 400
401 def gitpkgv_revision(self, ud, d, name):
402 """
403 Return a sortable revision number by counting commits in the history
404 Based on gitpkgv.bblass in meta-openembedded
405 """
406 rev = self._build_revision(ud, d, name)
407 localpath = ud.localpath
408 rev_file = os.path.join(localpath, "oe-gitpkgv_" + rev)
409 if not os.path.exists(localpath):
410 commits = None
411 else:
412 if not os.path.exists(rev_file) or not os.path.getsize(rev_file):
413 from pipes import quote
414 commits = bb.fetch2.runfetchcmd(
415 "git rev-list %s -- | wc -l" % (quote(rev)),
416 d, quiet=True).strip().lstrip('0')
417 if commits:
418 open(rev_file, "w").write("%d\n" % int(commits))
419 else:
420 commits = open(rev_file, "r").readline(128).strip()
421 if commits:
422 return False, "%s+%s" % (commits, rev[:7])
423 else:
424 return True, str(rev)
425
401 def checkstatus(self, ud, d): 426 def checkstatus(self, ud, d):
402 try: 427 try:
403 self._lsremote(ud, d, "") 428 self._lsremote(ud, d, "")