[PATCHv2] Provide a mechanism for platform-specific error messages for stage1 failure

Adam Williamson awilliam at redhat.com
Tue Jan 28 08:28:23 UTC 2014


This is a follow-up to "provide a more useful error message if user fails to
create an ESP". It just implements the same thing in a better way: instead
of stuffing a check for UEFI platform and a platform-specific error message
into the storage sanity check, it provides a mechanism by which we can specify
in platform.py an error message to be displayed in the case the stage1 check
fails. _boot_stage1_missing_error for any platform in platform.py will always
be shown to the user in the sanity check results if stage1_device setting
failed.

I've only included a message for UEFI for now. I'm not familiar enough with the
non-x86 platforms to write messages for those. For x86 BIOS mode, every case
of this error I could find in the wild related to not creating a biosboot
partition when installing to GPT, or some kind of flat-out anaconda bug.
The sanity check already contains a special test for the biosboot partition,
so any time you hit that case you already see a useful error message, there's
no need to duplicate it.

I also slightly tweaked the text of the generic error message itself to be
more accurate to the logic as it currently stands: stage1_device not being set
doesn't necessarily mean "nothing and no-one tried to set it" any more, it can
also mean "we tried to set it but couldn't find a valid setting" - in fact,
that's much more likely.
---
 blivet/__init__.py | 11 +++++------
 blivet/platform.py |  3 +++
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/blivet/__init__.py b/blivet/__init__.py
index e23ca3e..5b6243a 100644
--- a/blivet/__init__.py
+++ b/blivet/__init__.py
@@ -1626,12 +1626,11 @@ class Blivet(object):
         if self.bootloader and not self.bootloader.skip_bootloader:
             stage1 = self.bootloader.stage1_device
             if not stage1:
-                errors.append(_("you have not created a bootloader stage1 "
-                                "target device"))
-                if arch.isEfi():
-                    errors.append(_("For a UEFI installation, your layout must "
-                                    "include an EFI system partition mounted at "
-                                    "/boot/efi"))
+                errors.append(_("No valid bootloader stage1 target device "
+                                "found."))
+                pe = _platform._boot_stage1_missing_error
+                if pe:
+                    errors.append(_(pe))
             else:
                 self.bootloader.is_valid_stage1_device(stage1)
                 errors.extend(self.bootloader.errors)
diff --git a/blivet/platform.py b/blivet/platform.py
index 6c53d1d..51ecd1f 100644
--- a/blivet/platform.py
+++ b/blivet/platform.py
@@ -50,6 +50,7 @@ class Platform(object):
     _boot_stage1_raid_metadata = []
     _boot_stage1_raid_member_types = []
     _boot_stage1_description = N_("bootloader device")
+    _boot_stage1_missing_error = ""
     _boot_raid_description = N_("RAID Device")
     _boot_partition_description = N_("First sector of boot partition")
     _boot_descriptions = {}
@@ -184,6 +185,8 @@ class EFI(Platform):
     _boot_stage1_format_types = ["efi"]
     _boot_stage1_device_types = ["partition"]
     _boot_stage1_mountpoints = ["/boot/efi"]
+    _boot_stage1_missing_error = N_("For a UEFI installation, your layout must include "
+                                    "an EFI system partition mounted at /boot/efi")
     _boot_efi_description = N_("EFI System Partition")
     _boot_descriptions = {"partition": _boot_efi_description,
                           "mdarray": Platform._boot_raid_description}
-- 
1.8.5.3



More information about the anaconda-patches mailing list