def process(self): """ reformats raw disk image and its format to a new disk geometry using the qemu tool chain """ self.manual = Help() if self.command_args.get('help') is True: return self.manual.show('kiwi::image::resize') abs_target_dir_path = os.path.abspath( self.command_args['--target-dir']) if self.command_args['--root']: image_root = os.path.abspath( os.path.normpath(self.command_args['--root'])) else: image_root = os.sep.join( [abs_target_dir_path, 'build', 'image-root']) self.load_xml_description(image_root) disk_format = self.xml_state.build_type.get_format() image_format = DiskFormat(disk_format or 'raw', self.xml_state, image_root, abs_target_dir_path) if not image_format.has_raw_disk(): raise KiwiImageResizeError( 'no raw disk image {0} found in build results'.format( image_format.diskname)) new_disk_size = StringToSize.to_bytes(self.command_args['--size']) # resize raw disk log.info('Resizing raw disk to {0} bytes'.format(new_disk_size)) resize_result = image_format.resize_raw_disk(new_disk_size) # resize raw disk partition table firmware = FirmWare(self.xml_state) loop_provider = LoopDevice(image_format.diskname) loop_provider.create(overwrite=False) partitioner = Partitioner(firmware.get_partition_table_type(), loop_provider) partitioner.resize_table() del loop_provider # resize disk format from resized raw disk if disk_format and resize_result is True: log.info('Creating {0} disk format from resized raw disk'.format( disk_format)) image_format.create_image_format() elif resize_result is False: log.info('Raw disk is already at {0} bytes'.format(new_disk_size))
def create_disk_format(self, result_instance): """ Create a bootable disk format from a previously created raw disk image """ if self.image_format: log.info('Creating %s Disk Format', self.image_format) disk_format = DiskFormat(self.image_format, self.xml_state, self.root_dir, self.target_dir) disk_format.create_image_format() disk_format.store_to_result(result_instance) return result_instance
def create_disk_format(self, result_instance): """ Create a bootable disk format from a previously created raw disk image """ if self.image_format: log.info('Creating %s Disk Format', self.image_format) disk_format = DiskFormat( self.image_format, self.xml_state, self.root_dir, self.target_dir ) disk_format.create_image_format() disk_format.store_to_result(result_instance) return result_instance
def create_disk_format(self, result_instance): """ Create a bootable disk format from a previously created raw disk image :param object result_instance: instance of :class:`Result` :return: updated result_instance :rtype: instance of :class:`Result` """ if self.image_format: log.info('Creating %s Disk Format', self.image_format) disk_format = DiskFormat(self.image_format, self.xml_state, self.root_dir, self.target_dir) disk_format.create_image_format() disk_format.store_to_result(result_instance) return result_instance
def create_disk_format(self, result_instance): """ Create a bootable disk format from a previously created raw disk image :param object result_instance: instance of :class:`Result` :return: updated result_instance :rtype: instance of :class:`Result` """ if self.image_format: log.info('Creating %s Disk Format', self.image_format) disk_format = DiskFormat( self.image_format, self.xml_state, self.root_dir, self.target_dir ) disk_format.create_image_format() disk_format.store_to_result(result_instance) return result_instance
def process(self): """ reformats raw disk image and its format to a new disk geometry using the qemu tool chain """ self.manual = Help() if self.command_args.get('help') is True: return self.manual.show('kiwi::image::resize') abs_target_dir_path = os.path.abspath( self.command_args['--target-dir'] ) if self.command_args['--root']: image_root = os.path.abspath( os.path.normpath(self.command_args['--root']) ) else: image_root = os.sep.join( [abs_target_dir_path, 'build', 'image-root'] ) self.load_xml_description( image_root ) disk_format = self.xml_state.build_type.get_format() image_format = DiskFormat( disk_format or 'raw', self.xml_state, image_root, abs_target_dir_path ) if not image_format.has_raw_disk(): raise KiwiImageResizeError( 'no raw disk image {0} found in build results'.format( image_format.diskname ) ) new_disk_size = StringToSize.to_bytes(self.command_args['--size']) # resize raw disk log.info( 'Resizing raw disk to {0} bytes'.format(new_disk_size) ) resize_result = image_format.resize_raw_disk(new_disk_size) # resize raw disk partition table firmware = FirmWare(self.xml_state) loop_provider = LoopDevice(image_format.diskname) loop_provider.create(overwrite=False) partitioner = Partitioner( firmware.get_partition_table_type(), loop_provider ) partitioner.resize_table() del loop_provider # resize disk format from resized raw disk if disk_format and resize_result is True: log.info( 'Creating {0} disk format from resized raw disk'.format( disk_format ) ) image_format.create_image_format() elif resize_result is False: log.info( 'Raw disk is already at {0} bytes'.format(new_disk_size) )