mirror of
https://github.com/openembedded/meta-openembedded.git
synced 2026-06-03 02:10:04 +00:00
gitpkgv: add support SRCREV_FORMAT
In case of multiple GIT repositories are used, SRCREV_FORMAT will be respected while filling it with the proper GIT information to each revision. This new feature needed heavy changes in the code so basically it was a rewrote version that keeps compatibility with previous usage. Signed-off-by: Otavio Salvador <otavio@ossystems.com.br> Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
This commit is contained in:
committed by
Koen Kooi
parent
a67f2654a3
commit
9a9bc6e47d
@@ -51,27 +51,35 @@ def get_git_pkgv(d, use_tags):
|
|||||||
import os
|
import os
|
||||||
import bb
|
import bb
|
||||||
|
|
||||||
urls = bb.data.getVar('SRC_URI', d, 1).split()
|
src_uri = bb.data.getVar('SRC_URI', d, 1).split()
|
||||||
|
fetcher = bb.fetch2.Fetch(src_uri, d)
|
||||||
|
ud = fetcher.ud
|
||||||
|
|
||||||
for url in urls:
|
#
|
||||||
(type, host, path, user, pswd, parm) = bb.decodeurl(bb.data.expand(url, d))
|
# If SRCREV_FORMAT is set respect it for tags
|
||||||
if type in ['git']:
|
#
|
||||||
|
format = bb.data.getVar('SRCREV_FORMAT', d, True)
|
||||||
|
if not format:
|
||||||
|
format = 'default'
|
||||||
|
|
||||||
gitsrcname = '%s%s' % (host, path.replace('/', '.'))
|
found = False
|
||||||
repodir = os.path.join(bb.data.expand('${GITDIR}', d), gitsrcname)
|
for url in ud.values():
|
||||||
if not os.path.exists(repodir):
|
if url.type == 'git':
|
||||||
|
for name, rev in url.revisions.items():
|
||||||
|
if not os.path.exists(url.localpath):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
rev = bb.fetch.get_srcrev(d).split('+')[1]
|
found = True
|
||||||
|
|
||||||
cwd = os.getcwd()
|
cwd = os.getcwd()
|
||||||
os.chdir(repodir)
|
os.chdir(url.localpath)
|
||||||
|
|
||||||
commits = bb.fetch.runfetchcmd("git rev-list %s -- 2> /dev/null | wc -l" % rev, d, quiet=True).strip()
|
commits = bb.fetch2.runfetchcmd("git rev-list %s -- 2> /dev/null | wc -l" % rev, d, quiet=True).strip()
|
||||||
|
|
||||||
if use_tags:
|
if use_tags:
|
||||||
try:
|
try:
|
||||||
ver = gitpkgv_drop_tag_prefix(bb.fetch.runfetchcmd("git describe %s 2>/dev/null" % rev, d, quiet=True).strip())
|
output = bb.fetch2.runfetchcmd("git describe %s 2>/dev/null" % rev, d, quiet=True).strip()
|
||||||
|
ver = gitpkgv_drop_tag_prefix(output)
|
||||||
except Exception:
|
except Exception:
|
||||||
ver = "0.0-%s-g%s" % (commits, rev[:7])
|
ver = "0.0-%s-g%s" % (commits, rev[:7])
|
||||||
else:
|
else:
|
||||||
@@ -79,6 +87,9 @@ def get_git_pkgv(d, use_tags):
|
|||||||
|
|
||||||
os.chdir(cwd)
|
os.chdir(cwd)
|
||||||
|
|
||||||
return ver
|
format = format.replace(name, ver)
|
||||||
|
|
||||||
return "0+0"
|
if found:
|
||||||
|
return format
|
||||||
|
|
||||||
|
return '0+0'
|
||||||
|
|||||||
Reference in New Issue
Block a user