diff mbox series

[ImageBuilder] Add zstd compression support

Message ID 20241217211903.5945-1-jason.andryuk@amd.com (mailing list archive)
State New
Headers show
Series [ImageBuilder] Add zstd compression support | expand

Commit Message

Jason Andryuk Dec. 17, 2024, 9:19 p.m. UTC
uboot-script-gen fails to process a zstd-compressed initramdisk, exiting
with:
Wrong file type initrd.img. It should be cpio archive, exiting.

Extend the existing approach to also check zstd.

Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
---
 scripts/uboot-script-gen | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen
index fc63702..db2c011 100755
--- a/scripts/uboot-script-gen
+++ b/scripts/uboot-script-gen
@@ -567,6 +567,7 @@  function check_compressed_file_type()
 {
     local filename=$1
     local type="$2"
+    local file_type
 
     if [ ! -f $filename ]
     then
@@ -574,13 +575,17 @@  function check_compressed_file_type()
         cleanup_and_return_err
     fi
 
-    file -L $filename | grep "gzip compressed data" &> /dev/null
-    if test $? == 0
-    then
+    file_type=$( file -L $filename )
+    if echo "$file_type" | grep -q "gzip compressed data" ; then
         local tmp=`mktemp`
         tmp_files+=($tmp)
         cat $filename | gunzip > $tmp
         filename=$tmp
+    elif echo "$file_type" | grep -q "Zstandard compressed data" ; then
+        local tmp=`mktemp`
+        tmp_files+=($tmp)
+        zstdcat $filename > $tmp
+        filename=$tmp
     fi
     check_file_type $filename "$type"
 }