[PATCHv3 1/2] Provide a mechanism for platform-specific error messages for stage1 failure

Adam Williamson awilliam at redhat.com
Fri Jan 31 02:34:56 UTC 2014


This is a follow-up to "provide a more useful error message if user fails to
create an ESP". It implements a cleaner, more generic way of doing it: 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.

I've included error messages for each platform, based on the constraints.

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. "See below for details" makes it a bit clearer, I
think, that the platform-specific error message is giving you more details
about this still-fairly-cryptic message, they're not separate errors. "stage1"
is pretty jargon-y, probably meaningless to the user, and probably not strictly
the right term for some of these cases, so I dropped it.
---
 blivet/__init__.py | 11 +++++------
 blivet/platform.py | 25 ++++++++++++++++++++++++-
 2 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/blivet/__init__.py b/blivet/__init__.py
index e23ca3e..d411bc6 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 target device found. "
+                                "See below for details."))
+                pe = _platform.stage1MissingError
+                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..d45e2fd 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 = {}
@@ -148,6 +149,12 @@ class Platform(object):
         else:
             return 0
 
+    @property
+    def stage1MissingError(self):
+        """A platform-specific error message to be shown if stage1 target
+           selection fails."""
+        return self._boot_stage1_missing_error
+
 class X86(Platform):
     _boot_stage1_device_types = ["disk"]
     _boot_mbr_description = N_("Master Boot Record")
@@ -155,10 +162,11 @@ class X86(Platform):
                           "partition": Platform._boot_partition_description,
                           "mdarray": Platform._boot_raid_description}
 
-
     _disklabel_types = ["msdos", "gpt"]
     # XXX hpfs, if reported by blkid/udev, will end up with a type of None
     _non_linux_format_types = ["vfat", "ntfs", "hpfs"]
+    _boot_stage1_missing_error = N_("You must include at least one MBR- or "
+                                    "GPT-formatted disk as an install target.")    
 
     def __init__(self):
         super(X86, self).__init__()
@@ -191,6 +199,9 @@ class EFI(Platform):
     _disklabel_types = ["gpt"]
     # XXX hpfs, if reported by blkid/udev, will end up with a type of None
     _non_linux_format_types = ["vfat", "ntfs", "hpfs"]
+    _boot_stage1_missing_error = N_("For a UEFI installation, you must include "
+                                    "an EFI System Partition on a GPT-formatted "
+                                    "disk, mounted at /boot/efi.")
 
     def setDefaultPartitioning(self):
         ret = Platform.setDefaultPartitioning(self)
@@ -238,6 +249,9 @@ class IPSeriesPPC(PPC):
     _boot_prep_description = N_("PReP Boot Partition")
     _boot_descriptions = {"partition": _boot_prep_description}
     _disklabel_types = ["msdos"]
+    _boot_stage1_missing_error = N_("You must include a PReP Boot Partition "
+                                    "within the first 4GiB of an MBR-formatted "
+                                    "disk.")
 
     def setDefaultPartitioning(self):
         ret = PPC.setDefaultPartitioning(self)
@@ -260,6 +274,9 @@ class NewWorldPPC(PPC):
     _boot_descriptions = {"partition": _boot_apple_description}
     _disklabel_types = ["mac"]
     _non_linux_format_types = ["hfs", "hfs+"]
+    _boot_stage1_missing_error = N_("You must include an Apple Bootstrap "
+                                    "Partition on an Apple Partition Map-"
+                                    "formatted disk.")
 
     def setDefaultPartitioning(self):
         ret = Platform.setDefaultPartitioning(self)
@@ -290,6 +307,8 @@ class S390(Platform):
                           "zfcp": _boot_zfcp_description,
                           "disk": _boot_mbr_description,
                           "partition": Platform._boot_partition_description}
+    _boot_stage1_missing_error = N_("You must include at least one MBR- or "
+                                    "DASD-formatted disk as an install target.")
 
     def __init__(self):
         Platform.__init__(self)
@@ -315,6 +334,8 @@ class ARM(Platform):
                           "partition": Platform._boot_partition_description}
 
     _disklabel_types = ["msdos"]
+    _boot_stage1_missing_error = N_("You must include at least one MBR-formatted "
+                                    "disk as an install target.")
 
     @property
     def armMachine(self):
@@ -337,6 +358,8 @@ class omapARM(ARM):
     _boot_stage1_mountpoints = ["/boot/uboot"]
     _boot_uboot_description = N_("U-Boot Partition")
     _boot_descriptions = {"partition": _boot_uboot_description}
+    _boot_stage1_missing_error = N_("You must include a U-Boot Partition on a "
+                                    "FAT-formatted disk, mounted at /boot/uboot.")
 
     def setDefaultPartitioning(self):
         """Return the ARM-OMAP platform-specific partitioning information."""
-- 
1.8.5.3



More information about the anaconda-patches mailing list