[rhel6] Fall back to first ESP if none have mountpoints (#1145812)

Vratislav Podzimek vpodzime at redhat.com
Tue Nov 4 09:13:56 UTC 2014


On Mon, 2014-11-03 at 15:25 -0800, Brian C. Lane wrote:
> The problem with that last patch is it still doesn't fall back to the 1st ESP
> if there are none with a mountpoint.  This makes it keep creating new ESPs when
> using 'replace linux'.
> 
> I'd modify it like this:
> 
> ---
>  platform.py | 18 +++++++++++++-----
>  1 file changed, 13 insertions(+), 5 deletions(-)
> 
> diff --git a/platform.py b/platform.py
> index a169e28..a7d32b2 100644
> --- a/platform.py
> +++ b/platform.py
> @@ -248,6 +248,9 @@ class EFI(Platform):
>          Return the boot device. The bootloader.drivelist is used to
>          set the precedence in cases where multiple partitions are
>          available from multiple devices.
> +
> +        Return the first ESP with a mountpoint, if there is one.
> +        Otherwise return the first ESP.
>          """
>          drive = self.anaconda.id.bootloader.drivelist[0]
>  
> @@ -257,12 +260,17 @@ class EFI(Platform):
>                 part.format.type == "efi" and \
>                 self.validBootPartSize(part.size)
>  
> -        if self.isEfi:
> -            isBootDevice = lambda part: _isBoot(part) and part.format.mountpoint
> -        else:
> -            isBootDevice = _isBoot
> +        bootDevice = None
> +        for part in self.anaconda.id.storage.partitions:
> +            if not _isBoot(part):
> +                continue
> +            if part.format.mountpoint:
> +                bootDevice = part
> +                break
> +            elif bootDevice is None:
> +                bootDevice = part
>  
> -        return next((p for p in self.anaconda.id.storage.partitions if isBootDevice(p)), None)
> +        return bootDevice
This looks good to me and I must say that although I like generator/list
comprehensions in this case the "good old" for cycle is much better
readable than next()->generator->lambda->local_func.

-- 
Vratislav Podzimek

Anaconda Rider | RHCE | Red Hat, Inc. | Brno - Czech Republic




More information about the anaconda-patches mailing list