From 1bddbe745e6208575d05e2b4aa94eff57c517c51 Mon Sep 17 00:00:00 2001 From: Neal Gompa Date: Sat, 26 Jun 2021 09:38:11 -0400 Subject: [PATCH] Backport fix to deal with grub-install errors for UEFI --- ...-install-errors-if-they-are-expected.patch | 63 +++++++++++++++++++ appliance-tools.spec | 8 ++- 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 0001-Ignore-grub2-install-errors-if-they-are-expected.patch diff --git a/0001-Ignore-grub2-install-errors-if-they-are-expected.patch b/0001-Ignore-grub2-install-errors-if-they-are-expected.patch new file mode 100644 index 0000000..08ebaa9 --- /dev/null +++ b/0001-Ignore-grub2-install-errors-if-they-are-expected.patch @@ -0,0 +1,63 @@ +From bc03c7227fcfb4f5ebe05de2c31705c0eb94b6e7 Mon Sep 17 00:00:00 2001 +From: Pablo Greco +Date: Wed, 24 Mar 2021 10:30:46 -0300 +Subject: [PATCH] Ignore grub2-install errors if they are expected + +With the inclusion of +https://github.com/rhboot/grub2/commit/a1be2d182af27afb6db0e7fcf9d5ebf40086b2f6 +grub2-install refuses to run in efi environments, making +appliance-create fail erroneously. The approach here is to skip this +error if expected, while still calling grub2-install to try to keep the +functionality as close as possible with older versions + +Signed-off-by: Pablo Greco +--- + appcreate/appliance.py | 12 ++++++++++-- + 1 file changed, 10 insertions(+), 2 deletions(-) + +diff --git a/appcreate/appliance.py b/appcreate/appliance.py +index 31de48a..474a3b9 100644 +--- a/appcreate/appliance.py ++++ b/appcreate/appliance.py +@@ -74,6 +74,7 @@ class ApplianceImageCreator(ImageCreator): + # This determines which partition layout we'll be using + self.bootloader = None + self.grub2inst_params = [] ++ self.grub2inst_may_fail = False + + def _get_fstab(self): + f = "" +@@ -201,12 +202,16 @@ class ApplianceImageCreator(ImageCreator): + if 'grub2-efi-arm' in packages: + self.bootloader = 'grub2' + self.grub2inst_params = ["--target=arm-efi", "--removable"] ++ self.grub2inst_may_fail = True + elif 'grub2-efi-aa64' in packages: + self.bootloader = 'grub2' ++ self.grub2inst_may_fail = True + elif 'grub2-efi-ia32' in packages: + self.bootloader = 'grub2' ++ self.grub2inst_may_fail = True + elif 'grub2-efi-x64' in packages: + self.bootloader = 'grub2' ++ self.grub2inst_may_fail = True + elif 'grub2' in packages or 'grub2-pc' in packages: + self.bootloader = 'grub2' + elif 'grub' in packages: +@@ -505,8 +510,11 @@ class ApplianceImageCreator(ImageCreator): + rc = subprocess.call(["chroot", self._instroot, "grub2-install", "--no-floppy", "--no-nvram", "--grub-mkdevicemap=/boot/grub2/device.map"] + self.grub2inst_params + [loopdev]) + + if rc != 0: +- subprocess.call(["umount", self._instroot + "/dev"]) +- raise MountError("Unable to install grub2 bootloader") ++ if self.grub2inst_may_fail: ++ logging.debug("grub2-install failed, but error is expected and ignored (EFI)") ++ else: ++ subprocess.call(["umount", self._instroot + "/dev"]) ++ raise MountError("Unable to install grub2 bootloader") + + mkconfig_dest = "/boot/grub2/grub.cfg" + try: +-- +2.31.1 + diff --git a/appliance-tools.spec b/appliance-tools.spec index 7e0bc44..1e5d294 100644 --- a/appliance-tools.spec +++ b/appliance-tools.spec @@ -21,12 +21,15 @@ Name: appliance-tools Summary: Tools for building Appliances Version: 011.1 -Release: 3%{?dist} +Release: 4%{?dist} License: GPLv2 URL: https://pagure.io/appliance-tools Source0: https://releases.pagure.org/%{name}/%{name}-%{version}.tar.bz2 +# Backports from upstream +Patch0001: 0001-Ignore-grub2-install-errors-if-they-are-expected.patch + # Ensure system deps are installed (rhbz#1409536) Requires: python%{python_pkgversion}-imgcreate %{?min_imgcrate_evr:>= %{min_imgcreate_evr}} Requires: python%{python_pkgversion}-progress @@ -74,6 +77,9 @@ rm -rf %{buildroot}%{_datadir}/doc/%{name} %{python_sitelib}/ec2convert/ %changelog +* Sat Jun 26 2021 Neal Gompa - 011.1-4 +- Backport fix to deal with grub-install errors for UEFI + * Fri Jun 04 2021 Python Maint - 011.1-3 - Rebuilt for Python 3.10