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

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