[PATCH 1/2] Add rescue kernels to the bootloader install list. (#1036349)

Vratislav Podzimek vpodzime at redhat.com
Tue Mar 11 07:47:12 UTC 2014


On Mon, 2014-03-10 at 16:58 -0400, David Shea wrote:
> This adds a new property, rescueKernelList, to Payload.
> kernelVersionList is unchanged, since most other places that use it
> excluded rescue kernels for a reason.
> 
> Every bootloader but grub2 generates a config based on the list of
> kernels provided by the Payload object, so every bootloader but grub2
> was skipping the rescue kernels. This remedies that.
> ---
>  pyanaconda/bootloader.py         |  2 +-
>  pyanaconda/packaging/__init__.py | 48 ++++++++++++++++++++++++++--------------
>  2 files changed, 32 insertions(+), 18 deletions(-)
> 
> diff --git a/pyanaconda/bootloader.py b/pyanaconda/bootloader.py
> index 0ea7984..8386b57 100644
> --- a/pyanaconda/bootloader.py
> +++ b/pyanaconda/bootloader.py
> @@ -2343,7 +2343,7 @@ def writeBootLoader(storage, payload, instClass, ksdata):
>          log.info("bootloader stage2 target device is %s", stage2_device.name)
>  
>      # get a list of installed kernel packages
> -    kernel_versions = payload.kernelVersionList
> +    kernel_versions = payload.kernelVersionList + payload.rescueKernelList
>      if not kernel_versions:
>          log.warning("no kernel was installed -- bootloader config unchanged")
>          return
> diff --git a/pyanaconda/packaging/__init__.py b/pyanaconda/packaging/__init__.py
> index c85bbd1..7058672 100644
> --- a/pyanaconda/packaging/__init__.py
> +++ b/pyanaconda/packaging/__init__.py
> @@ -113,6 +113,7 @@ class Payload(object):
>          self.data = data
>          self.storage = None
>          self._kernelVersionList = []
> +        self._rescueVersionList = []
>          self._createdInitrds = False
>          self.txID = None
>  
> @@ -318,6 +319,28 @@ class Payload(object):
>  
>          self.data.packages.excludedList.append(pkgid)
>  
> +    def _updateKernelVersionList(self):
> +        import glob
> +        try:
> +            import yum
> +        except ImportError:
> +            cmpfunc = cmp
> +        else:
> +            cmpfunc = yum.rpmUtils.miscutils.compareVerOnly
> +
> +        files = glob.glob(ROOT_PATH + "/boot/vmlinuz-*")
> +        files.extend(glob.glob(ROOT_PATH + "/boot/efi/EFI/redhat/vmlinuz-*"))
> +
> +        versions = [f.split("/")[-1][8:] for f in files if os.path.isfile(f)]
> +        versions.sort(cmp=cmpfunc)
You can make the first line produce a generator and use sorted() in the
second line.

-- 
Vratislav Podzimek

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



More information about the anaconda-patches mailing list