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

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