dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

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

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