]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
feat: support ZSTD-compressed kernel modules
authorMikhail Novosyolov <m.novosyolov@rosalinux.ru>
Tue, 4 May 2021 09:28:46 +0000 (12:28 +0300)
committerJóhann B. Guðmundsson <johannbg@gmail.com>
Tue, 4 May 2021 15:55:19 +0000 (15:55 +0000)
Modern Linux kernels support zstd-compressed modules, which was added
by commit 73f3d1b48f50 ("lib: Add zstd modules").

Commit c3d7ef377eb ("kbuild: add support for zstd compressed modules")
added support of compressing modules with zstd to kernel Makefiles.

libkmod >= 28 built with libzstd is also required.

dracut-init.sh
dracut.sh
install/dracut-install.c

index 93ea84044be8d93c4293138cd1a6ba5a4050b899..b6e3714a86547c4952ce45b768519e1e9dd67fef 100644 (file)
@@ -625,6 +625,7 @@ get_decompress_cmd() {
         *.gz) echo 'gzip -f -d' ;;
         *.bz2) echo 'bzip2 -d' ;;
         *.xz) echo 'xz -f -d' ;;
+        *.zst) echo 'zstd -f -d ' ;;
     esac
 }
 
index 580b082665952dfe48ecd8226f049e4973fbfe71..a7d66edb9c5a47612495091ab1efb6b65e56249f 100755 (executable)
--- a/dracut.sh
+++ b/dracut.sh
@@ -1271,6 +1271,7 @@ if [[ $no_kernel != yes ]] && [[ -d $srcmods ]]; then
             case "$_mod" in
                 *.ko.gz) kcompress=gzip ;;
                 *.ko.xz) kcompress=xz ;;
+                *.ko.zst) kcompress=zstd ;;
             esac
             if [[ $kcompress ]]; then
                 if ! command -v "$kcompress" &> /dev/null; then
index 495ed2f1dc0218e3c714e5fb8360ec034ea390d8..b4eec363ae934b3aefdfdfe936efdebbae8510f5 100644 (file)
@@ -1937,6 +1937,10 @@ static int install_modules(int argc, char **argv)
                                 int len = strlen(modname);
                                 modname[len - 6] = 0;
                         }
+                        if (endswith(modname, ".ko.zst")) {
+                                int len = strlen(modname);
+                                modname[len - 7] = 0;
+                        }
                         r = kmod_module_new_from_lookup(ctx, modname, &modlist);
                         if (r < 0) {
                                 if (!arg_optional) {