Blame SOURCES/0397-add-install-optional-and-install_optional_items.patch

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