]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
add "--install-optional" and install_optional_items
authorHarald Hoyer <harald@redhat.com>
Tue, 22 Jul 2014 12:09:06 +0000 (14:09 +0200)
committerHarald Hoyer <harald@redhat.com>
Wed, 29 Jun 2016 09:28:23 +0000 (11:28 +0200)
(cherry picked from commit 54b68829b60bc3f4c28cfca1ab0336584fe1e74c)

dracut-bash-completion.sh
dracut.8.asc
dracut.conf.5.asc
dracut.conf.d/fedora.conf.example
dracut.sh

index 9f359c6e8cf0e7672416d72dbbb5ef146230d6af..feced605af0f6cf9b993b88aadefd1ac34825ae2 100644 (file)
@@ -40,7 +40,7 @@ _dracut() {
                               --omit-drivers --modules --omit --drivers --filesystems --install
                               --fwdir --libdirs --fscks --add-fstab --mount --device --nofscks
                               --kmoddir --conf --confdir --tmpdir --stdlog --compress --prefix
-                              --kernel-cmdline --sshkey --persistent-policy'
+                              --kernel-cmdline --sshkey --persistent-policy --install-optional'
         )
 
         if __contains_word "$prev" ${OPTS[ARG]}; then
@@ -49,7 +49,7 @@ _dracut() {
                                 comps=$(compgen -d -- "$cur")
                                 compopt -o filenames
                         ;;
-                        -c|--conf|--sshkey|--add-fstab|--add-device|-I|--install)
+                        -c|--conf|--sshkey|--add-fstab|--add-device|-I|--install|--install-optional)
                                 comps=$(compgen -f -- "$cur")
                                 compopt -o filenames
                         ;;
index 5f68d16af3a9ac9c235711c047c4ad25b18eb0d8..8fd863b92c22325d83e6048f1afca366aea95f0d 100644 (file)
@@ -355,6 +355,9 @@ example:
 ----
 ===============================
 
+**--install-optional** _<file list>_::
+    install the space separated list of files into the initramfs, if they exist.
+
 **--gzip**::
     Compress the generated initramfs using gzip. This will be done by default,
     unless another compression option or --no-compress is passed. Equivalent to
index 99f70fff2b570f625b670e10169a3345cfd611ed..c20a341dceff40031637f528ed5812cec9900a12 100644 (file)
@@ -66,6 +66,10 @@ Configuration files must have the extension .conf; other extensions are ignored.
 *install_items+=*" __<file>__[ __<file>__ ...] "::
     Specify additional files to include in the initramfs, separated by spaces.
 
+*install_optional_items+=*" __<file>__[ __<file>__ ...] "::
+    Specify additional files to include in the initramfs, separated by spaces,
+    if they exist.
+
 *do_strip=*"__{yes|no}__"::
     Strip binaries in the initramfs (default=yes)
 
index ff4e3b27183245ab940791000292b344ce792e7e..d69c943b5f34979150b375b7b36b654dd9506568 100644 (file)
@@ -6,7 +6,7 @@ i18n_default_font="latarcyrheb-sun16"
 i18n_install_all="yes"
 stdloglvl=3
 sysloglvl=5
-install_items+=" vi /etc/virc ps grep cat rm "
+install_optional_items+=" vi /etc/virc ps grep cat rm "
 prefix="/"
 systemdutildir=/usr/lib/systemd
 systemdsystemunitdir=/usr/lib/systemd/system
index 7897679235487d8a2fb8ab2f66888f0feece06dd..fefdefd531c943f1f8b62231c2e39813e5689415 100755 (executable)
--- a/dracut.sh
+++ b/dracut.sh
@@ -158,6 +158,8 @@ Creates initial ramdisk images for preloading modules
                          in the final initramfs.
   -I, --install [LIST]  Install the space separated list of files into the
                          initramfs.
+  --install-optional [LIST]  Install the space separated list of files into the
+                         initramfs, if they exist.
   --gzip                Compress the generated initramfs using gzip.
                          This will be done by default, unless another
                          compression option or --no-compress is passed.
@@ -305,6 +307,7 @@ rearrange_params()
         --long drivers: \
         --long filesystems: \
         --long install: \
+        --long install-optional: \
         --long fwdir: \
         --long libdirs: \
         --long fscks: \
@@ -471,6 +474,9 @@ while :; do
         -d|--drivers)  push drivers_l            "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
         --filesystems) push filesystems_l        "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
         -I|--install)  push install_items_l      "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
+        --install-optional)
+                       push install_optional_items_l \
+                                                 "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
         --fwdir)       push fw_dir_l             "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
         --libdirs)     push libdirs_l            "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
         --fscks)       push fscks_l              "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
@@ -722,6 +728,12 @@ if (( ${#install_items_l[@]} )); then
     done
 fi
 
+if (( ${#install_optional_items_l[@]} )); then
+    while pop install_optional_items_l val; do
+        install_optional_items+=" $val "
+    done
+fi
+
 # these options override the stuff in the config file
 if (( ${#dracutmodules_l[@]} )); then
     dracutmodules=''
@@ -1361,6 +1373,7 @@ fi
 
 if [[ $kernel_only != yes ]]; then
     (( ${#install_items[@]} > 0 )) && inst_multiple ${install_items[@]}
+    (( ${#install_optional_items[@]} > 0 )) && inst_multiple -o ${install_optional_items[@]}
 
     [[ $kernel_cmdline ]] && printf "%s\n" "$kernel_cmdline" >> "${initdir}/etc/cmdline.d/01-default.conf"