From 4fe0f66632e0b0e3264f78a51b30ab89eb6d49e4 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 8 Feb 2021 19:50:49 +0100 Subject: [PATCH] Unify GRUB configuration file location across all platforms The GRUB configuration files layout on EFI platforms isn't consistent with other non-EFI platforms (e.g: legacy BIOS x86 and Open Firmware ppc64le). On platforms using EFI, the GRUB config file (grub.cfg) and environment variables block (grubenv) are stored in the EFI System Partition (ESP), while for non-EFI platforms these are stored in the boot partition (or /boot directory if not boot partition is used). The reason for this is that the path where the GRUB bootloader searches for its configuration file varies depending on the firmware interface. For EFI the GRUB binary is located in the ESP and it expects to find its config file in that location as well. But this creates the mentioned inconsistency, because the GRUB configuration file has to be stored in /boot/efi/EFI/fedora/grub.cfg while for non-EFI platforms it has to be stored in /boot/grub2/grub.cfg. To allow all platforms to have the GRUB config file in the same location, only a minimal config file could be stored in the ESP and this will load the one that is stored in /boot/grub2. Related: rhbz#1918817 Signed-off-by: Javier Martinez Canillas --- grub.macros | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/grub.macros b/grub.macros index 52d5cae6..0498daed 100644 --- a/grub.macros +++ b/grub.macros @@ -506,8 +506,7 @@ if [ -f $RPM_BUILD_ROOT%{_infodir}/grub-dev.info ]; then \ rm -f $RPM_BUILD_ROOT%{_infodir}/grub-dev.info \ fi \ find $RPM_BUILD_ROOT -iname "*.module" -exec chmod a-x {} '\;' \ -touch $RPM_BUILD_ROOT%{efi_esp_dir}/grub.cfg \ -ln -sf ..%{efi_esp_dir}/grub.cfg \\\ +ln -s ../boot/%{name}/grub.cfg \\\ $RPM_BUILD_ROOT%{_sysconfdir}/%{name}-efi.cfg \ install -m 700 %{2} $RPM_BUILD_ROOT%{efi_esp_dir}/%{2} \ install -m 700 %{3} $RPM_BUILD_ROOT%{efi_esp_dir}/%{3} \ @@ -517,9 +516,7 @@ install -D -m 700 %{2} $RPM_BUILD_ROOT%{efi_esp_boot}/BOOTARM.EFI \ install -D -m 700 unicode.pf2 \\\ $RPM_BUILD_ROOT%{efi_esp_dir}/fonts/unicode.pf2 \ ${RPM_BUILD_ROOT}/%{_bindir}/%{name}-editenv \\\ - ${RPM_BUILD_ROOT}%{efi_esp_dir}/grubenv create \ -ln -sf ../efi/EFI/%{efi_vendor}/grubenv \\\ - $RPM_BUILD_ROOT/boot/grub2/grubenv \ + ${RPM_BUILD_ROOT}/boot/%{name}/grubenv create \ %{expand:%%do_install_protected_file %{name}-%{package_arch}} \ cd .. \ %{nil} @@ -533,8 +530,6 @@ fi \ if [ -f $RPM_BUILD_ROOT%{_infodir}/grub-dev.info ]; then \ rm -f $RPM_BUILD_ROOT%{_infodir}/grub-dev.info \ fi \ -ln -s ../boot/%{name}/grub.cfg \\\ - ${RPM_BUILD_ROOT}%{_sysconfdir}/grub2.cfg \ if [ -f $RPM_BUILD_ROOT/%{_libdir}/grub/%{1}/grub2.chrp ]; then \ mv $RPM_BUILD_ROOT/%{_libdir}/grub/%{1}/grub2.chrp \\\ $RPM_BUILD_ROOT/%{_libdir}/grub/%{1}/grub.chrp \ @@ -583,6 +578,8 @@ touch ${RPM_BUILD_ROOT}%{_sysconfdir}/default/grub \ ln -sf ../default/grub \\\ ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/grub \ touch ${RPM_BUILD_ROOT}/boot/%{name}/grub.cfg \ +ln -s ../boot/%{name}/grub.cfg \\\ + ${RPM_BUILD_ROOT}%{_sysconfdir}/grub2.cfg \ %{nil} %define define_legacy_variant_files() \ @@ -609,6 +606,7 @@ touch ${RPM_BUILD_ROOT}/boot/%{name}/grub.cfg \ %define define_efi_variant_files() \ %{expand:%%files %{1}} \ %defattr(0700,root,root,-) \ +%config(noreplace) %{_sysconfdir}/%{name}.cfg \ %config(noreplace) %{_sysconfdir}/%{name}-efi.cfg \ %attr(0700,root,root)%{efi_esp_dir}/%{2} \ %ifarch %{arm} \ @@ -616,9 +614,9 @@ touch ${RPM_BUILD_ROOT}/boot/%{name}/grub.cfg \ %endif \ %dir %attr(0700,root,root)%{efi_esp_dir}/fonts \ %dir %attr(0700,root,root)/boot/loader/entries \ +%ghost %config(noreplace) /boot/%{name}/grub.cfg \ %ghost %config(noreplace) %attr(0700,root,root)%{efi_esp_dir}/grub.cfg \ %config(noreplace) %verify(not size mode md5 mtime) /boot/grub2/grubenv \ -%ghost %config(noreplace) %attr(0700,root,root)%{efi_esp_dir}/grubenv \ %attr(0644,root,root) %config(noreplace) /etc/dnf/protected.d/%{name}-%{1}.conf \ %{expand:%if 0%{?without_efi_modules} \ %exclude %{_libdir}/grub/%{6} \