From 563153ac6fd341f2105e47b246531745036de487 Mon Sep 17 00:00:00 2001 From: Simon de Vlieger Date: Fri, 7 Mar 2025 12:06:57 +0100 Subject: [PATCH] tools: support zstd in `image-info` We have images that are zstd-compresed now so `image-info` needs to be able to deal with them. Signed-off-by: Simon de Vlieger --- tools/osbuild-image-info | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/osbuild-image-info b/tools/osbuild-image-info index 11a9c3bb..a60f8553 100755 --- a/tools/osbuild-image-info +++ b/tools/osbuild-image-info @@ -2888,12 +2888,15 @@ def analyse_tarball(path): def is_compressed(path): - _, encoding = mimetypes.guess_type(path) - return encoding in ["xz", "gzip", "bzip2"] + mtype, encoding = mimetypes.guess_type(path) + + # zst files do not return an "encoding", only a mimetype so they need to be + # special cased + return encoding in ["xz", "gzip", "bzip2"] or mtype == "application/zstd" def analyse_compressed(path): - _, encoding = mimetypes.guess_type(path) + mtype, encoding = mimetypes.guess_type(path) if encoding == "xz": command = ["unxz", "--force"] @@ -2901,6 +2904,10 @@ def analyse_compressed(path): command = ["gunzip", "--force"] elif encoding == "bzip2": command = ["bunzip2", "--force"] + elif mtype == "application/zstd": + # zst files do not return an "encoding", only a mimetype so they need to be + # special cased + command = ["unzstd", "--force", "--rm"] else: raise ValueError(f"Unsupported compression: {encoding}")