Blame SOURCES/0158-grub-switch-to-blscfg.in-get-rid-of-a-bunch-of-bashi.patch

d9d99f
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
d9d99f
From: Peter Jones <pjones@redhat.com>
d9d99f
Date: Fri, 22 Jun 2018 14:01:06 -0400
d9d99f
Subject: [PATCH] grub-switch-to-blscfg.in: get rid of a bunch of bashisms
d9d99f
d9d99f
Since this says /bin/sh at the top, it should work with dash.
d9d99f
d9d99f
Signed-off-by: Peter Jones <pjones@redhat.com>
d9d99f
---
d9d99f
 util/grub-switch-to-blscfg.in | 30 +++++++++++++++---------------
d9d99f
 1 file changed, 15 insertions(+), 15 deletions(-)
d9d99f
d9d99f
diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in
b71686
index 2482483a4..dac41e738 100644
d9d99f
--- a/util/grub-switch-to-blscfg.in
d9d99f
+++ b/util/grub-switch-to-blscfg.in
d9d99f
@@ -151,18 +151,18 @@ done
d9d99f
 
d9d99f
 find_grub_cfg() {
d9d99f
     local candidate=""
d9d99f
-    while [[ -e "${candidate}" || $# -gt 0 ]]
d9d99f
+    while [ -e "${candidate}" -o $# -gt 0 ]
d9d99f
     do
d9d99f
-        if [[ ! -e "${candidate}" ]] ; then
d9d99f
+        if [ ! -e "${candidate}" ] ; then
d9d99f
             candidate="$1"
d9d99f
             shift
d9d99f
         fi
d9d99f
 
d9d99f
-        if [[ -L "${candidate}" ]]; then
d9d99f
+        if [ -L "${candidate}" ]; then
d9d99f
             candidate="$(realpath "${candidate}")"
d9d99f
         fi
d9d99f
 
d9d99f
-        if [[ -f "${candidate}" ]]; then
d9d99f
+        if [ -f "${candidate}" ]; then
d9d99f
             export GRUB_CONFIG_FILE="${candidate}"
d9d99f
             return 0
d9d99f
         fi
d9d99f
@@ -175,11 +175,11 @@ if ! find_grub_cfg ${startlink} ${grubdir}/grub.cfg ; then
d9d99f
   exit 1
d9d99f
 fi
d9d99f
 
d9d99f
-if [[ ! -d "${blsdir}" ]]; then
d9d99f
+if [ ! -d "${blsdir}" ]; then
d9d99f
     install -m 700 -d "${blsdir}"
d9d99f
 fi
d9d99f
 
d9d99f
-if [[ -f /etc/machine-id ]]; then
d9d99f
+if [ -f /etc/machine-id ]; then
d9d99f
     MACHINE_ID=$(cat /etc/machine-id)
d9d99f
 else
d9d99f
     MACHINE_ID=$(dmesg | sha256sum)
d9d99f
@@ -194,9 +194,9 @@ mkbls() {
d9d99f
     local debugid=""
d9d99f
     local flavor=""
d9d99f
 
d9d99f
-    if [[ "$kernelver" == *\+* ]] ; then
d9d99f
+    if [ "$kernelver" == *\+* ] ; then
d9d99f
         local flavor=-"${kernelver##*+}"
d9d99f
-        if [[ "${flavor}" == "-debug" ]]; then
d9d99f
+        if [ "${flavor}" == "-debug" ]; then
d9d99f
             local debugname=" with debugging"
d9d99f
             local debugid="-debug"
d9d99f
         fi
d9d99f
@@ -219,15 +219,15 @@ EOF
d9d99f
 }
d9d99f
 
d9d99f
 for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do
d9d99f
-    if [[ ! -d "/lib/modules/${kernelver}" ]] ; then
d9d99f
+    if [ ! -d "/lib/modules/${kernelver}" ] ; then
d9d99f
         continue
d9d99f
     fi
d9d99f
-    if [[ ! -f "/boot/vmlinuz-${kernelver}" ]]; then
d9d99f
+    if [ ! -f "/boot/vmlinuz-${kernelver}" ]; then
d9d99f
         continue
d9d99f
     fi
d9d99f
     bls_target="${blsdir}/${MACHINE_ID}-${kernelver}.conf"
d9d99f
     kernel_dir="/lib/modules/${kernelver}"
d9d99f
-    if [[ -f "${kernel_dir}/bls.conf" ]]; then
d9d99f
+    if [ -f "${kernel_dir}/bls.conf" ]; then
d9d99f
         cp -af "${kernel_dir}/bls.conf" "${bls_target}"
d9d99f
     else
d9d99f
         mkbls "${kernelver}" \
d9d99f
@@ -240,7 +240,7 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do
d9d99f
     linux_relpath="$("${grub_mkrelpath}" /boot/$linux)"
d9d99f
     initrd_relpath="$("${grub_mkrelpath}" /boot/$initrd)"
d9d99f
 
d9d99f
-    if [[ $linux != $linux_relpath ]]; then
d9d99f
+    if [ $linux != $linux_relpath ] ; then
d9d99f
         sed -i -e "s,^linux.*,linux ${linux_relpath},g" "${bls_target}"
d9d99f
         sed -i -e "s,^initrd.*,initrd ${initrd_relpath},g" "${bls_target}"
d9d99f
     fi
d9d99f
@@ -257,8 +257,8 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do
d9d99f
     fi
d9d99f
 done
d9d99f
 
d9d99f
-if [[ -f "/boot/vmlinuz-0-rescue-${MACHINE_ID}" ]]; then
d9d99f
-    if [[ $linux != $linux_relpath ]]; then
d9d99f
+if [ -f "/boot/vmlinuz-0-rescue-${MACHINE_ID}" ]; then
d9d99f
+    if [ $linux != $linux_relpath ]; then
d9d99f
         bootprefix="$(dirname ${linux_relpath})"
d9d99f
     fi
d9d99f
     mkbls "0-rescue-${MACHINE_ID}" "0" "${bootprefix}" >"${blsdir}/${MACHINE_ID}-0-rescue.conf"
d9d99f
@@ -282,7 +282,7 @@ elif ! grep -q '^GRUB_ENABLE_BLSCFG=.*' "${etcdefaultgrub}" ; then
d9d99f
     GENERATE=1
d9d99f
 fi
d9d99f
 
d9d99f
-if [[ "${GENERATE}" -eq 1 ]] ; then
d9d99f
+if [ "${GENERATE}" -eq 1 ] ; then
d9d99f
     cp -af "${GRUB_CONFIG_FILE}" "${GRUB_CONFIG_FILE}${backupsuffix}"
d9d99f
     if ! grub2-mkconfig -o "${GRUB_CONFIG_FILE}" ; then
d9d99f
         cp -af "${GRUB_CONFIG_FILE}${backupsuffix}" "${GRUB_CONFIG_FILE}"