From 0f62890b388f00e4acebb2c6aab3bdf5eda3f2e3 Mon Sep 17 00:00:00 2001 From: Timo Wilken Date: Thu, 14 Mar 2024 09:54:27 +0100 Subject: [PATCH] Fix Git checkout in container This lets packages resolve Git refs in their source tree. GEANT4 needs this. --- alibuild_helpers/git.py | 6 +++++- tests/test_build.py | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/alibuild_helpers/git.py b/alibuild_helpers/git.py index 8f0717fa..b373e8db 100644 --- a/alibuild_helpers/git.py +++ b/alibuild_helpers/git.py @@ -49,7 +49,11 @@ def cloneReferenceCmd(self, source, referenceRepo, usePartialClone): def cloneSourceCmd(self, source, destination, referenceRepo, usePartialClone): cmd = ["clone", "-n", source, destination] if referenceRepo: - cmd.extend(["--reference", referenceRepo]) + # If we're building inside a Docker container, we can't refer to the + # mirror repo directly, since Git uses an absolute path. With + # "--dissociate", we still copy the objects locally, but we don't refer + # to them by path. + cmd.extend(["--dissociate", "--reference", referenceRepo]) if usePartialClone: cmd.extend(clone_speedup_options()) return cmd diff --git a/tests/test_build.py b/tests/test_build.py index 584476f1..07dfd04d 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -105,7 +105,7 @@ "/sw/MIRROR/zlib", "--filter=blob:none"), ".", False GIT_CLONE_SRC_ZLIB_ARGS = ("clone", "-n", "https://github.com/star-externals/zlib", "/sw/SOURCES/zlib/v1.2.3/8822efa61f", - "--reference", "/sw/MIRROR/zlib", "--filter=blob:none"), ".", False + "--dissociate", "--reference", "/sw/MIRROR/zlib", "--filter=blob:none"), ".", False GIT_SET_URL_ZLIB_ARGS = ("remote", "set-url", "--push", "origin", "https://github.com/star-externals/zlib"), \ "/sw/SOURCES/zlib/v1.2.3/8822efa61f", False GIT_CHECKOUT_ZLIB_ARGS = ("checkout", "-f", "master"), \ @@ -115,7 +115,7 @@ "+refs/heads/*:refs/heads/*"), "/sw/MIRROR/root", False GIT_CLONE_SRC_ROOT_ARGS = ("clone", "-n", "https://github.com/root-mirror/root", "/sw/SOURCES/ROOT/v6-08-30/f7b3366117", - "--reference", "/sw/MIRROR/root", "--filter=blob:none"), ".", False + "--dissociate", "--reference", "/sw/MIRROR/root", "--filter=blob:none"), ".", False GIT_SET_URL_ROOT_ARGS = ("remote", "set-url", "--push", "origin", "https://github.com/root-mirror/root"), \ "/sw/SOURCES/ROOT/v6-08-30/f7b3366117", False GIT_CHECKOUT_ROOT_ARGS = ("checkout", "-f", "v6-08-00-patches"), \