From 3e53195bceafc8831b3c967d5f90d91a7d2154f8 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 22 May 2019 14:47:14 +0200 Subject: [PATCH] dracut-install: Add support for compressed kernel modules 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 | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/dracut-init.sh b/dracut-init.sh index c9043d64..e1ced79d 100644 --- a/dracut-init.sh +++ b/dracut-init.sh @@ -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*}