From f5ae37fbd86c1328ebd81166573fbad3028abe5b Mon Sep 17 00:00:00 2001 From: Stefan Koch Date: Tue, 27 May 2025 11:59:02 +0200 Subject: [PATCH] bitbake: fetch2: Ensure a valid symlink in `PREMIRRORS` case when using shallow cloning - Since `ud.path` contains in that case the `PREMIRRORS` prefix path, this change ensures that a correct symlink is set up. (Bitbake rev: 37ed18e45aa17406162efc5ee3ddb2d6b33d07b9) Signed-off-by: Stefan Koch Signed-off-by: Richard Purdie --- bitbake/lib/bb/fetch2/__init__.py | 10 +++++++++- bitbake/lib/bb/fetch2/git.py | 7 +++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py index 8504678dff..0ad987c596 100644 --- a/bitbake/lib/bb/fetch2/__init__.py +++ b/bitbake/lib/bb/fetch2/__init__.py @@ -1117,7 +1117,10 @@ def try_mirror_url(fetch, origud, ud, ld, check = False): origud.method.build_mirror_data(origud, ld) return origud.localpath # Otherwise the result is a local file:// and we symlink to it - ensure_symlink(ud.localpath, origud.localpath) + # This may also be a link to a shallow archive + # When using shallow mode, add a symlink to the original fullshallow + # path to ensure a valid symlink even in the `PREMIRRORS` case + origud.method.update_mirror_links(ud, origud) update_stamp(origud, ld) return ud.localpath @@ -1653,6 +1656,11 @@ class FetchMethod(object): except FileExistsError: pass + def update_mirror_links(self, ud, origud): + # For local file:// results, create a symlink to them + # This may also be a link to a shallow archive + self.ensure_symlink(ud.localpath, origud.localpath) + def try_premirror(self, urldata, d): """ Should premirrors be used? diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py index 784a45bda2..55dd084abc 100644 --- a/bitbake/lib/bb/fetch2/git.py +++ b/bitbake/lib/bb/fetch2/git.py @@ -348,6 +348,13 @@ class Git(FetchMethod): def tarball_need_update(self, ud): return ud.write_tarballs and not os.path.exists(ud.fullmirror) + def update_mirror_links(self, ud, origud): + super().update_mirror_links(ud, origud) + # When using shallow mode, add a symlink to the original fullshallow + # path to ensure a valid symlink even in the `PREMIRRORS` case + if ud.shallow and not os.path.exists(origud.fullshallow): + self.ensure_symlink(ud.localpath, origud.fullshallow) + def try_premirror(self, ud, d): # If we don't do this, updating an existing checkout with only premirrors # is not possible