Add grub2-emu subpackage

GRUB has an user-space program emulator that allows to parse config files
and execute boot entries using the kexec tool. Add a grub2-emu subpackage
to install the emulator.

The subpackage is disabled on ppc64le architecture for now since grub2-emu
fails to build there.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
This commit is contained in:
Javier Martinez Canillas 2019-04-30 10:32:46 +02:00
parent af06f22ee4
commit a18e8e631d
No known key found for this signature in database
GPG Key ID: C751E590D63F3D69
4 changed files with 123 additions and 1 deletions

View File

@ -0,0 +1,41 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <javierm@redhat.com>
Date: Wed, 1 May 2019 00:36:19 +0200
Subject: [PATCH] Fix undefined references for fdt when building with platform
emu
The fdt module isn't build for this platform, so adding the declarations
with platform emu will lead to the following undefined reference errors:
BUILDSTDERR: /usr/bin/ld: grub_emu_lite-symlist.o:(.data+0x500): undefined reference to `grub_fdt_add_subnode'
BUILDSTDERR: /usr/bin/ld: grub_emu_lite-symlist.o:(.data+0x518): undefined reference to `grub_fdt_check_header'
BUILDSTDERR: /usr/bin/ld: grub_emu_lite-symlist.o:(.data+0x530): undefined reference to `grub_fdt_check_header_nosize'
BUILDSTDERR: /usr/bin/ld: grub_emu_lite-symlist.o:(.data+0x548): undefined reference to `grub_fdt_create_empty_tree'
BUILDSTDERR: /usr/bin/ld: grub_emu_lite-symlist.o:(.data+0x560): undefined reference to `grub_fdt_find_subnode'
BUILDSTDERR: /usr/bin/ld: grub_emu_lite-symlist.o:(.data+0x578): undefined reference to `grub_fdt_first_node'
BUILDSTDERR: /usr/bin/ld: grub_emu_lite-symlist.o:(.data+0x590): undefined reference to `grub_fdt_get_nodename'
BUILDSTDERR: /usr/bin/ld: grub_emu_lite-symlist.o:(.data+0x5a8): undefined reference to `grub_fdt_get_prop'
BUILDSTDERR: /usr/bin/ld: grub_emu_lite-symlist.o:(.data+0x5c0): undefined reference to `grub_fdt_next_node'
BUILDSTDERR: /usr/bin/ld: grub_emu_lite-symlist.o:(.data+0x5d8): undefined reference to `grub_fdt_set_prop'
BUILDSTDERR: collect2: error: ld returned 1 exit status
BUILDSTDERR: make[1]: *** [Makefile:27093: grub-emu-lite] Error 1
BUILDSTDERR: make[1]: *** Waiting for unfinished jobs....
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---
include/grub/fdt.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/grub/fdt.h b/include/grub/fdt.h
index 6ee57e11ab3..e34644631e1 100644
--- a/include/grub/fdt.h
+++ b/include/grub/fdt.h
@@ -19,7 +19,7 @@
#ifndef GRUB_FDT_HEADER
#define GRUB_FDT_HEADER 1
-#if defined(__arm__) || defined(__aarch64__)
+#if !defined(GRUB_MACHINE_EMU) && (defined(__arm__) || defined(__aarch64__))
#include <grub/types.h>
#include <grub/symbol.h>

View File

@ -51,6 +51,8 @@
%global with_efi_arch 0 %global with_efi_arch 0
%global with_alt_efi_arch 0 %global with_alt_efi_arch 0
%global with_legacy_arch 0 %global with_legacy_arch 0
%global with_emu_arch 1
%global emuarch %{_arch}
%global grubefiarch %{nil} %global grubefiarch %{nil}
%global grublegacyarch %{nil} %global grublegacyarch %{nil}
@ -64,6 +66,8 @@
%endif %endif
# ppc is always compiled 64 bit # ppc is always compiled 64 bit
%ifarch ppc ppc64 ppc64le %ifarch ppc ppc64 ppc64le
# GRUB emu fails to build on ppc64le
%global with_emu_arch 0
%global target_cpu_name %{_arch} %global target_cpu_name %{_arch}
%global legacy_target_cpu_name powerpc %global legacy_target_cpu_name powerpc
%global legacy_package_arch %{_arch} %global legacy_package_arch %{_arch}
@ -137,6 +141,7 @@
%endif %endif
%ifarch aarch64 %ifarch aarch64
%global emuarch arm64
%global efiarch aa64 %global efiarch aa64
%global target_cpu_name aarch64 %global target_cpu_name aarch64
%global grub_target_name arm64-efi %global grub_target_name arm64-efi
@ -417,6 +422,22 @@ make %{?_smp_mflags} \
cd .. \ cd .. \
%{nil} %{nil}
%define do_emu_build() \
cd grub-emu-%{tarversion} \
%configure \\\
%{cc_equals} \\\
--with-platform=emu \\\
--with-grubdir=%{name} \\\
--program-transform-name=s,grub,%{name}, \\\
--disable-werror || ( cat config.log ; exit 1 ) \
git add . \
git commit -m "After emu configure" \
make %{?_smp_mflags} ascii.h widthspec.h \
make %{?_smp_mflags} -C grub-core/gnulib \
make %{?_smp_mflags} -C grub-core \
cd .. \
%{nil}
%define do_alt_efi_install() \ %define do_alt_efi_install() \
cd grub-%{1}-%{tarversion} \ cd grub-%{1}-%{tarversion} \
install -d -m 755 $RPM_BUILD_ROOT/usr/lib/grub/%{grubaltefiarch}/ \ install -d -m 755 $RPM_BUILD_ROOT/usr/lib/grub/%{grubaltefiarch}/ \
@ -482,6 +503,22 @@ fi \
cd .. \ cd .. \
%{nil} %{nil}
%define do_emu_install() \
cd grub-emu-%{tarversion} \
make DESTDIR=$RPM_BUILD_ROOT install -C grub-core \
if [ -f $RPM_BUILD_ROOT%{_infodir}/grub.info ]; then \
rm -f $RPM_BUILD_ROOT%{_infodir}/grub.info \
fi \
if [ -f $RPM_BUILD_ROOT%{_infodir}/grub-dev.info ]; then \
rm -f $RPM_BUILD_ROOT%{_infodir}/grub-dev.info \
fi \
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 \
fi \
cd .. \
%{nil}
%define do_common_install() \ %define do_common_install() \
install -d -m 0755 \\\ install -d -m 0755 \\\
$RPM_BUILD_ROOT%{_datarootdir}/locale/en\@quot \\\ $RPM_BUILD_ROOT%{_datarootdir}/locale/en\@quot \\\

View File

@ -296,3 +296,4 @@ Patch0295: 0295-Fix-systemctl-kexec-exit-status-check.patch
Patch0296: 0296-Print-grub-emu-linux-loader-messages-as-debug.patch Patch0296: 0296-Print-grub-emu-linux-loader-messages-as-debug.patch
Patch0297: 0297-Don-t-assume-that-boot-commands-will-only-return-on-.patch Patch0297: 0297-Don-t-assume-that-boot-commands-will-only-return-on-.patch
Patch0298: 0298-Add-10_reset_boot_success-to-Makefile.patch Patch0298: 0298-Add-10_reset_boot_success-to-Makefile.patch
Patch0299: 0299-Fix-undefined-references-for-fdt-when-building-with-.patch

View File

@ -7,7 +7,7 @@
Name: grub2 Name: grub2
Epoch: 1 Epoch: 1
Version: 2.02 Version: 2.02
Release: 79%{?dist} Release: 80%{?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/
@ -132,6 +132,24 @@ This subpackage provides tools for support of all platforms.
%{expand:%define_legacy_variant %%{legacy_package_arch}} %{expand:%define_legacy_variant %%{legacy_package_arch}}
%endif %endif
%if 0%{with_emu_arch}
%package emu
Summary: GRUB user-space emulation.
Requires: %{name}-tools-minimal = %{epoch}:%{version}-%{release}
%description emu
%{desc}
This subpackage provides the GRUB user-space emulation support of all platforms.
%package emu-modules
Summary: GRUB user-space emulation modules.
Requires: %{name}-tools-minimal = %{epoch}:%{version}-%{release}
%description emu-modules
%{desc}
This subpackage provides the GRUB user-space emulation modules.
%endif
%prep %prep
%do_common_setup %do_common_setup
%if 0%{with_efi_arch} %if 0%{with_efi_arch}
@ -152,6 +170,12 @@ grep -A100000 '# stuff "make" creates' .gitignore > grub-%{grublegacyarch}-%{tar
cp %{SOURCE4} grub-%{grublegacyarch}-%{tarversion}/unifont.pcf.gz cp %{SOURCE4} grub-%{grublegacyarch}-%{tarversion}/unifont.pcf.gz
git add grub-%{grublegacyarch}-%{tarversion} git add grub-%{grublegacyarch}-%{tarversion}
%endif %endif
%if 0%{with_emu_arch}
mkdir grub-emu-%{tarversion}
grep -A100000 '# stuff "make" creates' .gitignore > grub-emu-%{tarversion}/.gitignore
cp %{SOURCE4} grub-emu-%{tarversion}/unifont.pcf.gz
git add grub-emu-%{tarversion}
%endif
git commit -m "After making subdirs" git commit -m "After making subdirs"
%build %build
@ -164,6 +188,9 @@ git commit -m "After making subdirs"
%if 0%{with_legacy_arch} %if 0%{with_legacy_arch}
%{expand:%do_legacy_build %%{grublegacyarch}} %{expand:%do_legacy_build %%{grublegacyarch}}
%endif %endif
%if 0%{with_emu_arch}
%{expand:%do_emu_build}
%endif
makeinfo --info --no-split -I docs -o docs/grub-dev.info \ makeinfo --info --no-split -I docs -o docs/grub-dev.info \
docs/grub-dev.texi docs/grub-dev.texi
makeinfo --info --no-split -I docs -o docs/grub.info \ makeinfo --info --no-split -I docs -o docs/grub.info \
@ -187,6 +214,9 @@ rm -fr $RPM_BUILD_ROOT
%if 0%{with_legacy_arch} %if 0%{with_legacy_arch}
%{expand:%do_legacy_install %%{grublegacyarch} %%{alt_grub_target_name} 0%{with_efi_arch}} %{expand:%do_legacy_install %%{grublegacyarch} %%{alt_grub_target_name} 0%{with_efi_arch}}
%endif %endif
%if 0%{with_emu_arch}
%{expand:%do_emu_install %%{package_arch}}
%endif
rm -f $RPM_BUILD_ROOT%{_infodir}/dir rm -f $RPM_BUILD_ROOT%{_infodir}/dir
ln -s %{name}-set-password ${RPM_BUILD_ROOT}/%{_sbindir}/%{name}-setpassword ln -s %{name}-set-password ${RPM_BUILD_ROOT}/%{_sbindir}/%{name}-setpassword
echo '.so man8/%{name}-set-password.8' > ${RPM_BUILD_ROOT}/%{_datadir}/man/man8/%{name}-setpassword.8 echo '.so man8/%{name}-set-password.8' > ${RPM_BUILD_ROOT}/%{_datadir}/man/man8/%{name}-setpassword.8
@ -475,7 +505,20 @@ rm -r /boot/grub2.tmp/ || :
%{expand:%define_legacy_variant_files %%{legacy_package_arch} %%{grublegacyarch}} %{expand:%define_legacy_variant_files %%{legacy_package_arch} %%{grublegacyarch}}
%endif %endif
%if 0%{with_emu_arch}
%files emu
%{_bindir}/%{name}-emu*
%{_datadir}/man/man1/%{name}-emu*
%files emu-modules
%{_libdir}/grub/%{emuarch}-emu/*
%exclude %{_libdir}/grub/%{emuarch}-emu/*.module
%endif
%changelog %changelog
* Fri May 03 2019 Javier Martinez Canillas <javierm@redhat.com> - 2.02-80
- Add grub2-emu subpackage
* Fri May 03 2019 Tim Landscheidt <tim@tim-landscheidt.de> - 2.02-79 * Fri May 03 2019 Tim Landscheidt <tim@tim-landscheidt.de> - 2.02-79
- Fix description of grub2-pc - Fix description of grub2-pc
Resolves: rhbz#1484298 Resolves: rhbz#1484298