fetch/gitsm: Store the original url data to fix relative gitsm paths
PATCH 1/2 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.
--- lib/bb/fetch/__init__.py | 1 + lib/bb/fetch/gitsm.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-)
lib/bb/fetch/__init__.py +1 -0
@@ -1059,6 +1059,7 @@ def build_mirroruris(origud, mirrors, ld): newud.setup_localpath(ld) if hasattr(ud, 'unpack_tracer'): newud.unpack_tracer = ud.unpack_tracer + newud.origud = ud except bb.fetch.BBFetchException as e: logger.debug("Mirror fetch failure for url %s (original url: %s)" % (newuri, origud.url)) logger.debug(str(e))
lib/bb/fetch/gitsm.py +4 -1
@@ -88,7 +88,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)
PATCH 2/2 tests/fetch: Swap github grpc repo for our own small test repo
The grpc repo is 1GB in size and makes a poor choice of test repo. With github rate limiting, it is proving probematic.
Swap if for our own gitsm test repo which is smaller but can serve the purposes of the test.
--- lib/bb/tests/fetch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/tests/fetch.py +1 -1
@@ -1197,7 +1197,7 @@ class FetcherNetworkTest(FetcherTest): def test_git_submodule_restricted_network_premirrors(self): # this test is to ensure that premirrors will be tried in restricted network # that is, BB_ALLOWED_NETWORKS does not contain the domain the url uses - url = "gitsm://github.com/grpc/grpc.git;protocol=https;name=grpc;branch=v1.60.x;rev=0ef13a7555dbaadd4633399242524129eef5e231" + url = "gitsm://git.yoctoproject.org/git-submodule-test;branch=master;rev=38e61644af90dccd73c03ed3acaed98c8dda9294;branch=master;protocol=https" # create a download directory to be used as premirror later tempdir = tempfile.mkdtemp(prefix="bitbake-fetch-") dl_premirror = os.path.join(tempdir, "download-premirror")