From f36526d1c94156b9b4a0301aaf88cbf891dcf028 Mon Sep 17 00:00:00 2001 From: Martin Gracik Date: Thu, 3 Mar 2011 14:26:03 +0100 Subject: [PATCH] Added s390 and x86 pseudo code --- pseudo/s390.pseudo.py | 74 ++++++++++++++++++++ pseudo/x86.pseudo.py | 155 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 229 insertions(+) create mode 100644 pseudo/s390.pseudo.py create mode 100644 pseudo/x86.pseudo.py diff --git a/pseudo/s390.pseudo.py b/pseudo/s390.pseudo.py new file mode 100644 index 00000000..c675169d --- /dev/null +++ b/pseudo/s390.pseudo.py @@ -0,0 +1,74 @@ +# s390.pseudo.py + + +##### constants ##### + +ANABOOTDIR = "usr/share/anaconda/boot" + +IMAGESDIR = "images" + +INITRD_ADDRESS = "0x02000000" + +ADDRSIZE = "usr/%s/anaconda/addrsize" % libdir +MKS390CDBOOT = "usr/%s/anaconda/mk-s390-cdboot" % libdir + + +##### main() ##### + +""" kernellist, installroot, outputroot, product, version, treeinfo, bootiso + +""" + +# create directories +makedirs(joinpaths(outputroot, IMAGESDIR)) + +# copy redhat.exec +copy(joinpaths(installroot, ANABOOTDIR, "redhat.exec"), + joinpaths(outputroot, IMAGESDIR)) + +# copy generic.prm +generic_prm = copy(joinpaths(installroot, ANABOOTDIR, "generic.prm"), + joinpaths(outputroot, IMAGESDIR)) + +# copy generic.ins +generic_ins = copy(joinpaths(installroot, ANABOOTDIR, "generic.ins"), + outputroot) + +replace(generic_ins, "@INITRD_LOAD_ADDRESS@", INITRD_ADDRESS) + +for kernel in kernellist: + + # copy kernel + kernel.fname = "kernel.img" + kernel.fpath = copy(kernel.fpath, + joinpaths(outputroot, IMAGESDIR, kernel.fname)) + + # create and copy initrd + initrd_fname = "initrd.img" + initrd_fpath = copy(create_initrd(kernel), + joinpaths(outputroot, IMAGESDIR, initrd_fname)) + + # run addrsize + initrd_addrsize = "initrd_addrsize" + rc = exec([ADDRSIZE, INITRD_ADDRESS, initrd_fpath, + joinpaths(outputroot, IMAGESDIR, initrd_addrsize)]) + + # add kernel and initrd to .treeinfo + with open(treeinfo, "a") as f: + f.write("[images-%s]\n" % kernel.arch) + f.write("kernel = %s\n" % joinpaths(IMAGESDIR, kernel.fname)) + f.write("initrd = %s\n" % joinpaths(IMAGESDIR, initrd_fname)) + f.write("initrd.addrsize = %s\n" % joinpaths(IMAGESDIR, + initrd_addrsize)) + f.write("generic.prm = %s\n" % joinpaths(IMAGESDIR, + basename(generic_prm))) + f.write("generic.ins = %s\n" % basename(generic_ins)) + f.write("cdboot.img = %s\n" % joinpaths(IMAGESDIR, bootiso)) + +if (bootiso): + # create boot.iso + bootiso_fpath = joinpaths(outputroot, IMAGESDIR, bootiso) + + # run mks390cdboot + rc = exec([MKS390CDBOOT, "-i", kernel.fpath, "-r", initrd_fpath, + "-p", generic_prm, "-o", bootiso_fpath]) diff --git a/pseudo/x86.pseudo.py b/pseudo/x86.pseudo.py new file mode 100644 index 00000000..3bd458e1 --- /dev/null +++ b/pseudo/x86.pseudo.py @@ -0,0 +1,155 @@ +# x86.pseudo.py + + +##### constants ##### + +ANABOOTDIR = "usr/share/anaconda/boot" + +ISOLINUXDIR = "isolinux" +IMAGESDIR = "images" +PXEBOOTDIR = "images/pxeboot" + +ISOLINUX_BIN = "usr/share/syslinux/isolinux.bin" +SYSLINUX_CFG = "usr/share/anaconda/boot/syslinux.cfg" + +ISOHYBRID = "isohybrid" +IMPLANTISOMD5 = "implantisomd5" + + +##### main() ##### + +""" kernellist, installroot, outputroot, product, version, treeinfo, bootiso, + basearch, uefi_boot_iso + +""" + +# create directories +makedirs(joinpaths(outputroot, ISOLINUXDIR)) +makedirs(joinpaths(outputroot, PXEBOOTDIR)) + +# check for isolinux.bin +isolinux_bin = joinpaths(installroot, ISOLINUX_BIN) +if (not exists(isolinux_bin)): + # XXX fatal? + raise Exception("isolinux.bin not present") + +# copy isolinux.bin to isolinux dir +copy(isolinux_bin, joinpaths(outputroot, ISOLINUXDIR)) + +# copy syslinux.cfg to isolinux dir (XXX rename to isolinux.cfg) +isolinux_cfg = copy(joinpaths(installroot, SYSLINUX_CFG), + joinpaths(outputroot, ISOLINUXDIR, "isolinux.cfg")) + +replace(isolinux_cfg, "@PRODUCT@", product) +replace(isolinux_cfg, "@VERSION@", version) + +# copy memtest (XXX not from installroot/boot ? +memtest = glob(joinpaths(installroot, ANABOOTDIR, "memtest*")) +if memtest: + copy(memtest[-1], joinpaths(outputroot, ISOLINUXDIR, "memtest")) + with open(isolinux_cfg, "a") as f: + f.write("label memtest86\n") + f.write(" menu label ^Memory test\n") + f.write(" kernel memtest\n") + f.write(" append -\n") + +# copy *.msg files +msgfiles = glob(joinpaths(installroot, ANABOOTDIR, "*.msg")) +if (not msgfiles): + raise Exception("message files not present") + +for source_path in msgfiles: + target_path = copy(source_path, joinpaths(outputroot, ISOLINUXDIR)) + replace(target_path, "@VERSION@", version) + +# copy syslinux vesa splash and vesamenu.c32 +splash = joinpaths(installroot, ANABOOTDIR, "syslinux-vesa-splash.jpg") +if (not exists(splash)): + raise Exception("syslinux-vesa-splash.jpg not present") + +splash = copy(splash, joinpaths(outputroot, ISOLINUXDIR, "splash.jpg")) +copy(joinpaths(installroot, "usr/share/syslinux/vesamenu.c32"), + joinpaths(outputroot, ISOLINUXDIR)) + +# set up isolinux.cfg +replace(isolinux_cfg, "default linux", "default vesamenu.c32") +replace(isolinux_cfg, "prompt 1", "#prompt 1") + +# copy grub.conf +grubconf = copy(joinpaths(installroot, ANABOOTDIR, "grub.conf"), + joinpaths(outputroot, ISOLINUXDIR)) + +replace(grubconf, "@PRODUCT@", product) +replace(grubconf, "@VERSION@", version) + +# create images +for kernel in kernellist: + + # set up file names + suffix = "" + if (kernel.type == K_PAE): + suffix = "-PAE" + elif (kernel.type == K_XEN): + suffix = "-XEN" + + kernel.fname = "vmlinuz%s" % suffix + if (not suffix): + # copy kernel to isolinux dir + kernel.fpath = copy(kernel.fpath, + joinpaths(outputroot, ISOLINUXDIR, kernel.fname)) + + # create link in pxeboot dir + os.link(kernel.fpath, joinpaths(outputroot, PXEBOOTDIR, kernel.fname)) + else: + # copy kernel to pxeboot dir + kernel.fpath = copy(kernel.fpath, + joinpaths(outputroot, PXEBOOTDIR, kernel.fname)) + + # create and copy initrd to pxeboot dir + initrd_fname = "initrd%s.img" % suffix + initrd_fpath = copy(create_initrd(kernel), + joinpaths(outputroot, PXEBOOTDIR, initrd_fname)) + + if (not suffix): + # create link in isolinux dir + os.link(initrd_fpath, joinpaths(outputroot, ISOLINUXDIR, initrd_fname)) + + # add kernel and initrd to .treeinfo + with open(treeinfo, "a") as f: + f.write("[images-%s]\n" % "xen" if suffix else basearch) + f.write("kernel = %s\n" % joinpaths(PXEBOOTDIR, kernel.fname)) + f.write("initrd = %s\n" % joinpaths(PXEBOOTDIR, initrd_fname)) + + if (not suffix): + # add boot.iso to .treeinfo + with open(treeinfo, "a") as f: + f.write("boot.iso = %s\n" % joinpaths(IMAGESDIR, bootiso)) + +if (bootiso): + # define efiargs and efigraft + efiargs, efigraft = [], [] + if (uefi_boot_iso and + exists(joinpaths(outputroot, IMAGESDIR, "efiboot.img"))): + + efiargs = ["-eltorito-alt-boot", "-e", + joinpaths(IMAGESDIR, "efiboot.img"), "-no-emul-boot"] + efigraft = ["EFI/BOOT=%s/EFI/BOOT" % outputroot] + + # create boot.iso + bootiso_fpath = joinpaths(outputroot, IMAGESDIR, bootiso) + + # run mkisofs + rc = exec([MKISOFS, "-v", "-o", bootiso_fpath, "-b", + "%s/isolinux.bin" % ISOLINUXDIR, "-c", + "%s/boot.cat" % ISOLINUXDIR, "-no-emul-boot", "-boot-load-size", + "4", "-boot-info-table"] + EFIARGS + ["-R", "-J", "-V", + "'%s'" % product, "-T", "-graft-points", + "isolinux=%s" % joinpaths(outputroot, ISOLINUXDIR), + "images=%s" % joinpaths(outputroot, IMAGESDIR)] + EFIGRAFT) + + if (exists(ISOHYBRID)): + # run isohybrid + rc = exec([ISOHYBRID, bootiso_fpath]) + + # run implantisomd5 + rc = exec([IMPLANTISOMD5, bootiso_fpath])