mirror of
https://src.fedoraproject.org/rpms/grub2.git
synced 2024-11-28 07:44:52 +00:00
Make the grub-switch-to-blscfg and 10_linux scripts more robust
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
This commit is contained in:
parent
7509e59c4a
commit
5b188159a7
4 changed files with 91 additions and 1 deletions
|
@ -0,0 +1,46 @@
|
||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||||
|
Date: Thu, 16 Apr 2020 18:53:03 +0200
|
||||||
|
Subject: [PATCH] grub-switch-to-blscfg: Use install to copy GRUB binary,
|
||||||
|
modules and config
|
||||||
|
|
||||||
|
By default the cp command truncates the destination before copying from the
|
||||||
|
source, so if interrupted it can lead to a file that's half written.
|
||||||
|
|
||||||
|
This behavior can be modified using the --remove-destination option, but is
|
||||||
|
usually a better choice to use the install tool for this. So let's do that.
|
||||||
|
|
||||||
|
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||||
|
---
|
||||||
|
util/grub-switch-to-blscfg.in | 6 +++---
|
||||||
|
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in
|
||||||
|
index 4bbed8e4fe9..3333a620c28 100644
|
||||||
|
--- a/util/grub-switch-to-blscfg.in
|
||||||
|
+++ b/util/grub-switch-to-blscfg.in
|
||||||
|
@@ -273,7 +273,7 @@ copy_bls() {
|
||||||
|
if test -f /run/ostree-booted && test -d /sys/firmware/efi/efivars && \
|
||||||
|
! ${grub_editenv} - list | grep -q blsdir; then
|
||||||
|
grub_binary="$(find /usr/lib/ostree-boot/efi/EFI/${EFIDIR}/ -name grub*.efi)"
|
||||||
|
- cp ${grub_binary} ${grubdir} || exit 1
|
||||||
|
+ install -m 700 ${grub_binary} ${grubdir} || exit 1
|
||||||
|
# Create a hidden file to indicate that grub2 now has BLS support.
|
||||||
|
touch /boot/grub2/.grub2-blscfg-supported
|
||||||
|
fi
|
||||||
|
@@ -307,13 +307,13 @@ if [ "${GENERATE}" -eq 1 ] ; then
|
||||||
|
|
||||||
|
if [ -n "${mod_dir}" ]; then
|
||||||
|
for mod in blscfg increment; do
|
||||||
|
- cp ${prefix}/lib/grub/${mod_dir}/${mod}.mod ${grubdir}/$mod_dir/ || exit 1
|
||||||
|
+ install -m 700 ${prefix}/lib/grub/${mod_dir}/${mod}.mod ${grubdir}/$mod_dir/ || exit 1
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
cp -af "${GRUB_CONFIG_FILE}" "${GRUB_CONFIG_FILE}${backupsuffix}"
|
||||||
|
if ! grub2-mkconfig -o "${GRUB_CONFIG_FILE}" ; then
|
||||||
|
- cp -af "${GRUB_CONFIG_FILE}${backupsuffix}" "${GRUB_CONFIG_FILE}"
|
||||||
|
+ install -m 700 "${GRUB_CONFIG_FILE}${backupsuffix}" "${GRUB_CONFIG_FILE}"
|
||||||
|
sed -i"${backupsuffix}" \
|
||||||
|
-e 's,^GRUB_ENABLE_BLSCFG=.*,GRUB_ENABLE_BLSCFG=false,' \
|
||||||
|
"${etcdefaultgrub}"
|
|
@ -0,0 +1,39 @@
|
||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||||
|
Date: Thu, 16 Apr 2020 18:53:05 +0200
|
||||||
|
Subject: [PATCH] 10_linux.in: Enable BLS configuration if new-kernel-pkg isn't
|
||||||
|
present
|
||||||
|
|
||||||
|
Currently if the the GRUB_ENABLE_BLSCFG option in /etc/default/grub hasn't
|
||||||
|
been set, the 10_linux script will generate a GRUB configuration that does
|
||||||
|
not include the blscfg command to populate the menu entries from BLS files.
|
||||||
|
|
||||||
|
But on kernel install the /usr/lib/kernel/install.d/20-grub.install script
|
||||||
|
will only add menuentry commands to the GRUB config file if the old grubby
|
||||||
|
tool and new-kernel-pkg script are installed.
|
||||||
|
|
||||||
|
So a configuration with the GRUB_ENABLE_BLSCFG option will lead to a setup
|
||||||
|
where new kernel entries are not added. Make a BLS config the default if
|
||||||
|
that option wasn't set and the new-kernel-pkg script is not present.
|
||||||
|
|
||||||
|
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||||
|
---
|
||||||
|
util/grub.d/10_linux.in | 5 +++++
|
||||||
|
1 file changed, 5 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
|
||||||
|
index c72cc3246bb..847646bd8a8 100644
|
||||||
|
--- a/util/grub.d/10_linux.in
|
||||||
|
+++ b/util/grub.d/10_linux.in
|
||||||
|
@@ -164,6 +164,11 @@ populate_menu()
|
||||||
|
printf "$menu"
|
||||||
|
}
|
||||||
|
|
||||||
|
+# Make BLS the default if GRUB_ENABLE_BLSCFG was not set and grubby is not installed.
|
||||||
|
+if [ -z "${GRUB_ENABLE_BLSCFG}" ] && [ -z "$(which new-kernel-pkg 2> /dev/null)" ]; then
|
||||||
|
+ GRUB_ENABLE_BLSCFG="true"
|
||||||
|
+fi
|
||||||
|
+
|
||||||
|
if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then
|
||||||
|
if [ x$dirname = x/ ]; then
|
||||||
|
if [ -z "${prepare_root_cache}" ]; then
|
|
@ -205,3 +205,5 @@ Patch0204: 0204-blscfg-return-NULL-instead-of-a-zero-length-array-in.patch
|
||||||
Patch0205: 0205-grub-switch-to-blscfg-Update-grub2-binary-in-ESP-for.patch
|
Patch0205: 0205-grub-switch-to-blscfg-Update-grub2-binary-in-ESP-for.patch
|
||||||
Patch0206: 0206-grub-switch-to-blscfg-Only-mark-GRUB-as-BLS-supporte.patch
|
Patch0206: 0206-grub-switch-to-blscfg-Only-mark-GRUB-as-BLS-supporte.patch
|
||||||
Patch0207: 0207-10_linux.in-Merge-logic-from-10_linux_bls-and-drop-t.patch
|
Patch0207: 0207-10_linux.in-Merge-logic-from-10_linux_bls-and-drop-t.patch
|
||||||
|
Patch0208: 0208-grub-switch-to-blscfg-Use-install-to-copy-GRUB-binar.patch
|
||||||
|
Patch0209: 0209-10_linux.in-Enable-BLS-configuration-if-new-kernel-p.patch
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
Name: grub2
|
Name: grub2
|
||||||
Epoch: 1
|
Epoch: 1
|
||||||
Version: 2.04
|
Version: 2.04
|
||||||
Release: 12%{?dist}
|
Release: 13%{?dist}
|
||||||
Summary: Bootloader with support for Linux, Multiboot and more
|
Summary: Bootloader with support for Linux, Multiboot and more
|
||||||
License: GPLv3+
|
License: GPLv3+
|
||||||
URL: http://www.gnu.org/software/grub/
|
URL: http://www.gnu.org/software/grub/
|
||||||
|
@ -504,6 +504,9 @@ rm -r /boot/grub2.tmp/ || :
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Apr 16 2020 Javier Martinez Canillas <javierm@redhat.com> - 2.04-13
|
||||||
|
- Make the grub-switch-to-blscfg and 10_linux scripts more robust
|
||||||
|
|
||||||
* Thu Apr 02 2020 Javier Martinez Canillas <javierm@redhat.com> - 2.04-12
|
* Thu Apr 02 2020 Javier Martinez Canillas <javierm@redhat.com> - 2.04-12
|
||||||
- Merge 10_linux_bls logic into 10_linux and avoid issues if blsdir is set
|
- Merge 10_linux_bls logic into 10_linux and avoid issues if blsdir is set
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue