nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0561-switch-to-blscfg-don-t-assume-newline-at-end-of-cfg.patch

a9bbe0
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
a9bbe0
From: Robbie Harwood <rharwood@redhat.com>
a9bbe0
Date: Tue, 18 Oct 2022 14:15:28 -0400
a9bbe0
Subject: [PATCH] switch-to-blscfg: don't assume newline at end of cfg
a9bbe0
a9bbe0
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
a9bbe0
---
a9bbe0
 util/grub-switch-to-blscfg.in | 4 +++-
a9bbe0
 1 file changed, 3 insertions(+), 1 deletion(-)
a9bbe0
a9bbe0
diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in
a9bbe0
index eeea130770..5a97954c39 100644
a9bbe0
--- a/util/grub-switch-to-blscfg.in
a9bbe0
+++ b/util/grub-switch-to-blscfg.in
a9bbe0
@@ -277,7 +277,9 @@ if grep '^GRUB_ENABLE_BLSCFG=.*' "${etcdefaultgrub}" \
a9bbe0
     fi
a9bbe0
     GENERATE=1
a9bbe0
 elif ! grep -q '^GRUB_ENABLE_BLSCFG=.*' "${etcdefaultgrub}" ; then
a9bbe0
-    if ! echo 'GRUB_ENABLE_BLSCFG=true' >> "${etcdefaultgrub}" ; then
a9bbe0
+    # prepend in case admins have been bad at newlines
a9bbe0
+    sed -i '1iGRUB_ENABLE_BLSCFG=true' "${etcdefaultgrub}"
a9bbe0
+    if ! grep -q '^GRUB_ENABLE_BLSCFG=true' "${etcdefaultgrub}" ; then
a9bbe0
         gettext_printf "Updating %s failed\n" "${etcdefaultgrub}"
a9bbe0
         exit 1
a9bbe0
     fi