diff mbox series

[meta-openembedded] gitpkgver: Update to match bitbake fetcher changes

Message ID 20250319164511.832211-1-richard.purdie@linuxfoundation.org
State Accepted
Headers show
Series [meta-openembedded] gitpkgver: Update to match bitbake fetcher changes | expand

Commit Message

Richard Purdie March 19, 2025, 4:45 p.m. UTC
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>
---
 meta-oe/classes/gitpkgv.bbclass | 73 +++++++++++++++------------------
 1 file changed, 34 insertions(+), 39 deletions(-)
diff mbox series

Patch

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