def __init__(self, xml_state, target_dir, root_dir): self.custom_args = None self.label = None self.root_dir = root_dir self.requested_image_type = xml_state.get_build_type_name() if self.requested_image_type == 'pxe': self.requested_filesystem = xml_state.build_type.get_filesystem() else: self.requested_filesystem = self.requested_image_type if not self.requested_filesystem: raise KiwiFileSystemSetupError( 'No filesystem configured in %s type' % self.requested_image_type ) self.filename = ''.join( [ target_dir, '/', xml_state.xml_data.get_name(), '.' + platform.machine(), '-' + xml_state.get_image_version(), '.', self.requested_filesystem ] ) self.blocksize = xml_state.build_type.get_target_blocksize() self.filesystem_setup = FileSystemSetup(xml_state, root_dir) self.filesystems_no_device_node = [ 'squashfs' ] self.result = Result()
class FileSystemBuilder(object): """ Filesystem image builder """ def __init__(self, xml_state, target_dir, root_dir): self.custom_args = None self.label = None self.root_dir = root_dir self.requested_image_type = xml_state.get_build_type_name() if self.requested_image_type == 'pxe': self.requested_filesystem = xml_state.build_type.get_filesystem() else: self.requested_filesystem = self.requested_image_type if not self.requested_filesystem: raise KiwiFileSystemSetupError( 'No filesystem configured in %s type' % self.requested_image_type) self.filename = ''.join([ target_dir, '/', xml_state.xml_data.get_name(), '.' + platform.machine(), '-' + xml_state.get_image_version(), '.', self.requested_filesystem ]) self.blocksize = xml_state.build_type.get_target_blocksize() self.filesystem_setup = FileSystemSetup(xml_state, root_dir) self.filesystems_no_device_node = ['squashfs'] self.result = Result() def create(self): log.info('Creating %s filesystem', self.requested_filesystem) supported_filesystems = Defaults.get_filesystem_image_types() if self.requested_filesystem not in supported_filesystems: raise KiwiFileSystemSetupError('Unknown filesystem: %s' % self.requested_filesystem) if self.requested_filesystem not in self.filesystems_no_device_node: self.__operate_on_loop() else: self.__operate_on_file() self.result.add('filesystem_image', self.filename) return self.result def __operate_on_loop(self): filesystem = None loop_provider = LoopDevice(self.filename, self.filesystem_setup.get_size_mbytes(), self.blocksize) loop_provider.create() filesystem = FileSystem(self.requested_filesystem, loop_provider, self.root_dir, self.custom_args) filesystem.create_on_device(self.label) log.info('--> Syncing data to filesystem on %s', loop_provider.get_device()) exclude_list = ['image', '.profile', '.kconfig', 'var/cache/kiwi'] filesystem.sync_data(exclude_list) def __operate_on_file(self): default_provider = DeviceProvider() filesystem = FileSystem(self.requested_filesystem, default_provider, self.root_dir, self.custom_args) filesystem.create_on_file(self.filename, self.label)
def __init__(self, xml_state, target_dir, root_dir): self.custom_args = None self.label = None self.root_dir = root_dir self.requested_image_type = xml_state.get_build_type_name() if self.requested_image_type == 'pxe': self.requested_filesystem = xml_state.build_type.get_filesystem() else: self.requested_filesystem = self.requested_image_type if not self.requested_filesystem: raise KiwiFileSystemSetupError( 'No filesystem configured in %s type' % self.requested_image_type) self.filename = ''.join([ target_dir, '/', xml_state.xml_data.get_name(), '.' + platform.machine(), '-' + xml_state.get_image_version(), '.', self.requested_filesystem ]) self.blocksize = xml_state.build_type.get_target_blocksize() self.filesystem_setup = FileSystemSetup(xml_state, root_dir) self.filesystems_no_device_node = ['squashfs'] self.result = Result()
class FileSystemBuilder(object): """ Filesystem image builder """ def __init__(self, xml_state, target_dir, root_dir): self.custom_args = None self.label = None self.root_dir = root_dir self.requested_image_type = xml_state.get_build_type_name() if self.requested_image_type == 'pxe': self.requested_filesystem = xml_state.build_type.get_filesystem() else: self.requested_filesystem = self.requested_image_type if not self.requested_filesystem: raise KiwiFileSystemSetupError( 'No filesystem configured in %s type' % self.requested_image_type ) self.filename = ''.join( [ target_dir, '/', xml_state.xml_data.get_name(), '.' + platform.machine(), '-' + xml_state.get_image_version(), '.', self.requested_filesystem ] ) self.blocksize = xml_state.build_type.get_target_blocksize() self.filesystem_setup = FileSystemSetup(xml_state, root_dir) self.filesystems_no_device_node = [ 'squashfs' ] self.result = Result() def create(self): log.info( 'Creating %s filesystem', self.requested_filesystem ) supported_filesystems = Defaults.get_filesystem_image_types() if self.requested_filesystem not in supported_filesystems: raise KiwiFileSystemSetupError( 'Unknown filesystem: %s' % self.requested_filesystem ) if self.requested_filesystem not in self.filesystems_no_device_node: self.__operate_on_loop() else: self.__operate_on_file() self.result.add( 'filesystem_image', self.filename ) return self.result def __operate_on_loop(self): filesystem = None loop_provider = LoopDevice( self.filename, self.filesystem_setup.get_size_mbytes(), self.blocksize ) loop_provider.create() filesystem = FileSystem( self.requested_filesystem, loop_provider, self.root_dir, self.custom_args ) filesystem.create_on_device(self.label) log.info( '--> Syncing data to filesystem on %s', loop_provider.get_device() ) exclude_list = [ 'image', '.profile', '.kconfig', 'var/cache/kiwi' ] filesystem.sync_data(exclude_list) def __operate_on_file(self): default_provider = DeviceProvider() filesystem = FileSystem( self.requested_filesystem, default_provider, self.root_dir, self.custom_args ) filesystem.create_on_file( self.filename, self.label )