From 1ac52be1e65b69e89408a5aedc0cd1c8a8ddf539 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Mon, 7 Sep 2026 14:05:23 +0100 Subject: [PATCH] bitbake: fetch/gitsm: Store the original url data to fix relative gitsm paths If the gitsm:// url contains a git submodule with a relative "../" path and the fetcher is configured to use a premirror, it will fail as the host name encoded in the original url is lost and the correct paths can't be found. Save the original url data in the new data so that it can be consulted to fix this kind of edge case. The test case change that follows this provides a test of this functionality. (Bitbake rev: ecfde933b848b5120858b922236f57238a6e1fed) Signed-off-by: Richard Purdie (cherry picked from commit 58872250f72f5760b4126552bdec5497f5a1a1f4) Signed-off-by: Yoann Congal Signed-off-by: Paul Barker --- bitbake/lib/bb/fetch2/__init__.py | 1 + bitbake/lib/bb/fetch2/gitsm.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py index f2835397a5..e89f5be2a5 100644 --- a/bitbake/lib/bb/fetch2/__init__.py +++ b/bitbake/lib/bb/fetch2/__init__.py @@ -1011,6 +1011,7 @@ def build_mirroruris(origud, mirrors, ld): newud = FetchData(newuri, ld) newud.ignore_checksums = True newud.setup_localpath(ld) + newud.origud = ud except bb.fetch2.BBFetchException as e: logger.debug("Mirror fetch failure for url %s (original url: %s)" % (newuri, origud.url)) logger.debug(str(e)) diff --git a/bitbake/lib/bb/fetch2/gitsm.py b/bitbake/lib/bb/fetch2/gitsm.py index ef19053330..e866edeb8c 100644 --- a/bitbake/lib/bb/fetch2/gitsm.py +++ b/bitbake/lib/bb/fetch2/gitsm.py @@ -89,7 +89,10 @@ class GitSM(Git): # Convert relative to absolute uri based on parent uri if uris[m].startswith('..') or uris[m].startswith('./'): - newud = copy.copy(ud) + if hasattr(ud, "origud"): + newud = copy.copy(ud.origud) + else: + newud = copy.copy(ud) newud.path = os.path.normpath(os.path.join(newud.path, uris[m])) uris[m] = Git._get_repo_url(self, newud)