Make sure we have at least one kernel

If the only kernel we have is a PAE or xen kernel,
make sure we copy it to the isolinux directory, and create the
efi images.
This commit is contained in:
Martin Gracik 2010-02-25 10:54:02 +01:00
parent d8e07aeac0
commit 38b6fce4e5

View File

@ -174,46 +174,85 @@ class Lorax(BaseLoraxClass):
initrd = images.InitRD(self.installtree, modules, initrd_template, initrd = images.InitRD(self.installtree, modules, initrd_template,
self.workdir) self.workdir)
# get all kernels and initrds
kernel_normal, kernel_pae, kernel_xen = [], [], []
for kernel, initrd in initrd.create(): for kernel, initrd in initrd.create():
if kernel.is_pae:
kernel_pae.append((kernel, initrd))
elif kernel.is_xen:
kernel_xen.append((kernel, initrd))
else:
kernel_normal.append((kernel, initrd))
# if we have a normal kernel, set it as the main kernel
kernels = []
try:
kernels.append(kernel_normal.pop(0))
except IndexError:
pass
# add pae and xen kernels to the list of kernels
kernels.extend(kernel_pae)
kernels.extend(kernel_xen)
# check if we have at least one kernel
if not kernels:
self.pcritical("no kernel images found")
sys.exit(1)
# main kernel
kernel, initrd = kernels.pop(0)
kernelfile = "vmlinuz"
initrdfile = "initrd.img"
# add images section to treeinfo
section = "images-{0}".format(self.conf.basearch)
data = {"kernel": "images/pxeboot/{0}".format(kernelfile),
"initrd": "images/pxeboot/{0}".format(initrdfile)}
self.treeinfo_add_section(self.conf.treeinfo, section, data)
# copy the kernel and initrd image to the isolinux directory
kdst = os.path.join(self.conf.isodir, kernelfile)
idst = os.path.join(self.conf.isodir, initrdfile)
shutil.copy2(kernel.path, kdst)
shutil.copy2(initrd, idst)
# copy the kernel and initrd image to the pxe directory
kdst = os.path.join(self.conf.pxedir, kernelfile)
idst = os.path.join(self.conf.pxedir, initrdfile)
shutil.copy2(kernel.path, kdst)
shutil.copy2(initrd, idst)
# create the efi images
if self.installtree.do_efi:
efi = images.EFI(self.installtree, kernel, initrd,
self.product, self.version, self.workdir)
efiboot, efidisk = efi.create()
# copy the efi images to the images directory
shutil.copy2(efiboot, self.conf.imgdir)
shutil.copy2(efidisk, self.conf.imgdir)
# other kernels
for kernel, initrd in kernels:
if kernel.is_pae: if kernel.is_pae:
kernelfile = "vmlinuz-PAE" kernelfile = "vmlinuz-PAE"
initrdfile = "initrd-PAE.img" initrdfile = "initrd-PAE.img"
# XXX add images section to treeinfo
# add images section to treeinfo
section = "images-xen" section = "images-xen"
data = {"kernel": "images/pxeboot/vmlinuz-PAE", data = {"kernel": "images/pxeboot/{0}".format(kernelfile),
"initrd": "images/pxeboot/initrd-PAE.img"} "initrd": "images/pxeboot/{0}".format(initrdfile)}
self.treeinfo_add_section(self.conf.treeinfo, section, data) self.treeinfo_add_section(self.conf.treeinfo, section, data)
elif kernel.is_xen: elif kernel.is_xen:
kernelfile = "vmlinuz-xen" kernelfile = "vmlinuz-xen"
initrdfile = "initrd-xen.img" initrdfile = "initrd-xen.img"
else: # XXX add images section to treeinfo
kernelfile = "vmlinuz" section = "images-xen"
initrdfile = "initrd.img" data = {"kernel": "images/pxeboot/{0}".format(kernelfile),
"initrd": "images/pxeboot/{0}".format(initrdfile)}
# add images section to treeinfo
section = "images-{0}".format(self.conf.basearch)
data = {"kernel": "images/pxeboot/vmlinuz",
"initrd": "images/pxeboot/initrd.img"}
self.treeinfo_add_section(self.conf.treeinfo, section, data) self.treeinfo_add_section(self.conf.treeinfo, section, data)
# copy the kernel and initrd image to the isolinux directory
kdst = os.path.join(self.conf.isodir, kernelfile)
idst = os.path.join(self.conf.isodir, initrdfile)
shutil.copy2(kernel.path, kdst)
shutil.copy2(initrd, idst)
# create the efi images
if self.installtree.do_efi:
efi = images.EFI(self.installtree, kernel, initrd,
self.product, self.version, self.workdir)
efiboot, efidisk = efi.create()
# copy the efi images to the images directory
shutil.copy2(efiboot, self.conf.imgdir)
shutil.copy2(efidisk, self.conf.imgdir)
# copy the kernel and initrd image to the pxe directory # copy the kernel and initrd image to the pxe directory
kdst = os.path.join(self.conf.pxedir, kernelfile) kdst = os.path.join(self.conf.pxedir, kernelfile)
idst = os.path.join(self.conf.pxedir, initrdfile) idst = os.path.join(self.conf.pxedir, initrdfile)