Blame SOURCES/0131-Add-flag-to-toggle-hostonly-cmdline-storing-in-the-i.patch

18971c
From 81c9e224820fa284806690fc64ac39c58e8760a3 Mon Sep 17 00:00:00 2001
18971c
From: Harald Hoyer <harald@redhat.com>
18971c
Date: Tue, 25 Feb 2014 12:35:32 +0100
18971c
Subject: [PATCH] Add flag to toggle hostonly cmdline storing in the initramfs
18971c
18971c
--hostonly-cmdline:
18971c
    Store kernel command line arguments needed in the initramfs
18971c
18971c
--no-hostonly-cmdline:
18971c
    Do not store kernel command line arguments needed in the initramfs
18971c
---
18971c
 dracut.8.asc                             |  6 +++++
18971c
 dracut.conf.5.asc                        |  3 +++
18971c
 dracut.sh                                | 27 ++++++++++++++++-----
18971c
 modules.d/90crypt/module-setup.sh        |  6 +++--
18971c
 modules.d/90dmraid/module-setup.sh       |  6 +++--
18971c
 modules.d/90lvm/module-setup.sh          |  6 +++--
18971c
 modules.d/90mdraid/module-setup.sh       |  6 +++--
18971c
 modules.d/95rootfs-block/module-setup.sh | 31 +++++++++++++++---------
18971c
 8 files changed, 66 insertions(+), 25 deletions(-)
18971c
18971c
diff --git a/dracut.8.asc b/dracut.8.asc
18971c
index b2946753..ba125c0d 100644
18971c
--- a/dracut.8.asc
18971c
+++ b/dracut.8.asc
18971c
@@ -294,6 +294,12 @@ provide a valid _/etc/fstab_.
18971c
 **-N, --no-hostonly**::
18971c
     Disable Host-Only mode
18971c
 
18971c
+**--hostonly-cmdline**:
18971c
+    Store kernel command line arguments needed in the initramfs
18971c
+
18971c
+**--no-hostonly-cmdline**:
18971c
+    Do not store kernel command line arguments needed in the initramfs
18971c
+
18971c
 **--persistent-policy** _<policy>_::
18971c
     Use _<policy>_ to address disks and partitions.
18971c
     _<policy>_ can be any directory name found in /dev/disk.
18971c
diff --git a/dracut.conf.5.asc b/dracut.conf.5.asc
18971c
index 5c941188..be62da98 100644
18971c
--- a/dracut.conf.5.asc
18971c
+++ b/dracut.conf.5.asc
18971c
@@ -76,6 +76,9 @@ Configuration files must have the extension .conf; other extensions are ignored.
18971c
     Host-Only mode: Install only what is needed for booting the local host
18971c
     instead of a generic host and generate host-specific configuration.
18971c
 
18971c
+*hostonly_cmdline*"__{yes|no}__"::
18971c
+    If set, store the kernel command line arguments needed in the initramfs
18971c
+
18971c
 *persistent_policy=*"__<policy>__"::
18971c
     Use _<policy>_ to address disks and partitions.
18971c
     _<policy>_ can be any directory name found in /dev/disk.
18971c
diff --git a/dracut.sh b/dracut.sh
18971c
index c4bf4ebc..1c5e6889 100755
18971c
--- a/dracut.sh
18971c
+++ b/dracut.sh
18971c
@@ -136,6 +136,10 @@ Creates initial ramdisk images for preloading modules
18971c
   -H, --hostonly        Host-Only mode: Install only what is needed for
18971c
                         booting the local host instead of a generic host.
18971c
   -N, --no-hostonly     Disables Host-Only mode
18971c
+  --hostonly-cmdline    Store kernel command line arguments needed
18971c
+                        in the initramfs
18971c
+  --no-hostonly-cmdline Do not store kernel command line arguments needed
18971c
+                        in the initramfs
18971c
   --persistent-policy [POLICY]
18971c
                         Use [POLICY] to address disks and partitions.
18971c
                         POLICY can be any directory name found in /dev/disk.
18971c
@@ -376,7 +380,8 @@ while :; do
18971c
         -a|--add)      push add_dracutmodules_l  "$2"; shift;;
18971c
         --force-add)   push force_add_dracutmodules_l  "$2"; shift;;
18971c
         --add-drivers) push add_drivers_l        "$2"; shift;;
18971c
-        --omit-drivers) push omit_drivers_l      "$2"; shift;;
18971c
+        --omit-drivers)
18971c
+                       push omit_drivers_l      "$2"; shift;;
18971c
         -m|--modules)  push dracutmodules_l      "$2"; shift;;
18971c
         -o|--omit)     push omit_dracutmodules_l "$2"; shift;;
18971c
         -d|--drivers)  push drivers_l            "$2"; shift;;
18971c
@@ -389,7 +394,8 @@ while :; do
18971c
         --mount)       push fstab_lines          "$2"; shift;;
18971c
         --add-device|--device)
18971c
                        push add_device_l         "$2"; shift;;
18971c
-        --kernel-cmdline) push kernel_cmdline_l  "$2"; shift;;
18971c
+        --kernel-cmdline)
18971c
+                       push kernel_cmdline_l  "$2"; shift;;
18971c
         --nofscks)     nofscks_l="yes";;
18971c
         --ro-mnt)      ro_mnt_l="yes";;
18971c
         -k|--kmoddir)  drivers_dir_l="$2"; shift;;
18971c
@@ -402,9 +408,12 @@ while :; do
18971c
         -f|--force)    force=yes;;
18971c
         --kernel-only) kernel_only="yes"; no_kernel="no";;
18971c
         --no-kernel)   kernel_only="no"; no_kernel="yes";;
18971c
-        --print-cmdline) print_cmdline="yes"; hostonly_l="yes"; kernel_only="yes"; no_kernel="yes";;
18971c
-        --early-microcode) early_microcode_l="yes";;
18971c
-        --no-early-microcode) early_microcode_l="no";;
18971c
+        --print-cmdline)
18971c
+                       print_cmdline="yes"; hostonly_l="yes"; kernel_only="yes"; no_kernel="yes";;
18971c
+        --early-microcode)
18971c
+                       early_microcode_l="yes";;
18971c
+        --no-early-microcode)
18971c
+                       early_microcode_l="no";;
18971c
         --strip)       do_strip_l="yes";;
18971c
         --nostrip)     do_strip_l="no";;
18971c
         --prelink)     do_prelink_l="yes";;
18971c
@@ -430,11 +439,16 @@ while :; do
18971c
                        hostonly_l="yes" ;;
18971c
         -N|--no-hostonly|--no-host-only)
18971c
                        hostonly_l="no" ;;
18971c
+        --hostonly-cmdline)
18971c
+                       hostonly_cmdline_l="yes" ;;
18971c
+        --no-hostonly-cmdline)
18971c
+                       hostonly_cmdline_l="no" ;;
18971c
         --persistent-policy)
18971c
                        persistent_policy_l="$2"; shift;;
18971c
         --fstab)       use_fstab_l="yes" ;;
18971c
         -h|--help)     long_usage; exit 1 ;;
18971c
-        -i|--include)  push include_src "$2"
18971c
+        -i|--include)
18971c
+                       push include_src "$2"
18971c
                        shift;;
18971c
         --bzip2)       compress_l="bzip2";;
18971c
         --lzma)        compress_l="lzma";;
18971c
@@ -677,6 +691,7 @@ stdloglvl=$((stdloglvl + verbosity_mod_l))
18971c
 [[ $prefix_l ]] && prefix=$prefix_l
18971c
 [[ $prefix = "/" ]] && unset prefix
18971c
 [[ $hostonly_l ]] && hostonly=$hostonly_l
18971c
+[[ $hostonly_cmdline_l ]] && hostonly_cmdline=$hostonly_cmdline_l
18971c
 [[ $persistent_policy_l ]] && persistent_policy=$persistent_policy_l
18971c
 [[ $use_fstab_l ]] && use_fstab=$use_fstab_l
18971c
 [[ $mdadmconf_l ]] && mdadmconf=$mdadmconf_l
18971c
diff --git a/modules.d/90crypt/module-setup.sh b/modules.d/90crypt/module-setup.sh
18971c
index 18583915..267d39d5 100755
18971c
--- a/modules.d/90crypt/module-setup.sh
18971c
+++ b/modules.d/90crypt/module-setup.sh
18971c
@@ -46,8 +46,10 @@ cmdline() {
18971c
 
18971c
 install() {
18971c
 
18971c
-    cmdline >> "${initdir}/etc/cmdline.d/90crypt.conf"
18971c
-    echo >> "${initdir}/etc/cmdline.d/90crypt.conf"
18971c
+    if [[ $hostonly_cmdline == "yes" ]]; then
18971c
+        cmdline >> "${initdir}/etc/cmdline.d/90crypt.conf"
18971c
+        echo >> "${initdir}/etc/cmdline.d/90crypt.conf"
18971c
+    fi
18971c
 
18971c
     inst_multiple cryptsetup rmdir readlink umount
18971c
     inst_script "$moddir"/cryptroot-ask.sh /sbin/cryptroot-ask
18971c
diff --git a/modules.d/90dmraid/module-setup.sh b/modules.d/90dmraid/module-setup.sh
18971c
index 11181cf5..b230cb0e 100755
18971c
--- a/modules.d/90dmraid/module-setup.sh
18971c
+++ b/modules.d/90dmraid/module-setup.sh
18971c
@@ -61,8 +61,10 @@ cmdline() {
18971c
 install() {
18971c
     local _i
18971c
 
18971c
-    cmdline >> "${initdir}/etc/cmdline.d/90dmraid.conf"
18971c
-    echo >> "${initdir}/etc/cmdline.d/90dmraid.conf"
18971c
+    if [[ $hostonly_cmdline == "yes" ]]; then
18971c
+        cmdline >> "${initdir}/etc/cmdline.d/90dmraid.conf"
18971c
+        echo >> "${initdir}/etc/cmdline.d/90dmraid.conf"
18971c
+    fi
18971c
 
18971c
     inst_multiple dmraid
18971c
     inst_multiple -o kpartx
18971c
diff --git a/modules.d/90lvm/module-setup.sh b/modules.d/90lvm/module-setup.sh
18971c
index f0c9b964..1c962d54 100755
18971c
--- a/modules.d/90lvm/module-setup.sh
18971c
+++ b/modules.d/90lvm/module-setup.sh
18971c
@@ -48,8 +48,10 @@ install() {
18971c
 
18971c
     inst lvm
18971c
 
18971c
-    cmdline >> "${initdir}/etc/cmdline.d/90lvm.conf"
18971c
-    echo >> "${initdir}/etc/cmdline.d/90lvm.conf"
18971c
+    if [[ $hostonly_cmdline == "yes" ]]; then
18971c
+        cmdline >> "${initdir}/etc/cmdline.d/90lvm.conf"
18971c
+        echo >> "${initdir}/etc/cmdline.d/90lvm.conf"
18971c
+    fi
18971c
 
18971c
     inst_rules "$moddir/64-lvm.rules"
18971c
 
18971c
diff --git a/modules.d/90mdraid/module-setup.sh b/modules.d/90mdraid/module-setup.sh
18971c
index 34aae1e3..1e03847f 100755
18971c
--- a/modules.d/90mdraid/module-setup.sh
18971c
+++ b/modules.d/90mdraid/module-setup.sh
18971c
@@ -65,8 +65,10 @@ install() {
18971c
     inst $(command -v partx) /sbin/partx
18971c
     inst $(command -v mdadm) /sbin/mdadm
18971c
 
18971c
-    cmdline  >> "${initdir}/etc/cmdline.d/90mdraid.conf"
18971c
-    echo  >> "${initdir}/etc/cmdline.d/90mdraid.conf"
18971c
+    if [[ $hostonly_cmdline == "yes" ]]; then
18971c
+        cmdline  >> "${initdir}/etc/cmdline.d/90mdraid.conf"
18971c
+        echo  >> "${initdir}/etc/cmdline.d/90mdraid.conf"
18971c
+    fi
18971c
 
18971c
     # 
18971c
     inst_rules 64-md-raid.rules
18971c
diff --git a/modules.d/95rootfs-block/module-setup.sh b/modules.d/95rootfs-block/module-setup.sh
18971c
index 7e714eb0..5bb704a4 100755
18971c
--- a/modules.d/95rootfs-block/module-setup.sh
18971c
+++ b/modules.d/95rootfs-block/module-setup.sh
18971c
@@ -10,17 +10,8 @@ depends() {
18971c
     echo fs-lib
18971c
 }
18971c
 
18971c
-cmdline() {
18971c
-    local dev=/dev/block/$(find_root_block_device)
18971c
-    if [ -e $dev ]; then
18971c
-        printf " root=%s" "$(shorten_persistent_dev "$(get_persistent_dev "$dev")")"
18971c
-        printf " rootflags=%s" "$(find_mp_fsopts /)"
18971c
-        printf " rootfstype=%s" "$(find_mp_fstype /)"
18971c
-    fi
18971c
-}
18971c
-
18971c
-install() {
18971c
 
18971c
+cmdline_journal() {
18971c
     if [[ $hostonly ]]; then
18971c
         for dev in "${!host_fs_types[@]}"; do
18971c
             [[ ${host_fs_types[$dev]} = "reiserfs" ]] || [[ ${host_fs_types[$dev]} = "xfs" ]] || continue
18971c
@@ -32,10 +23,28 @@ install() {
18971c
             fi
18971c
 
18971c
             if [ -n "$journaldev" ]; then
18971c
-                printf "%s\n" "root.journaldev=$journaldev" >> "${initdir}/etc/cmdline.d/95root-journaldev.conf"
18971c
+                printf " root.journaldev=%s" "$journaldev"
18971c
             fi
18971c
         done
18971c
     fi
18971c
+    return 0
18971c
+}
18971c
+
18971c
+cmdline() {
18971c
+    local dev=/dev/block/$(find_root_block_device)
18971c
+    if [ -e $dev ]; then
18971c
+        printf " root=%s" "$(shorten_persistent_dev "$(get_persistent_dev "$dev")")"
18971c
+        printf " rootflags=%s" "$(find_mp_fsopts /)"
18971c
+        printf " rootfstype=%s" "$(find_mp_fstype /)"
18971c
+    fi
18971c
+    cmdline_journal
18971c
+}
18971c
+
18971c
+install() {
18971c
+    if [[ $hostonly_cmdline == "yes" ]]; then
18971c
+        journaldev=$(cmdline_journal)
18971c
+        [[ $journaldev ]] && printf "%s\n" "$journaldev" >> "${initdir}/etc/cmdline.d/95root-journaldev.conf"
18971c
+    fi
18971c
 
18971c
     inst_multiple umount
18971c
     inst_multiple tr