From: Harald Hoyer Date: Wed, 15 Feb 2012 13:53:18 +0000 (+0100) Subject: dracut: add "--omit-driver" X-Git-Tag: 016~14 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fcbcb2521c3ca7376e7846eec900eda3f74bddc1;p=thirdparty%2Fdracut.git dracut: add "--omit-driver" --- diff --git a/dracut b/dracut index fb46d7020..526594c45 100755 --- a/dracut +++ b/dracut @@ -40,8 +40,10 @@ Creates initial ramdisk images for preloading modules -a, --add [LIST] Add a space-separated list of dracut modules. -d, --drivers [LIST] Specify a space-separated list of kernel modules to exclusively include in the initramfs. - --add-drivers [LIST] Specify a space-separated list of kernel + --add-drivers [LIST] Specify a space-separated list of kernel modules to add to the initramfs. + --omit-drivers [LIST] Specify a space-separated list of kernel + modules not to add to the initramfs. --filesystems [LIST] Specify a space-separated list of kernel filesystem modules to exclusively include in the generic initramfs. @@ -210,6 +212,7 @@ while (($# > 0)); do -a|--add) push_arg add_dracutmodules_l "$@" || shift;; --force-add) push_arg force_add_dracutmodules_l "$@" || shift;; --add-drivers) push_arg add_drivers_l "$@" || shift;; + --omit-drivers) push_arg omit_drivers_l "$@" || shift;; -m|--modules) push_arg dracutmodules_l "$@" || shift;; -o|--omit) push_arg omit_dracutmodules_l "$@" || shift;; -d|--drivers) push_arg drivers_l "$@" || shift;; @@ -341,13 +344,6 @@ if (( ${#force_add_dracutmodules_l[@]} )); then done fi - -if (( ${#add_drivers_l[@]} )); then - while pop add_drivers_l val; do - add_drivers+=" $val " - done -fi - if (( ${#fscks_l[@]} )); then while pop fscks_l val; do fscks+=" $val " @@ -387,13 +383,6 @@ if (( ${#omit_dracutmodules_l[@]} )); then done fi -if (( ${#drivers_l[@]} )); then - drivers='' - while pop drivers_l val; do - drivers+="$val " - done -fi - if (( ${#filesystems_l[@]} )); then filesystems='' while pop filesystems_l val; do @@ -466,6 +455,37 @@ fi dracutfunctions=$dracutbasedir/dracut-functions export dracutfunctions +if (( ${#drivers_l[@]} )); then + drivers='' + while pop drivers_l val; do + drivers+="$val " + done +fi +drivers=${drivers/-/_} + +if (( ${#add_drivers_l[@]} )); then + while pop add_drivers_l val; do + add_drivers+=" $val " + done +fi +add_drivers=${add_drivers/-/_} + +if (( ${#omit_drivers_l[@]} )); then + while pop omit_drivers_l val; do + omit_drivers+=" $val " + done +fi +omit_drivers=${omit_drivers/-/_} + +unset omit_drivers_corrected +for d in $omit_drivers; do + strstr " $drivers $add_drivers " " $d " && continue + omit_drivers_corrected+=" $d " +done +omit_drivers=$omit_drivers_corrected +unset omit_drivers_corrected + + ddebug "Executing $0 $dracut_args" [[ $do_list = yes ]] && { @@ -604,7 +624,7 @@ done export initdir dracutbasedir dracutmodules drivers \ fw_dir drivers_dir debug no_kernel kernel_only \ - add_drivers mdadmconf lvmconf filesystems \ + add_drivers omit_drivers mdadmconf lvmconf filesystems \ use_fstab fstab_lines libdir usrlibdir fscks nofscks cttyhack \ stdloglvl sysloglvl fileloglvl kmsgloglvl logfile \ debug host_fs_types host_devs sshkey diff --git a/dracut-functions b/dracut-functions index 434ffa271..41d752e5d 100755 --- a/dracut-functions +++ b/dracut-functions @@ -927,6 +927,17 @@ install_kmod_with_fw() { # no need to go further if the module is already installed [[ -e "${initdir}/lib/modules/$kernel/${1##*/lib/modules/$kernel/}" ]] \ && return 0 + + if [[ $omit_drivers ]]; then + local _kmod=${1##*/} + _kmod=${_kmod%.ko} + _kmod=${_kmod/-/_} + if strstr " $omit_drivers " " $_kmod " ; then + dinfo "Omitting driver $_kmod" + return 1 + fi + fi + inst_simple "$1" "/lib/modules/$kernel/${1##*/lib/modules/$kernel/}" \ || return $? diff --git a/dracut.8.xml b/dracut.8.xml index 88c97c3a1..de1a0bfda 100644 --- a/dracut.8.xml +++ b/dracut.8.xml @@ -196,6 +196,20 @@ The kernel modules have to be specified without the ".ko" suffix. This + + + + + + specify a space-separated list of kernel modules not to add to the initramfs. +The kernel modules have to be specified without the ".ko" suffix. This parameter can be specified multiple times. + + If [LIST] has multiple arguments, then you have to put these in quotes. + For example: + # dracut --omit-drivers "kmodule1 kmodule2" ... + + + diff --git a/dracut.conf.5.xml b/dracut.conf.5.xml index e24078bdf..760c89257 100644 --- a/dracut.conf.5.xml +++ b/dracut.conf.5.xml @@ -82,6 +82,16 @@ The kernel modules have to be specified without the ".ko" suffix. Specify a space-separated list of kernel modules to add to the initramfs. +The kernel modules have to be specified without the ".ko" suffix. + + + + + omit_drivers+=" <kernel modules> " + + + Specify a space-separated list of kernel +modules not to add to the initramfs. The kernel modules have to be specified without the ".ko" suffix.