]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
dracut-install: Add support for compressed kernel modules
authorTakashi Iwai <tiwai@suse.de>
Wed, 22 May 2019 12:47:14 +0000 (14:47 +0200)
committerHarald Hoyer <harald@hoyer.xyz>
Fri, 19 Jul 2019 14:17:35 +0000 (16:17 +0200)
When a module is compressed, uncompress it before packing into initrd.
Since initrd is already compressed, it makes no sense to put the
compressed module files.

The patch contains a slight refactoring and adds a helper function to
get the command for uncompressing a file per extension.

dracut-init.sh

index c9043d64b4896239ddf3ac7a5acfa58fd8bc6b97..e1ced79d91d1e365530f88dbce372a7cd2a5f7dd 100644 (file)
@@ -541,6 +541,14 @@ inst_libdir_file() {
     [[ $_files ]] && inst_multiple $_files
 }
 
+# get a command to decompress the given file
+get_decompress_cmd() {
+    case "$1" in
+        *.gz) echo 'gzip -f -d' ;;
+        *.bz2) echo 'bzip2 -d' ;;
+        *.xz) echo 'xz -f -d' ;;
+    esac
+}
 
 # install function decompressing the target and handling symlinks
 # $@ = list of compressed (gz or bz2) files or symlinks pointing to such files
@@ -552,11 +560,8 @@ inst_decompress() {
 
     for _src in $@
     do
-        case ${_src} in
-            *.gz) _cmd='gzip -f -d' ;;
-            *.bz2) _cmd='bzip2 -d' ;;
-            *) return 1 ;;
-        esac
+        _cmd=$(get_decompress_cmd ${_src})
+        [[ -z "${_cmd}" ]] && return 1
         inst_simple ${_src}
         # Decompress with chosen tool.  We assume that tool changes name e.g.
         # from 'name.gz' to 'name'.
@@ -928,6 +933,9 @@ install_kmod_with_fw() {
     inst_simple "$1" "/lib/modules/$kernel/${1##*/lib/modules/$kernel/}"
     ret=$?
     (($ret != 0)) && return $ret
+    local _cmd=$(get_decompress_cmd "$1")
+    [[ -n "${_cmd}" ]] && \
+        ${_cmd} "${initdir}/lib/modules/$kernel/${1##*/lib/modules/$kernel/}"
 
     local _modname=${1##*/} _fwdir _found _fw
     _modname=${_modname%.ko*}