コード例 #1
0
ファイル: filesystem_clicfs.py プロジェクト: k0da/kiwi-1
    def create_on_file(self, filename, label=None):
        # there is no label which could be set for clicfs
        # thus this parameter is not used
        self.container_dir = mkdtemp()
        clicfs_container_filesystem = self.container_dir + '/fsdata.ext4'
        loop_provider = LoopDevice(
            clicfs_container_filesystem,
            self.__get_container_filesystem_size_mbytes()
        )
        loop_provider.create()
        filesystem = FileSystemExt4(
            loop_provider, self.root_dir
        )
        filesystem.create_on_device()
        filesystem.sync_data()
        Command.run(
            ['resize2fs', '-f', loop_provider.get_device(), '-M']
        )

        # force cleanup and umount of container filesystem
        # before mkclicfs is called
        del filesystem

        Command.run(
            ['mkclicfs', clicfs_container_filesystem, filename]
        )
コード例 #2
0
 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)
コード例 #3
0
    def create_on_file(self, filename, label=None):
        # there is no label which could be set for clicfs
        # thus this parameter is not used
        self.container_dir = mkdtemp()
        clicfs_container_filesystem = self.container_dir + '/fsdata.ext4'
        loop_provider = LoopDevice(
            clicfs_container_filesystem,
            self.__get_container_filesystem_size_mbytes())
        loop_provider.create()
        filesystem = FileSystemExt4(loop_provider, self.root_dir)
        filesystem.create_on_device()
        filesystem.sync_data()
        Command.run(['resize2fs', '-f', loop_provider.get_device(), '-M'])

        # force cleanup and umount of container filesystem
        # before mkclicfs is called
        del filesystem

        Command.run(['mkclicfs', clicfs_container_filesystem, filename])
コード例 #4
0
ファイル: filesystem_builder.py プロジェクト: k0da/kiwi-1
 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)
コード例 #5
0
ファイル: disk_builder.py プロジェクト: k0da/kiwi-1
    def create(self):
        if self.install_media and self.build_type_name != 'oem':
            raise KiwiInstallMediaError(
                'Install media requires oem type setup, got %s' %
                self.build_type_name
            )

        # setup recovery archive, cleanup and create archive if requested
        self.system_setup.create_recovery_archive()

        # prepare boot(initrd) root system
        log.info('Preparing boot system')
        self.boot_image_task.prepare()

        # precalculate needed disk size
        disksize_mbytes = self.disk_setup.get_disksize_mbytes()

        # create the disk
        log.info('Creating raw disk image %s', self.diskname)
        loop_provider = LoopDevice(
            self.diskname, disksize_mbytes, self.blocksize
        )
        loop_provider.create()

        self.disk = Disk(
            self.firmware.get_partition_table_type(), loop_provider
        )

        # create the bootloader instance
        self.bootloader_config = BootLoaderConfig(
            self.bootloader, self.xml_state, self.root_dir,
            {'targetbase': loop_provider.get_device()}
        )

        # create disk partitions and instance device map
        device_map = self.__build_and_map_disk_partitions()

        # create raid on current root device if requested
        if self.mdraid:
            self.raid_root = RaidDevice(device_map['root'])
            self.raid_root.create_degraded_raid(raid_level=self.mdraid)
            device_map['root'] = self.raid_root.get_device()

        # create luks on current root device if requested
        if self.luks:
            self.luks_root = LuksDevice(device_map['root'])
            self.luks_root.create_crypto_luks(
                passphrase=self.luks, os=self.luks_os
            )
            device_map['root'] = self.luks_root.get_device()

        # create filesystems on boot partition(s) if any
        self.__build_boot_filesystems(device_map)

        # create volumes and filesystems for root system
        if self.volume_manager_name:
            volume_manager_custom_parameters = {
                'root_filesystem_args':
                    self.custom_filesystem_args,
                'root_label':
                    self.disk_setup.get_root_label(),
                'root_is_snapshot':
                    self.xml_state.build_type.get_btrfs_root_is_snapshot()
            }
            volume_manager = VolumeManager(
                self.volume_manager_name, device_map['root'],
                self.root_dir + '/',
                self.volumes, volume_manager_custom_parameters
            )
            volume_manager.setup(
                self.volume_group_name
            )
            volume_manager.create_volumes(
                self.requested_filesystem
            )
            volume_manager.mount_volumes()
            self.system = volume_manager
            device_map['root'] = volume_manager.get_device()['root']
        else:
            log.info(
                'Creating root(%s) filesystem on %s',
                self.requested_filesystem, device_map['root'].get_device()
            )
            filesystem = FileSystem(
                self.requested_filesystem, device_map['root'],
                self.root_dir + '/',
                self.custom_filesystem_args
            )
            filesystem.create_on_device(
                label=self.disk_setup.get_root_label()
            )
            self.system = filesystem

        # create a random image identifier
        self.mbrid = ImageIdentifier()
        self.mbrid.calculate_id()

        # create first stage metadata to boot image
        self.__write_partition_id_config_to_boot_image()

        self.__write_recovery_metadata_to_boot_image()

        self.__write_raid_config_to_boot_image()

        self.system_setup.export_modprobe_setup(
            self.boot_image_task.boot_root_directory
        )

        # create first stage metadata to system image
        self.__write_image_identifier_to_system_image()

        self.__write_crypttab_to_system_image()

        # create initrd cpio archive
        self.boot_image_task.create_initrd(self.mbrid)

        # create second stage metadata to boot
        self.__copy_first_boot_files_to_system_image()

        self.__write_bootloader_config_to_system_image(device_map)

        self.mbrid.write_to_disk(
            self.disk.storage_provider
        )

        # syncing system data to disk image
        log.info('Syncing system to image')
        if self.system_efi:
            log.info('--> Syncing EFI boot data to EFI partition')
            self.system_efi.sync_data()

        if self.system_boot:
            log.info('--> Syncing boot data at extra partition')
            self.system_boot.sync_data(
                self.__get_exclude_list_for_boot_data_sync()
            )

        log.info('--> Syncing root filesystem data')
        self.system.sync_data(
            self.__get_exclude_list_for_root_data_sync(device_map)
        )

        # install boot loader
        self.__install_bootloader(device_map)

        self.result.add(
            'disk_image', self.diskname
        )

        # create install media if requested
        if self.install_media:
            if self.image_format:
                log.warning('Install image requested, ignoring disk format')
            if self.install_iso or self.install_stick:
                log.info('Creating hybrid ISO installation image')
                self.install_image.create_install_iso()
                self.result.add(
                    'installation_image', self.install_image.isoname
                )

            if self.install_pxe:
                log.info('Creating PXE installation archive')
                self.install_image.create_install_pxe_archive()
                self.result.add(
                    'installation_pxe_archive', self.install_image.pxename
                )

        # create disk image format if requested
        elif 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()
            self.result.add(
                'disk_format_image',
                self.target_dir + '/' + disk_format.get_target_name_for_format(
                    self.image_format
                )
            )

        return self.result