def create_install_iso(self): """ Create an install ISO from the disk_image as hybrid ISO bootable via legacy BIOS, EFI and as disk from Stick """ self.media_dir = mkdtemp(prefix="install-media.", dir=self.target_dir) # custom iso metadata self.custom_iso_args = ["-V", '"KIWI Installation System"', "-A", self.mbrid.get_id()] # the system image transfer is checked against a checksum log.info("Creating disk image checksum") self.squashed_contents = mkdtemp(prefix="install-squashfs.", dir=self.target_dir) checksum = Checksum(self.diskname) checksum.md5(self.squashed_contents + "/" + self.md5name) # the kiwi initrd code triggers the install by trigger files self.__create_iso_install_trigger_files() # the system image is stored as squashfs embedded file log.info("Creating squashfs embedded disk image") Command.run(["cp", "-l", self.diskname, self.squashed_contents + "/" + self.squashed_diskname]) squashed_image_file = "".join([self.target_dir, "/", self.squashed_diskname, ".squashfs"]) squashed_image = FileSystemSquashFs(device_provider=None, root_dir=self.squashed_contents) squashed_image.create_on_file(squashed_image_file) Command.run(["mv", squashed_image_file, self.media_dir]) # setup bootloader config to boot the ISO via isolinux log.info("Setting up install image bootloader configuration") bootloader_config_isolinux = BootLoaderConfig("isolinux", self.xml_state, self.media_dir) bootloader_config_isolinux.setup_install_boot_images( mbrid=None, lookup_path=self.boot_image_task.boot_root_directory ) bootloader_config_isolinux.setup_install_image_config(mbrid=None) bootloader_config_isolinux.write() # setup bootloader config to boot the ISO via EFI bootloader_config_grub = BootLoaderConfig("grub2", self.xml_state, self.media_dir) bootloader_config_grub.setup_install_boot_images( mbrid=self.mbrid, lookup_path=self.boot_image_task.boot_root_directory ) bootloader_config_grub.setup_install_image_config(mbrid=self.mbrid) bootloader_config_grub.write() # create initrd for install image log.info("Creating install image boot image") self.__create_iso_install_kernel_and_initrd() # create iso filesystem from media_dir log.info("Creating ISO filesystem") iso_image = FileSystemIsoFs(device_provider=None, root_dir=self.media_dir, custom_args=self.custom_iso_args) iso_header_offset = iso_image.create_on_file(self.isoname) # make it hybrid Iso.create_hybrid(iso_header_offset, self.mbrid, self.isoname)
def create(self): supported_archives = Defaults.get_archive_image_types() if self.requested_archive_type not in supported_archives: raise KiwiArchiveSetupError('Unknown archive type: %s' % self.requested_archive_type) if self.requested_archive_type == 'tbz': log.info('Creating XZ compressed tar archive') archive = ArchiveTar(self.__target_file_for('tar')) archive.create_xz_compressed(self.root_dir) checksum = Checksum(self.filename) log.info('--> Creating archive checksum') checksum.md5(self.checksum) self.result.add('root_archive', self.filename) self.result.add('root_archive_checksum', self.checksum) return self.result
def create_install_pxe_archive(self): """ Create an oem install tar archive suitable for installing a disk image via the network using the PXE boot protocol. The archive contains the raw disk image and its checksum as well as an install initrd and kernel plus the required kernel commandline information which needs to be added as append line in the pxelinux config file on the boot server """ self.pxe_dir = mkdtemp(prefix="pxe-install-media.", dir=self.target_dir) # the system image is transfered as xz compressed variant log.info("xz compressing disk image") pxe_image_filename = "".join([self.pxe_dir, "/", self.xml_state.xml_data.get_name(), ".xz"]) compress = Compress(source_filename=self.diskname, keep_source_on_compress=True) compress.xz() Command.run(["mv", compress.compressed_filename, pxe_image_filename]) # the system image transfer is checked against a checksum log.info("Creating disk image checksum") pxe_md5_filename = "".join([self.pxe_dir, "/", self.xml_state.xml_data.get_name(), ".md5"]) checksum = Checksum(pxe_image_filename) checksum.md5(pxe_md5_filename) # create pxe config append information # this information helps to configure the boot server correctly append_filename = "".join([self.pxe_dir, "/", self.xml_state.xml_data.get_name(), ".append"]) cmdline = "pxe=1" custom_cmdline = self.xml_state.build_type.get_kernelcmdline() if custom_cmdline: cmdline += " " + custom_cmdline with open(append_filename, "w") as append: append.write("%s\n" % cmdline) # create initrd for pxe install log.info("Creating pxe install boot image") self.__create_pxe_install_kernel_and_initrd() # create pxe install tarball log.info("Creating pxe install archive") archive = ArchiveTar(self.pxename.replace(".xz", "")) archive.create_xz_compressed(self.pxe_dir)
def create(self): supported_archives = Defaults.get_archive_image_types() if self.requested_archive_type not in supported_archives: raise KiwiArchiveSetupError( 'Unknown archive type: %s' % self.requested_archive_type ) if self.requested_archive_type == 'tbz': log.info('Creating XZ compressed tar archive') archive = ArchiveTar( self.__target_file_for('tar') ) archive.create_xz_compressed(self.root_dir) checksum = Checksum(self.filename) log.info('--> Creating archive checksum') checksum.md5(self.checksum) self.result.add( 'root_archive', self.filename ) self.result.add( 'root_archive_checksum', self.checksum ) return self.result
def create(self): log.info('Creating PXE root filesystem image') self.filesystem.create() self.image = self.filesystem.filename if self.compressed: log.info('xz compressing root filesystem image') compress = Compress(self.image) compress.xz() self.image = compress.compressed_filename log.info('Creating PXE root filesystem MD5 checksum') self.filesystem_checksum = self.filesystem.filename + '.md5' checksum = Checksum(self.image) checksum.md5(self.filesystem_checksum) # prepare boot(initrd) root system log.info('Creating PXE boot image') self.boot_image_task.prepare() # export modprobe configuration to boot image self.system_setup.export_modprobe_setup( self.boot_image_task.boot_root_directory ) # extract kernel from boot(initrd) root system kernel = Kernel(self.boot_image_task.boot_root_directory) kernel_data = kernel.get_kernel() if kernel_data: self.kernel_filename = ''.join( [self.image_name, '-', kernel_data.version, '.kernel'] ) kernel.copy_kernel( self.target_dir, self.kernel_filename ) else: raise KiwiPxeBootImageError( 'No kernel in boot image tree %s found' % self.boot_image_task.boot_root_directory ) # extract hypervisor from boot(initrd) root system if self.machine and self.machine.get_domain() == 'dom0': kernel_data = kernel.get_xen_hypervisor() if kernel_data: self.hypervisor_filename = ''.join( [self.image_name, '-', kernel_data.name] ) kernel.copy_xen_hypervisor( self.target_dir, self.hypervisor_filename ) self.result.add( 'xen_hypervisor', self.hypervisor_filename ) else: raise KiwiPxeBootImageError( 'No hypervisor in boot image tree %s found' % self.boot_image_task.boot_root_directory ) # create initrd for pxe boot self.boot_image_task.create_initrd() self.result.add( 'kernel', self.kernel_filename ) self.result.add( 'initrd', self.boot_image_task.initrd_filename ) self.result.add( 'filesystem_image', self.image ) self.result.add( 'filesystem_md5', self.filesystem_checksum ) if self.pxedeploy: log.warning( 'Creation of client config file from pxedeploy not implemented' ) return self.result
def create_install_iso(self): """ Create an install ISO from the disk_image as hybrid ISO bootable via legacy BIOS, EFI and as disk from Stick """ self.media_dir = mkdtemp( prefix='install-media.', dir=self.target_dir ) # custom iso metadata self.custom_iso_args = [ '-V', '"KIWI Installation System"', '-A', self.mbrid.get_id() ] # the system image transfer is checked against a checksum log.info('Creating disk image checksum') self.squashed_contents = mkdtemp( prefix='install-squashfs.', dir=self.target_dir ) checksum = Checksum(self.diskname) checksum.md5(self.squashed_contents + '/' + self.md5name) # the kiwi initrd code triggers the install by trigger files self.__create_iso_install_trigger_files() # the system image is stored as squashfs embedded file log.info('Creating squashfs embedded disk image') Command.run( [ 'cp', '-l', self.diskname, self.squashed_contents + '/' + self.squashed_diskname ] ) squashed_image_file = ''.join( [ self.target_dir, '/', self.squashed_diskname, '.squashfs' ] ) squashed_image = FileSystemSquashFs( device_provider=None, root_dir=self.squashed_contents ) squashed_image.create_on_file(squashed_image_file) Command.run( ['mv', squashed_image_file, self.media_dir] ) # setup bootloader config to boot the ISO via isolinux log.info('Setting up install image bootloader configuration') bootloader_config_isolinux = BootLoaderConfig( 'isolinux', self.xml_state, self.media_dir ) bootloader_config_isolinux.setup_install_boot_images( mbrid=None, lookup_path=self.boot_image_task.boot_root_directory ) bootloader_config_isolinux.setup_install_image_config( mbrid=None ) bootloader_config_isolinux.write() # setup bootloader config to boot the ISO via EFI bootloader_config_grub = BootLoaderConfig( 'grub2', self.xml_state, self.media_dir ) bootloader_config_grub.setup_install_boot_images( mbrid=self.mbrid, lookup_path=self.boot_image_task.boot_root_directory ) bootloader_config_grub.setup_install_image_config( mbrid=self.mbrid ) bootloader_config_grub.write() # create initrd for install image log.info('Creating install image boot image') self.__create_iso_install_kernel_and_initrd() # create iso filesystem from media_dir log.info('Creating ISO filesystem') iso_image = FileSystemIsoFs( device_provider=None, root_dir=self.media_dir, custom_args=self.custom_iso_args ) iso_header_offset = iso_image.create_on_file(self.isoname) # make it hybrid Iso.create_hybrid( iso_header_offset, self.mbrid, self.isoname )
def create_install_pxe_archive(self): """ Create an oem install tar archive suitable for installing a disk image via the network using the PXE boot protocol. The archive contains the raw disk image and its checksum as well as an install initrd and kernel plus the required kernel commandline information which needs to be added as append line in the pxelinux config file on the boot server """ self.pxe_dir = mkdtemp( prefix='pxe-install-media.', dir=self.target_dir ) # the system image is transfered as xz compressed variant log.info('xz compressing disk image') pxe_image_filename = ''.join( [ self.pxe_dir, '/', self.xml_state.xml_data.get_name(), '.xz' ] ) compress = Compress( source_filename=self.diskname, keep_source_on_compress=True ) compress.xz() Command.run( ['mv', compress.compressed_filename, pxe_image_filename] ) # the system image transfer is checked against a checksum log.info('Creating disk image checksum') pxe_md5_filename = ''.join( [ self.pxe_dir, '/', self.xml_state.xml_data.get_name(), '.md5' ] ) checksum = Checksum(pxe_image_filename) checksum.md5(pxe_md5_filename) # create pxe config append information # this information helps to configure the boot server correctly append_filename = ''.join( [ self.pxe_dir, '/', self.xml_state.xml_data.get_name(), '.append' ] ) cmdline = 'pxe=1' custom_cmdline = self.xml_state.build_type.get_kernelcmdline() if custom_cmdline: cmdline += ' ' + custom_cmdline with open(append_filename, 'w') as append: append.write('%s\n' % cmdline) # create initrd for pxe install log.info('Creating pxe install boot image') self.__create_pxe_install_kernel_and_initrd() # create pxe install tarball log.info('Creating pxe install archive') archive = ArchiveTar( self.pxename.replace('.xz', '') ) archive.create_xz_compressed( self.pxe_dir )
def create(self): log.info('Creating PXE root filesystem image') self.filesystem.create() self.image = self.filesystem.filename if self.compressed: log.info('xz compressing root filesystem image') compress = Compress(self.image) compress.xz() self.image = compress.compressed_filename log.info('Creating PXE root filesystem MD5 checksum') self.filesystem_checksum = self.filesystem.filename + '.md5' checksum = Checksum(self.image) checksum.md5(self.filesystem_checksum) # prepare boot(initrd) root system log.info('Creating PXE boot image') self.boot_image_task.prepare() # export modprobe configuration to boot image self.system_setup.export_modprobe_setup( self.boot_image_task.boot_root_directory) # extract kernel from boot(initrd) root system kernel = Kernel(self.boot_image_task.boot_root_directory) kernel_data = kernel.get_kernel() if kernel_data: self.kernel_filename = ''.join( [self.image_name, '-', kernel_data.version, '.kernel']) kernel.copy_kernel(self.target_dir, self.kernel_filename) else: raise KiwiPxeBootImageError( 'No kernel in boot image tree %s found' % self.boot_image_task.boot_root_directory) # extract hypervisor from boot(initrd) root system if self.machine and self.machine.get_domain() == 'dom0': kernel_data = kernel.get_xen_hypervisor() if kernel_data: self.hypervisor_filename = ''.join( [self.image_name, '-', kernel_data.name]) kernel.copy_xen_hypervisor(self.target_dir, self.hypervisor_filename) self.result.add('xen_hypervisor', self.hypervisor_filename) else: raise KiwiPxeBootImageError( 'No hypervisor in boot image tree %s found' % self.boot_image_task.boot_root_directory) # create initrd for pxe boot self.boot_image_task.create_initrd() self.result.add('kernel', self.kernel_filename) self.result.add('initrd', self.boot_image_task.initrd_filename) self.result.add('filesystem_image', self.image) self.result.add('filesystem_md5', self.filesystem_checksum) if self.pxedeploy: log.warning( 'Creation of client config file from pxedeploy not implemented' ) return self.result