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 <javierm@redhat.com>
This commit is contained in:
Javier Martinez Canillas 2021-02-08 19:50:49 +01:00
parent 3a8f1e293b
commit 4fe0f66632
No known key found for this signature in database
GPG key ID: C751E590D63F3D69

View file

@ -506,8 +506,7 @@ if [ -f $RPM_BUILD_ROOT%{_infodir}/grub-dev.info ]; then \
rm -f $RPM_BUILD_ROOT%{_infodir}/grub-dev.info \ rm -f $RPM_BUILD_ROOT%{_infodir}/grub-dev.info \
fi \ fi \
find $RPM_BUILD_ROOT -iname "*.module" -exec chmod a-x {} '\;' \ find $RPM_BUILD_ROOT -iname "*.module" -exec chmod a-x {} '\;' \
touch $RPM_BUILD_ROOT%{efi_esp_dir}/grub.cfg \ ln -s ../boot/%{name}/grub.cfg \\\
ln -sf ..%{efi_esp_dir}/grub.cfg \\\
$RPM_BUILD_ROOT%{_sysconfdir}/%{name}-efi.cfg \ $RPM_BUILD_ROOT%{_sysconfdir}/%{name}-efi.cfg \
install -m 700 %{2} $RPM_BUILD_ROOT%{efi_esp_dir}/%{2} \ install -m 700 %{2} $RPM_BUILD_ROOT%{efi_esp_dir}/%{2} \
install -m 700 %{3} $RPM_BUILD_ROOT%{efi_esp_dir}/%{3} \ 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 \\\ install -D -m 700 unicode.pf2 \\\
$RPM_BUILD_ROOT%{efi_esp_dir}/fonts/unicode.pf2 \ $RPM_BUILD_ROOT%{efi_esp_dir}/fonts/unicode.pf2 \
${RPM_BUILD_ROOT}/%{_bindir}/%{name}-editenv \\\ ${RPM_BUILD_ROOT}/%{_bindir}/%{name}-editenv \\\
${RPM_BUILD_ROOT}%{efi_esp_dir}/grubenv create \ ${RPM_BUILD_ROOT}/boot/%{name}/grubenv create \
ln -sf ../efi/EFI/%{efi_vendor}/grubenv \\\
$RPM_BUILD_ROOT/boot/grub2/grubenv \
%{expand:%%do_install_protected_file %{name}-%{package_arch}} \ %{expand:%%do_install_protected_file %{name}-%{package_arch}} \
cd .. \ cd .. \
%{nil} %{nil}
@ -533,8 +530,6 @@ fi \
if [ -f $RPM_BUILD_ROOT%{_infodir}/grub-dev.info ]; then \ if [ -f $RPM_BUILD_ROOT%{_infodir}/grub-dev.info ]; then \
rm -f $RPM_BUILD_ROOT%{_infodir}/grub-dev.info \ rm -f $RPM_BUILD_ROOT%{_infodir}/grub-dev.info \
fi \ fi \
ln -s ../boot/%{name}/grub.cfg \\\
${RPM_BUILD_ROOT}%{_sysconfdir}/grub2.cfg \
if [ -f $RPM_BUILD_ROOT/%{_libdir}/grub/%{1}/grub2.chrp ]; then \ if [ -f $RPM_BUILD_ROOT/%{_libdir}/grub/%{1}/grub2.chrp ]; then \
mv $RPM_BUILD_ROOT/%{_libdir}/grub/%{1}/grub2.chrp \\\ mv $RPM_BUILD_ROOT/%{_libdir}/grub/%{1}/grub2.chrp \\\
$RPM_BUILD_ROOT/%{_libdir}/grub/%{1}/grub.chrp \ $RPM_BUILD_ROOT/%{_libdir}/grub/%{1}/grub.chrp \
@ -583,6 +578,8 @@ touch ${RPM_BUILD_ROOT}%{_sysconfdir}/default/grub \
ln -sf ../default/grub \\\ ln -sf ../default/grub \\\
${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/grub \ ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/grub \
touch ${RPM_BUILD_ROOT}/boot/%{name}/grub.cfg \ touch ${RPM_BUILD_ROOT}/boot/%{name}/grub.cfg \
ln -s ../boot/%{name}/grub.cfg \\\
${RPM_BUILD_ROOT}%{_sysconfdir}/grub2.cfg \
%{nil} %{nil}
%define define_legacy_variant_files() \ %define define_legacy_variant_files() \
@ -609,6 +606,7 @@ touch ${RPM_BUILD_ROOT}/boot/%{name}/grub.cfg \
%define define_efi_variant_files() \ %define define_efi_variant_files() \
%{expand:%%files %{1}} \ %{expand:%%files %{1}} \
%defattr(0700,root,root,-) \ %defattr(0700,root,root,-) \
%config(noreplace) %{_sysconfdir}/%{name}.cfg \
%config(noreplace) %{_sysconfdir}/%{name}-efi.cfg \ %config(noreplace) %{_sysconfdir}/%{name}-efi.cfg \
%attr(0700,root,root)%{efi_esp_dir}/%{2} \ %attr(0700,root,root)%{efi_esp_dir}/%{2} \
%ifarch %{arm} \ %ifarch %{arm} \
@ -616,9 +614,9 @@ touch ${RPM_BUILD_ROOT}/boot/%{name}/grub.cfg \
%endif \ %endif \
%dir %attr(0700,root,root)%{efi_esp_dir}/fonts \ %dir %attr(0700,root,root)%{efi_esp_dir}/fonts \
%dir %attr(0700,root,root)/boot/loader/entries \ %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 \ %ghost %config(noreplace) %attr(0700,root,root)%{efi_esp_dir}/grub.cfg \
%config(noreplace) %verify(not size mode md5 mtime) /boot/grub2/grubenv \ %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 \ %attr(0644,root,root) %config(noreplace) /etc/dnf/protected.d/%{name}-%{1}.conf \
%{expand:%if 0%{?without_efi_modules} \ %{expand:%if 0%{?without_efi_modules} \
%exclude %{_libdir}/grub/%{6} \ %exclude %{_libdir}/grub/%{6} \