gitpkgver: Update to match bitbake fetcher changes

The bitbake fetcher dropped support for multiple revisions on a single
url. Update the gitpkgver code to match.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Richard Purdie 2025-03-20 15:42:21 +00:00 committed by Khem Raj
parent cb0a43ea78
commit 2920d49092
No known key found for this signature in database
GPG Key ID: BB053355919D3314

View File

@ -70,54 +70,52 @@ def get_git_pkgv(d, use_tags):
names = [] names = []
for url in ud.values(): for url in ud.values():
if url.type == 'git' or url.type == 'gitsm': if url.type == 'git' or url.type == 'gitsm':
names.extend(url.revisions.keys()) names.extend(url.revision)
if len(names) > 0: if len(names) > 0:
format = '_'.join(names) format = '_'.join(names)
else: else:
format = 'default' format = 'default'
found = False found = False
for url in ud.values(): for url in ud.values():
if url.type == 'git' or url.type == 'gitsm': if url.type == 'git' or url.type == 'gitsm':
for name, rev in url.revisions.items(): if not os.path.exists(url.localpath):
if not os.path.exists(url.localpath): return None
return None
found = True found = True
vars = { 'repodir' : quote(url.localpath), vars = { 'repodir' : quote(url.localpath),
'rev' : quote(rev) } 'rev' : quote(url.revision) }
rev = bb.fetch2.get_srcrev(d).split('+')[1] rev = bb.fetch2.get_srcrev(d).split('+')[1]
rev_file = os.path.join(url.localpath, "oe-gitpkgv_" + rev) rev_file = os.path.join(url.localpath, "oe-gitpkgv_" + url.revision)
if not os.path.exists(rev_file) or os.path.getsize(rev_file)==0: if not os.path.exists(rev_file) or os.path.getsize(rev_file)==0:
commits = bb.fetch2.runfetchcmd( commits = bb.fetch2.runfetchcmd(
"git --git-dir=%(repodir)s rev-list %(rev)s -- 2>/dev/null | wc -l" "git --git-dir=%(repodir)s rev-list %(rev)s -- 2>/dev/null | wc -l"
% vars, d, quiet=True).strip().lstrip('0') % vars, d, quiet=True).strip().lstrip('0')
if commits != "": if commits != "":
oe.path.remove(rev_file, recurse=False) oe.path.remove(rev_file, recurse=False)
with open(rev_file, "w") as f: with open(rev_file, "w") as f:
f.write("%d\n" % int(commits)) f.write("%d\n" % int(commits))
else:
commits = "0"
else: else:
with open(rev_file, "r") as f: commits = "0"
commits = f.readline(128).strip() else:
with open(rev_file, "r") as f:
commits = f.readline(128).strip()
if use_tags: if use_tags:
try: try:
output = bb.fetch2.runfetchcmd( output = bb.fetch2.runfetchcmd(
"git --git-dir=%(repodir)s describe %(rev)s --tags --exact-match 2>/dev/null" "git --git-dir=%(repodir)s describe %(rev)s --tags --exact-match 2>/dev/null"
% vars, d, quiet=True).strip() % vars, d, quiet=True).strip()
ver = gitpkgv_drop_tag_prefix(d, output) ver = gitpkgv_drop_tag_prefix(d, output)
except Exception: except Exception:
ver = "0.0-%s-g%s" % (commits, vars['rev'][:7]) ver = "0.0-%s-g%s" % (commits, vars['rev'][:7])
else: else:
ver = "%s+%s" % (commits, vars['rev'][:7]) ver = "%s+%s" % (commits, vars['rev'][:7])
format = format.replace(name, ver) format = format.replace(url.name, ver)
if found: if found:
return format return format