61 lines
2.2 KiB
Diff
61 lines
2.2 KiB
Diff
From d11a97fec8efc57f1a6cb2f1bbb270dc67bf873a Mon Sep 17 00:00:00 2001
|
|
From: Will Woods <wwoods@redhat.com>
|
|
Date: Tue, 13 Nov 2012 01:33:15 -0500
|
|
Subject: [PATCH 2/6] treebuilder: improve findkernels() initrd search
|
|
|
|
This makes findkernels() look for any image named something like:
|
|
|
|
$PREFIX-$KERNELVER.img
|
|
|
|
and adds a corresponding entry to its returned data like:
|
|
|
|
kernel.$PREFIX.path = [path]
|
|
|
|
As a special backwards-compatibility case we use 'initrd' for the
|
|
attribute name if $PREFIX is 'initramfs'.
|
|
|
|
This gives us any extra initramfs images that may have been built using
|
|
the 'prefix' argument to rebuild_initrds().
|
|
---
|
|
src/pylorax/treebuilder.py | 17 ++++++++++-------
|
|
1 file changed, 10 insertions(+), 7 deletions(-)
|
|
|
|
diff --git a/src/pylorax/treebuilder.py b/src/pylorax/treebuilder.py
|
|
index 74a59ae..17f2ae6 100644
|
|
--- a/src/pylorax/treebuilder.py
|
|
+++ b/src/pylorax/treebuilder.py
|
|
@@ -266,20 +266,23 @@ def findkernels(root="/", kdir="boot"):
|
|
kre = re.compile(r"vmlinuz-(?P<version>.+?\.(?P<arch>[a-z0-9_]+)"
|
|
r"(\.(?P<flavor>{0}))?)$".format("|".join(flavors)))
|
|
kernels = []
|
|
- for f in os.listdir(joinpaths(root, kdir)):
|
|
+ bootfiles = os.listdir(joinpaths(root, kdir))
|
|
+ for f in bootfiles:
|
|
match = kre.match(f)
|
|
if match:
|
|
kernel = DataHolder(path=joinpaths(kdir, f))
|
|
kernel.update(match.groupdict()) # sets version, arch, flavor
|
|
kernels.append(kernel)
|
|
|
|
- # look for associated initrd/initramfs
|
|
+ # look for associated initrd/initramfs/etc.
|
|
for kernel in kernels:
|
|
- # NOTE: if both exist, the last one found will win
|
|
- for imgname in ("initrd", "initramfs"):
|
|
- i = kernel.path.replace("vmlinuz", imgname, 1) + ".img"
|
|
- if os.path.exists(joinpaths(root, i)):
|
|
- kernel.initrd = DataHolder(path=i)
|
|
+ for f in bootfiles:
|
|
+ if f.endswith('-'+kernel.version+'.img'):
|
|
+ imgtype, rest = f.split('-',1)
|
|
+ # special backwards-compat case
|
|
+ if imgtype == 'initramfs':
|
|
+ imgtype = 'initrd'
|
|
+ kernel[imgtype] = DataHolder(path=joinpaths(kdir, f))
|
|
|
|
return kernels
|
|
|
|
--
|
|
1.8.0
|
|
|