Search
j0ke.net Open Build Service
>
Projects
>
home:jg
:
playground
>
dracut
> 0268-dracut-add-omit-driver.patch
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File 0268-dracut-add-omit-driver.patch of Package dracut
From 1fd259f340a93e6932b6a52051bbe25a7edce7f9 Mon Sep 17 00:00:00 2001 From: Harald Hoyer <harald@redhat.com> Date: Wed, 15 Feb 2012 14:53:18 +0100 Subject: [PATCH] dracut: add "--omit-driver" https://bugzilla.redhat.com/show_bug.cgi?id=722879 --- dracut | 15 ++++++++++++++- dracut-functions | 27 +++++++++++++++++++++++++-- dracut.8 | 10 ++++++++++ dracut.conf.5 | 6 ++++++ modules.d/90kernel-modules/installkernel | 2 +- 5 files changed, 56 insertions(+), 4 deletions(-) diff --git a/dracut b/dracut index 4693261..525f1ce 100755 --- a/dracut +++ b/dracut @@ -39,6 +39,8 @@ Creates initial ramdisk images for preloading modules exclusively include in the initramfs. --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. @@ -81,6 +83,7 @@ while (($# > 0)); do -a|--add) add_dracutmodules_l="$2"; shift;; -d|--drivers) drivers_l="$2"; shift;; --add-drivers) add_drivers_l="$2"; shift;; + --omit-drivers) omit_drivers_l+="$2"; shift;; --filesystems) filesystems_l="$2"; shift;; -k|--kmoddir) drivers_dir_l="$2"; shift;; --fwdir) fw_dir_l="$2"; shift;; @@ -143,6 +146,7 @@ fi # these optins add to the stuff in the config file [[ $add_dracutmodules_l ]] && add_dracutmodules+=" $add_dracutmodules_l" [[ $add_drivers_l ]] && add_drivers+=" $add_drivers_l" +[[ $omit_drivers_l ]] && omit_drivers+=" $omit_drivers_l" # these options override the stuff in the config file [[ $dracutmodules_l ]] && dracutmodules=$dracutmodules_l @@ -176,6 +180,15 @@ dracutfunctions=$dracutbasedir/dracut-functions export dracutfunctions dinfo "Executing $0 $dracut_args" + +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 + # This is kinda legacy -- eventually it should go away. case $dracutmodules in ""|auto) dracutmodules="all" ;; @@ -223,7 +236,7 @@ chmod 755 "$initdir" export initdir hookdirs dracutbasedir dracutmodules drivers \ fw_dir drivers_dir debug beverbose no_kernel kernel_only \ - add_drivers mdadmconf lvmconf filesystems + add_drivers omit_drivers mdadmconf lvmconf filesystems if [[ $kernel_only != yes ]]; then # Create some directory structure first diff --git a/dracut-functions b/dracut-functions index 5b85d84..82beb01 100755 --- a/dracut-functions +++ b/dracut-functions @@ -430,8 +430,24 @@ install_kmod_with_fw() { modname=${modname%.ko*} # 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 [[ "$_kmod" =~ $omit_drivers ]]; then + dinfo "Omitting driver $_kmod" + return 1 + fi + if [[ "${1##*/lib/modules/$kernel/}" =~ $omit_drivers ]]; then + dinfo "Omitting driver $_kmod" + return 1 + fi + fi + inst_simple "$1" "/lib/modules/$kernel/${1##*/lib/modules/$kernel/}" || \ - return $? + return $? + for fw in $(modinfo -k $kernel -F firmware $1 2>/dev/null); do found='' for fwdir in $fw_dir; do @@ -520,10 +536,17 @@ instmods() { shift; continue; ;; *) - mod=${mod##*/} # if we are already installed, skip this module and go on # to the next one. [[ -f $initdir/$1 ]] && { shift; continue; } + + mod=${mod##*/} + + if [[ $omit_drivers ]] && [[ "$1" =~ $omit_drivers ]]; then + dinfo "Omitting driver ${mod##$srcmods}" + shift; continue; + fi + # If we are building a host-specific initramfs and this # module is not already loaded, move on to the next one. [[ $hostonly ]] && ! grep -q "${mod//-/_}" /proc/modules && \ diff --git a/dracut.8 b/dracut.8 index 883e5e0..bdd8959 100644 --- a/dracut.8 +++ b/dracut.8 @@ -36,6 +36,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. .TP +.BR \-\-omit-drivers " \fILIST\fR" +specify a space-separated list of kernel modules to omit from the initramfs. +The kernel modules have to be specified without the ".ko" suffix. +Regular expressions are also allowed like ".*/fs/ocfs/.*". + +If [LIST] has multiple arguments, then you have to put these in quotes. + +example: +# dracut --omit "module1 module2" ... +.TP .BR \-\-filesystems " \fILIST\fR" specify a space-separated list of kernel filesystem modules to exclusively include in the generic initramfs. diff --git a/dracut.conf.5 b/dracut.conf.5 index a62c912..4c36710 100644 --- a/dracut.conf.5 +++ b/dracut.conf.5 @@ -33,6 +33,12 @@ Specify a space-separated list of kernel modules to add to the initramfs. The kernel modules have to be specified without the ".ko" suffix. .TP +.BR omit_drivers+= \%"[LIST]" +Specify a space-separated list of kernel +modules to omit from the initramfs. +The kernel modules have to be specified without the ".ko" suffix. +Regular expressions are also allowed like ".*/fs/foo/.* .*/fs/bar/.*". +.TP .BR filesystems+= \%"[LIST]" Specify a space-separated list of kernel filesystem modules to exclusively include in the generic diff --git a/modules.d/90kernel-modules/installkernel b/modules.d/90kernel-modules/installkernel index 2171e5a..cd51786 100755 --- a/modules.d/90kernel-modules/installkernel +++ b/modules.d/90kernel-modules/installkernel @@ -17,7 +17,7 @@ if [[ -z $drivers ]]; then # if not on hostonly mode, install all known filesystems if the required list is not set via the filesystems variable if ! [[ $hostonly ]]; then if [[ -z $filesystems ]]; then - instmods '=fs' + omit_drivers="$omit_drivers|.*/fs/ocfs/.*" instmods '=fs' # hardcoded list of exceptions # to save a lot of space rm -fr ${initdir}/lib/modules/*/kernel/fs/ocfs2 -- 1.8.3.1