def __init__(self, creatoropts=None, pkgmgr=None): """Initialise a LiveImageCreator instance. This method takes the same arguments as ImageCreator.__init__(). """ LoopImageCreator.__init__(self, creatoropts, pkgmgr) #Controls whether to use squashfs to compress the image. self.skip_compression = False #Controls whether an image minimizing snapshot should be created. # #This snapshot can be used when copying the system image from the ISO in #order to minimize the amount of data that needs to be copied; simply, #it makes it possible to create a version of the image's filesystem with #no spare space. self.skip_minimize = False #A flag which indicates i act as a convertor default false self.actasconvertor = False #The bootloader timeout from kickstart. if self.ks: self._timeout = kickstart.get_timeout(self.ks, 10) else: self._timeout = 10 #The default kernel type from kickstart. if self.ks: self._default_kernel = kickstart.get_default_kernel( self.ks, "kernel") else: self._default_kernel = None if self.ks: parts = kickstart.get_partitions(self.ks) if len(parts) > 1: raise CreatorError("Can't support multi partitions in ks file " "for this image type") # FIXME: rename rootfs img to self.name, # else can't find files when create iso self._instloops[0]['name'] = self.name + ".img" self.__isodir = None self.__modules = [ "=ata", "sym53c8xx", "aic7xxx", "=usb", "=firewire", "=mmc", "=pcmcia", "mptsas" ] if self.ks: self.__modules.extend(kickstart.get_modules(self.ks)) self._dep_checks.extend( ["isohybrid", "unsquashfs", "mksquashfs", "dd", "genisoimage"])
def do_configure_partition(self, part, cr, cr_workdir, oe_builddir, bootimg_dir, kernel_dir, native_sysroot): """ Called before do_prepare_partition(), creates syslinux config """ hdddir = "%s/hdd/boot" % cr_workdir rm_cmd = "rm -rf " + cr_workdir exec_cmd(rm_cmd) install_cmd = "install -d %s" % hdddir tmp = exec_cmd(install_cmd) splash = os.path.join(cr_workdir, "/hdd/boot/splash.jpg") if os.path.exists(splash): splashline = "menu background splash.jpg" else: splashline = "" (rootdev, root_part_uuid) = cr._get_boot_config() options = cr.ks.handler.bootloader.appendLine syslinux_conf = "" syslinux_conf += "PROMPT 0\n" timeout = kickstart.get_timeout(cr.ks) if not timeout: timeout = 0 syslinux_conf += "TIMEOUT " + str(timeout) + "\n" syslinux_conf += "\n" syslinux_conf += "ALLOWOPTIONS 1\n" syslinux_conf += "SERIAL 0 115200\n" syslinux_conf += "\n" if splashline: syslinux_conf += "%s\n" % splashline syslinux_conf += "DEFAULT boot\n" syslinux_conf += "LABEL boot\n" kernel = "/vmlinuz" syslinux_conf += "KERNEL " + kernel + "\n" if cr._ptable_format == 'msdos': rootstr = rootdev else: if not root_part_uuid: raise MountError("Cannot find the root GPT partition UUID") rootstr = "PARTUUID=%s" % root_part_uuid syslinux_conf += "APPEND label=boot root=%s %s\n" % (rootstr, options) msger.debug("Writing syslinux config %s/hdd/boot/syslinux.cfg" \ % cr_workdir) cfg = open("%s/hdd/boot/syslinux.cfg" % cr_workdir, "w") cfg.write(syslinux_conf) cfg.close()
def __init__(self, creatoropts = None, pkgmgr = None): """Initialise a LiveImageCreator instance. This method takes the same arguments as ImageCreator.__init__(). """ LoopImageCreator.__init__(self, creatoropts, pkgmgr) #Controls whether to use squashfs to compress the image. self.skip_compression = False #Controls whether an image minimizing snapshot should be created. # #This snapshot can be used when copying the system image from the ISO in #order to minimize the amount of data that needs to be copied; simply, #it makes it possible to create a version of the image's filesystem with #no spare space. self.skip_minimize = False #A flag which indicates i act as a convertor default false self.actasconvertor = False #The bootloader timeout from kickstart. if self.ks: self._timeout = kickstart.get_timeout(self.ks, 10) else: self._timeout = 10 #The default kernel type from kickstart. if self.ks: self._default_kernel = kickstart.get_default_kernel(self.ks, "kernel") else: self._default_kernel = None self.__isodir = None self.__modules = ["=ata", "sym53c8xx", "aic7xxx", "=usb", "=firewire", "=mmc", "=pcmcia", "mptsas"] if self.ks: self.__modules.extend(kickstart.get_modules(self.ks)) self._dep_checks.extend(["isohybrid", "unsquashfs", "mksquashfs", "dd", "genisoimage"])
def do_configure_partition(self, part, cr, cr_workdir, oe_builddir, bootimg_dir, kernel_dir, native_sysroot): """ Called before do_prepare_partition(), creates grubefi config """ hdddir = "%s/hdd/boot" % cr_workdir rm_cmd = "rm -rf %s" % cr_workdir exec_cmd(rm_cmd) install_cmd = "install -d %s/EFI/BOOT" % hdddir tmp = exec_cmd(install_cmd) splash = os.path.join(cr_workdir, "/EFI/boot/splash.jpg") if os.path.exists(splash): splashline = "menu background splash.jpg" else: splashline = "" (rootdev, root_part_uuid) = cr._get_boot_config() options = cr.ks.handler.bootloader.appendLine grubefi_conf = "" grubefi_conf += "serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1\n" grubefi_conf += "default=boot\n" timeout = kickstart.get_timeout(cr.ks) if not timeout: timeout = 0 grubefi_conf += "timeout=%s\n" % timeout grubefi_conf += "menuentry 'boot'{\n" kernel = "/vmlinuz" if cr._ptable_format == 'msdos': rootstr = rootdev else: if not root_part_uuid: raise MountError("Cannot find the root GPT partition UUID") rootstr = "PARTUUID=%s" % root_part_uuid grubefi_conf += "linux %s root=%s rootwait %s\n" \ % (kernel, rootstr, options) grubefi_conf += "}\n" if splashline: syslinux_conf += "%s\n" % splashline msger.debug("Writing grubefi config %s/hdd/boot/EFI/BOOT/grub.cfg" \ % cr_workdir) cfg = open("%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir, "w") cfg.write(grubefi_conf) cfg.close()