diff mbox series

[1/1] fetch2: Ensure a valid symlink in `PREMIRRORS` case when using shallow cloning

Message ID 20250521091153.2445853-2-stefan-koch@siemens.com
State Not Applicable
Headers show
Series fetch2: Ensure a valid symlink in `PREMIRRORS` case when using shallow cloning | expand

Commit Message

Koch, Stefan May 21, 2025, 9:11 a.m. UTC
- Since `ud.path` contains in that case the `PREMIRRORS` prefix path,
  this change ensures that a correct symlink is set up.

Signed-off-by: Stefan Koch <stefan-koch@siemens.com>
---
 lib/bb/fetch2/__init__.py | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Richard Purdie May 21, 2025, 10:22 a.m. UTC | #1
On Wed, 2025-05-21 at 11:11 +0200, Stefan Koch wrote:
> - Since `ud.path` contains in that case the `PREMIRRORS` prefix path,
>   this change ensures that a correct symlink is set up.
> 
> Signed-off-by: Stefan Koch <stefan-koch@siemens.com>
> ---
>  lib/bb/fetch2/__init__.py | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py
> index 2de4f4f8c..7459adb00 100644
> --- a/lib/bb/fetch2/__init__.py
> +++ b/lib/bb/fetch2/__init__.py
> @@ -1117,7 +1117,12 @@ 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
> +        # This could also be a link to a shallow archive
>          ensure_symlink(ud.localpath, origud.localpath)
> +        # 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):
> +            ensure_symlink(ud.localpath, origud.fullshallow)
>          update_stamp(origud, ld)
>          return ud.localpath

FWIW this looks/sounds like the right fix to me. Is there a test case
we should add?

Cheers,

Richard
Koch, Stefan May 21, 2025, 4:34 p.m. UTC | #2
Hi Mathieu,

can you try PATCH v2, again? Thanks.

Regards

Stefan

On Wed, 2025-05-21 at 16:36 +0200, Mathieu Dubois-Briand via
lists.openembedded.org wrote:
> On Wed May 21, 2025 at 11:11 AM CEST, Stefan via
> lists.openembedded.org Koch wrote:
> > - Since `ud.path` contains in that case the `PREMIRRORS` prefix
> > path,
> >   this change ensures that a correct symlink is set up.
> >
> > Signed-off-by: Stefan Koch <stefan-koch@siemens.com>
> > ---
>
> Hi Stefan,
>
> Thanks for your patch.
>
> It looks like these modifications will trigger an exception in some
> cases:
>
> NOTE: Fetching uninative binary shim
> http://downloads.yoctoproject.org/releases/uninative/4.7/x86_64-nativesdk-libc-4.7.tar.xz;sha256sum=5800d4e9a129d1be09cf548918d25f74e91a7c1193ae5239d5b0c9246c486d2c
>  (will check PREMIRRORS first)
> ERROR: Execution of event handler 'uninative_event_fetchloader'
> failed
> Traceback (most recent call last):
>   File "/srv/pokybuild/yocto-worker/build-
> appliance/build/meta/classes-global/uninative.bbclass", line 80, in
> uninative_event_fetchloader
>     fetcher.download()
>   File "/srv/pokybuild/yocto-worker/build-
> appliance/build/bitbake/lib/bb/fetch2/__init__.py", line 1875, in
> download
>     done = m.try_mirrors(self, ud, self.d, mirrors)
>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>   File "/srv/pokybuild/yocto-worker/build-
> appliance/build/bitbake/lib/bb/fetch2/__init__.py", line 1672, in
> try_mirrors
>     return bool(try_mirrors(fetch, d, urldata, mirrors, check))
>                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>   File "/srv/pokybuild/yocto-worker/build-
> appliance/build/bitbake/lib/bb/fetch2/__init__.py", line 1192, in
> try_mirrors
>     ret = try_mirror_url(fetch, origud, uds[index], ld, check)
>           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>   File "/srv/pokybuild/yocto-worker/build-
> appliance/build/bitbake/lib/bb/fetch2/__init__.py", line 1124, in
> try_mirror_url
>     if ud.shallow and not os.path.exists(origud.fullshallow):
>        ^^^^^^^^^^
> AttributeError: 'FetchData' object has no attribute 'shallow'
>
> https://autobuilder.yoctoproject.org/valkyrie/#/builders/78/builds/1698
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#17626):
> https://lists.openembedded.org/g/bitbake-devel/message/17626
> Mute This Topic: https://lists.openembedded.org/mt/113226202/7767788
> Group Owner: bitbake-devel+owner@lists.openembedded.org
> Unsubscribe:
> https://lists.openembedded.org/g/bitbake-devel/unsub [stefan-koch@siemens.com
> ]
> -=-=-=-=-=-=-=-=-=-=-=-
>

--
Stefan Koch
Siemens AG
http://www.siemens.com/
diff mbox series

Patch

diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py
index 2de4f4f8c..7459adb00 100644
--- a/lib/bb/fetch2/__init__.py
+++ b/lib/bb/fetch2/__init__.py
@@ -1117,7 +1117,12 @@  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
+        # This could also be a link to a shallow archive
         ensure_symlink(ud.localpath, origud.localpath)
+        # 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):
+            ensure_symlink(ud.localpath, origud.fullshallow)
         update_stamp(origud, ld)
         return ud.localpath