diff mbox series

fetch2: zstd: use --force to allow decompressing symlinks

Message ID 20250708124711.3541367-1-martin.jansa@gmail.com
State New
Headers show
Series fetch2: zstd: use --force to allow decompressing symlinks | expand

Commit Message

Martin Jansa July 8, 2025, 12:47 p.m. UTC
From: Martin Jansa <martin.jansa@gmail.com>

* when some zstd compressed file was fetched from PREMIRROR using file://
  the DL_DIR will contain symlink to the file in PREMIRROR and zstd will
  refuse to decompress it

It shows an warning and creates empty file which then fails to extract with tar:

log.do_unpack then shows:
Warning : /OE/downloads/some-ver.tar.zst is a symbolic link, ignoring
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors

$ zstd --decompress --stdout /OE/downloads/some-ver.tar.zst > some-ver.tar
Warning : /OE/downloads/some-ver.tar.zst is a symbolic link, ignoring
$ file some-ver.tar
some-ver.tar: empty

Signed-off-by: Martin Jansa <martin.jansa@gmail.com>
---
 lib/bb/fetch2/__init__.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Alexander Kanavin July 8, 2025, 2:45 p.m. UTC | #1
On Tue, 8 Jul 2025 at 14:47, Martin Jansa via lists.openembedded.org
<martin.jansa=gmail.com@lists.openembedded.org> wrote:
> -                cmd = 'zstd --decompress --stdout %s | %s -f -' % (file, tar_cmd)
> +                cmd = 'zstd --force --decompress --stdout %s | %s -f -' % (file, tar_cmd)
>              elif file.endswith('.zst'):
> -                cmd = 'zstd --decompress --stdout %s > %s' % (file, efile)
> +                cmd = 'zstd --force --decompress --stdout %s > %s' % (file, efile)


       •   -f, --force: disable input and output checks. Allows
overwriting existing files, input from console, output to stdout,
operating on links, block devices, etc. During decompression and when
the output
           destination is stdout, pass-through unrecognized formats as-is.

I'm not sure using this --force option to fix this one particular
issue is right. It will mask other problems that should stop the build
at the decompression point.

Alex
diff mbox series

Patch

diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py
index 0ad987c59..b3bf4d0b0 100644
--- a/lib/bb/fetch2/__init__.py
+++ b/lib/bb/fetch2/__init__.py
@@ -1547,9 +1547,9 @@  class FetchMethod(object):
             elif file.endswith('.7z'):
                 cmd = '7za x -y %s 1>/dev/null' % file
             elif file.endswith('.tzst') or file.endswith('.tar.zst'):
-                cmd = 'zstd --decompress --stdout %s | %s -f -' % (file, tar_cmd)
+                cmd = 'zstd --force --decompress --stdout %s | %s -f -' % (file, tar_cmd)
             elif file.endswith('.zst'):
-                cmd = 'zstd --decompress --stdout %s > %s' % (file, efile)
+                cmd = 'zstd --force --decompress --stdout %s > %s' % (file, efile)
             elif file.endswith('.zip') or file.endswith('.jar'):
                 try:
                     dos = bb.utils.to_boolean(urldata.parm.get('dos'), False)