Blame 0011-add-install-optional-and-install_optional_items.patch

Harald Hoyer e09d6b
From 54b68829b60bc3f4c28cfca1ab0336584fe1e74c Mon Sep 17 00:00:00 2001
Harald Hoyer e09d6b
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer e09d6b
Date: Tue, 22 Jul 2014 14:09:06 +0200
Harald Hoyer e09d6b
Subject: [PATCH] add "--install-optional" and install_optional_items
Harald Hoyer e09d6b
Harald Hoyer e09d6b
---
Harald Hoyer e09d6b
 dracut-bash-completion.sh         |  4 ++--
Harald Hoyer e09d6b
 dracut.8.asc                      |  3 +++
Harald Hoyer e09d6b
 dracut.conf.5.asc                 |  4 ++++
Harald Hoyer e09d6b
 dracut.conf.d/fedora.conf.example |  2 +-
Harald Hoyer e09d6b
 dracut.sh                         | 13 +++++++++++++
Harald Hoyer e09d6b
 5 files changed, 23 insertions(+), 3 deletions(-)
Harald Hoyer e09d6b
Harald Hoyer e09d6b
diff --git a/dracut-bash-completion.sh b/dracut-bash-completion.sh
Harald Hoyer e09d6b
index 9f359c6..feced60 100644
Harald Hoyer e09d6b
--- a/dracut-bash-completion.sh
Harald Hoyer e09d6b
+++ b/dracut-bash-completion.sh
Harald Hoyer e09d6b
@@ -40,7 +40,7 @@ _dracut() {
Harald Hoyer e09d6b
                               --omit-drivers --modules --omit --drivers --filesystems --install
Harald Hoyer e09d6b
                               --fwdir --libdirs --fscks --add-fstab --mount --device --nofscks
Harald Hoyer e09d6b
                               --kmoddir --conf --confdir --tmpdir --stdlog --compress --prefix
Harald Hoyer e09d6b
-                              --kernel-cmdline --sshkey --persistent-policy'
Harald Hoyer e09d6b
+                              --kernel-cmdline --sshkey --persistent-policy --install-optional'
Harald Hoyer e09d6b
         )
Harald Hoyer e09d6b
 
Harald Hoyer e09d6b
         if __contains_word "$prev" ${OPTS[ARG]}; then
Harald Hoyer e09d6b
@@ -49,7 +49,7 @@ _dracut() {
Harald Hoyer e09d6b
                                 comps=$(compgen -d -- "$cur")
Harald Hoyer e09d6b
                                 compopt -o filenames
Harald Hoyer e09d6b
                         ;;
Harald Hoyer e09d6b
-                        -c|--conf|--sshkey|--add-fstab|--add-device|-I|--install)
Harald Hoyer e09d6b
+                        -c|--conf|--sshkey|--add-fstab|--add-device|-I|--install|--install-optional)
Harald Hoyer e09d6b
                                 comps=$(compgen -f -- "$cur")
Harald Hoyer e09d6b
                                 compopt -o filenames
Harald Hoyer e09d6b
                         ;;
Harald Hoyer e09d6b
diff --git a/dracut.8.asc b/dracut.8.asc
Harald Hoyer e09d6b
index 14ce26b..51a4e9f 100644
Harald Hoyer e09d6b
--- a/dracut.8.asc
Harald Hoyer e09d6b
+++ b/dracut.8.asc
Harald Hoyer e09d6b
@@ -349,6 +349,9 @@ example:
Harald Hoyer e09d6b
 ----
Harald Hoyer e09d6b
 ===============================
Harald Hoyer e09d6b
 
Harald Hoyer e09d6b
+**--install-optional** _<file list>_::
Harald Hoyer e09d6b
+    install the space separated list of files into the initramfs, if they exist.
Harald Hoyer e09d6b
+
Harald Hoyer e09d6b
 **--gzip**::
Harald Hoyer e09d6b
     Compress the generated initramfs using gzip. This will be done by default,
Harald Hoyer e09d6b
     unless another compression option or --no-compress is passed. Equivalent to
Harald Hoyer e09d6b
diff --git a/dracut.conf.5.asc b/dracut.conf.5.asc
Harald Hoyer e09d6b
index be62da9..0b6be6a 100644
Harald Hoyer e09d6b
--- a/dracut.conf.5.asc
Harald Hoyer e09d6b
+++ b/dracut.conf.5.asc
Harald Hoyer e09d6b
@@ -66,6 +66,10 @@ Configuration files must have the extension .conf; other extensions are ignored.
Harald Hoyer e09d6b
 *install_items+=*" __<file>__[ __<file>__ ...] "::
Harald Hoyer e09d6b
     Specify additional files to include in the initramfs, separated by spaces.
Harald Hoyer e09d6b
 
Harald Hoyer e09d6b
+*install_optional_items+=*" __<file>__[ __<file>__ ...] "::
Harald Hoyer e09d6b
+    Specify additional files to include in the initramfs, separated by spaces,
Harald Hoyer e09d6b
+    if they exist.
Harald Hoyer e09d6b
+
Harald Hoyer e09d6b
 *do_strip=*"__{yes|no}__"::
Harald Hoyer e09d6b
     Strip binaries in the initramfs (default=yes)
Harald Hoyer e09d6b
 
Harald Hoyer e09d6b
diff --git a/dracut.conf.d/fedora.conf.example b/dracut.conf.d/fedora.conf.example
Harald Hoyer e09d6b
index 495e8fb..c06202b 100644
Harald Hoyer e09d6b
--- a/dracut.conf.d/fedora.conf.example
Harald Hoyer e09d6b
+++ b/dracut.conf.d/fedora.conf.example
Harald Hoyer e09d6b
@@ -6,7 +6,7 @@ i18n_default_font="latarcyrheb-sun16"
Harald Hoyer e09d6b
 i18n_install_all="yes"
Harald Hoyer e09d6b
 stdloglvl=3
Harald Hoyer e09d6b
 sysloglvl=5
Harald Hoyer e09d6b
-install_items+=" vi /etc/virc ps grep cat rm "
Harald Hoyer e09d6b
+install_optional_items+=" vi /etc/virc ps grep cat rm "
Harald Hoyer e09d6b
 prefix="/"
Harald Hoyer e09d6b
 systemdutildir=/usr/lib/systemd
Harald Hoyer e09d6b
 systemdsystemunitdir=/usr/lib/systemd/system
Harald Hoyer e09d6b
diff --git a/dracut.sh b/dracut.sh
Harald Hoyer e09d6b
index 22273a5..3e1bf44 100755
Harald Hoyer e09d6b
--- a/dracut.sh
Harald Hoyer e09d6b
+++ b/dracut.sh
Harald Hoyer e09d6b
@@ -158,6 +158,8 @@ Creates initial ramdisk images for preloading modules
Harald Hoyer e09d6b
                          in the final initramfs.
Harald Hoyer e09d6b
   -I, --install [LIST]  Install the space separated list of files into the
Harald Hoyer e09d6b
                          initramfs.
Harald Hoyer e09d6b
+  --install-optional [LIST]  Install the space separated list of files into the
Harald Hoyer e09d6b
+                         initramfs, if they exist.
Harald Hoyer e09d6b
   --gzip                Compress the generated initramfs using gzip.
Harald Hoyer e09d6b
                          This will be done by default, unless another
Harald Hoyer e09d6b
                          compression option or --no-compress is passed.
Harald Hoyer e09d6b
@@ -305,6 +307,7 @@ rearrange_params()
Harald Hoyer e09d6b
         --long drivers: \
Harald Hoyer e09d6b
         --long filesystems: \
Harald Hoyer e09d6b
         --long install: \
Harald Hoyer e09d6b
+        --long install-optional: \
Harald Hoyer e09d6b
         --long fwdir: \
Harald Hoyer e09d6b
         --long libdirs: \
Harald Hoyer e09d6b
         --long fscks: \
Harald Hoyer e09d6b
@@ -469,6 +472,9 @@ while :; do
Harald Hoyer e09d6b
         -d|--drivers)  push drivers_l            "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
Harald Hoyer e09d6b
         --filesystems) push filesystems_l        "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
Harald Hoyer e09d6b
         -I|--install)  push install_items_l      "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
Harald Hoyer e09d6b
+        --install-optional)
Harald Hoyer e09d6b
+                       push install_optional_items_l \
Harald Hoyer e09d6b
+                                                 "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
Harald Hoyer e09d6b
         --fwdir)       push fw_dir_l             "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
Harald Hoyer e09d6b
         --libdirs)     push libdirs_l            "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
Harald Hoyer e09d6b
         --fscks)       push fscks_l              "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
Harald Hoyer e09d6b
@@ -716,6 +722,12 @@ if (( ${#install_items_l[@]} )); then
Harald Hoyer e09d6b
     done
Harald Hoyer e09d6b
 fi
Harald Hoyer e09d6b
 
Harald Hoyer e09d6b
+if (( ${#install_optional_items_l[@]} )); then
Harald Hoyer e09d6b
+    while pop install_optional_items_l val; do
Harald Hoyer e09d6b
+        install_optional_items+=" $val "
Harald Hoyer e09d6b
+    done
Harald Hoyer e09d6b
+fi
Harald Hoyer e09d6b
+
Harald Hoyer e09d6b
 # these options override the stuff in the config file
Harald Hoyer e09d6b
 if (( ${#dracutmodules_l[@]} )); then
Harald Hoyer e09d6b
     dracutmodules=''
Harald Hoyer e09d6b
@@ -1317,6 +1329,7 @@ fi
Harald Hoyer e09d6b
 
Harald Hoyer e09d6b
 if [[ $kernel_only != yes ]]; then
Harald Hoyer e09d6b
     (( ${#install_items[@]} > 0 )) && inst_multiple ${install_items[@]}
Harald Hoyer e09d6b
+    (( ${#install_optional_items[@]} > 0 )) && inst_multiple -o ${install_optional_items[@]}
Harald Hoyer e09d6b
 
Harald Hoyer e09d6b
     [[ $kernel_cmdline ]] && printf "%s\n" "$kernel_cmdline" >> "${initdir}/etc/cmdline.d/01-default.conf"
Harald Hoyer e09d6b