]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
add support for Zstandard
authortpgxyz <tpgxyz@gmail.com>
Mon, 4 Sep 2017 23:23:38 +0000 (01:23 +0200)
committertpgxyz <tpgxyz@gmail.com>
Mon, 4 Sep 2017 23:23:38 +0000 (01:23 +0200)
dracut-bash-completion.sh
dracut-initramfs-restore.sh
dracut.8.asc
dracut.conf.5.asc
dracut.sh
lsinitrd.sh
modules.d/99img-lib/img-lib.sh
modules.d/99img-lib/module-setup.sh

index 09330a67323082214718f1f95fbf2791018e075d..89b70f29cdf653d67134b44f32144d6e82da4125 100644 (file)
@@ -29,7 +29,7 @@ _dracut() {
                               --hardlink --nohardlink --noprefix --mdadmconf --nomdadmconf
                               --lvmconf --nolvmconf --debug --profile --verbose --quiet
                               --local --hostonly --no-hostonly --fstab --help --bzip2 --lzma
-                              --xz --no-compress --gzip --list-modules --show-modules --keep
+                              --xz -zstd --no-compress --gzip --list-modules --show-modules --keep
                               --printsize --regenerate-all --noimageifnotneeded --early-microcode
                               --no-early-microcode --print-cmdline --prelink --noprelink --reproducible
                               --uefi
index 0c41a59ce0e64676dc30225a8fe58983bc6e482c..9479480490487d251aaad3a397975f24957ba75c 100644 (file)
@@ -31,6 +31,8 @@ elif $SKIP "$IMG" | xzcat | cpio -id --no-absolute-filenames --quiet >/dev/null;
     rm -f -- .need_shutdown
 elif $SKIP "$IMG" | lz4 -d -c | cpio -id --no-absolute-filenames --quiet >/dev/null; then
     rm -f -- .need_shutdown
+elif $SKIP "$IMG" | zstd -d -c | cpio -id --no-absolute-filenames --quiet >/dev/null; then
+    rm -f -- .need_shutdown
 else
     # something failed, so we clean up
     echo "Unpacking of $IMG to /run/initramfs failed" >&2
index 23c53cc4997b08ffabc4dd9ad60be7443d2d688f..64c0207f502044d2b32f088b50f71bd8039ff84b 100644 (file)
@@ -432,6 +432,14 @@ Make sure your kernel has lz4 decompression support compiled in, otherwise you
 will not be able to boot.
 ====
 
+**--zstd**::
+    Compress the generated initramfs using Zstandard.
+[WARNING]
+====
+Make sure your kernel has zstd decompression support compiled in, otherwise you
+will not be able to boot.
+====
+
 **--compress** _<compressor>_::
     Compress the generated initramfs using the passed compression program. If
     you pass it just the name of a compression program, it will call that
index 907a2fd44073ec3099e7581db4b58b209eff4b24..6e8f3ebaa43b7e70e7e35ee710b9207e667b64c3 100644 (file)
@@ -79,7 +79,7 @@ Configuration files must have the extension .conf; other extensions are ignored.
     Specify additional files to include in the initramfs, separated by spaces,
     if they exist.
 
-*compress=*"__{bzip2|lzma|xz|gzip|lzo|lz4|<compressor [args ...]>}__"::
+*compress=*"__{bzip2|lzma|xz|gzip|lzo|lz4|zstd|<compressor [args ...]>}__"::
     Compress the generated initramfs using the passed compression program. If
     you pass it just the name of a compression program, it will call that
     program with known-working arguments. If you pass arguments, it will be called
index 06127ca41ecb30a70549b8f3e20f2d2dd7e86e17..5ad0f464606dfbe2f9932ac69e3099e4d3824fb9 100755 (executable)
--- a/dracut.sh
+++ b/dracut.sh
@@ -197,6 +197,9 @@ Creates initial ramdisk images for preloading modules
   --lz4                 Compress the generated initramfs using lz4.
                          Make sure that your kernel has lz4 support compiled
                          in, otherwise you will not be able to boot.
+  --zstd                Compress the generated initramfs using Zstandard.
+                         Make sure that your kernel has zstd support compiled
+                         in, otherwise you will not be able to boot.
   --compress [COMPRESSION] Compress the generated initramfs with the
                          passed compression program.  Make sure your kernel
                          knows how to decompress the generated initramfs,
@@ -358,6 +361,7 @@ rearrange_params()
         --long xz \
         --long lzo \
         --long lz4 \
+        --long zstd \
         --long no-compress \
         --long gzip \
         --long list-modules \
@@ -557,6 +561,7 @@ while :; do
         --xz)          compress_l="xz";;
         --lzo)         compress_l="lzo";;
         --lz4)         compress_l="lz4";;
+        --zstd)        compress_l="zstd";;
         --no-compress) _no_compress_l="cat";;
         --gzip)        compress_l="gzip";;
         --list-modules) do_list="yes";;
@@ -797,7 +802,7 @@ fi
 
 if ! [[ $compress ]]; then
     # check all known compressors, if none specified
-    for i in pigz gzip lz4 lzop lzma xz lbzip2 bzip2 cat; do
+    for i in pigz gzip lz4 lzop zstd lzma xz lbzip2 bzip2 cat; do
         command -v "$i" &>/dev/null || continue
         compress="$i"
         break
@@ -837,6 +842,9 @@ case $compress in
     lz4)
         compress="lz4 -l -9"
         ;;
+    zstd)
+       compress="zstd -15 -q -T0"
+       ;;
 esac
 
 [[ $hostonly = yes ]] && hostonly="-h"
index b19a66a036f9f8289adb7b856ce43d94cc2f3088..f40884536049f8a51c31dd5fb0be8791f921d439 100755 (executable)
@@ -219,6 +219,9 @@ case $bin in
     $'\x89'LZO$'\0'*)
         CAT="lzop -d -c"
         ;;
+    $'0xFD2FB528'*)
+        CAT="zstd -d -c"
+        ;;
     *)
         if echo "test"|xz|xzcat --single-stream >/dev/null 2>&1; then
             CAT="xzcat --single-stream --"
index 48e56ce72ec3081de063795243e7ef20c8132445..437858120da421f0805d72e7a054560e77d3c635 100755 (executable)
@@ -8,12 +8,13 @@
 # works with stdin if $1 is not set.
 det_archive() {
     # NOTE: echo -e works in ash and bash, but not dash
-    local bz="BZh" xz="$(echo -e '\xfd7zXZ')" gz="$(echo -e '\x1f\x8b')"
+    local bz="BZh" xz="$(echo -e '\xfd7zXZ')" gz="$(echo -e '\x1f\x8b')" zs="$(echo -e '0xFD2FB528')"
     local headerblock="$(dd ${1:+if=$1} bs=262 count=1 2>/dev/null)"
     case "$headerblock" in
         $xz*) echo "xz" ;;
         $gz*) echo "gzip" ;;
         $bz*) echo "bzip2" ;;
+        $zs*) echo "zstd" ;;
         07070*) echo "cpio" ;;
         *ustar) echo "tar" ;;
     esac
@@ -33,7 +34,7 @@ unpack_archive() {
     local img="$1" outdir="$2" archiver="" decompr=""
     local ft="$(det_archive $img)"
     case "$ft" in
-        xz|gzip|bzip2) decompr="$ft -dc" ;;
+        xz|gzip|bzip2|zstd) decompr="$ft -dc" ;;
         cpio|tar) decompr="cat";;
         *) return 1 ;;
     esac
index 69346b2f1916baa1ffe91ddb7a84fcf0081caff5..fe1eca1a69b865b1a0bd8f9c563812d81ef74cf4 100755 (executable)
@@ -16,7 +16,7 @@ depends() {
 install() {
     inst_multiple tar gzip dd bash
     # TODO: make this conditional on a cmdline flag / config option
-    inst_multiple -o cpio xz bzip2
+    inst_multiple -o cpio xz bzip2 zstd
     inst_simple "$moddir/img-lib.sh" "/lib/img-lib.sh"
 }