def setup(self): Defaults.set_platform_name('x86_64') self.size = mock.Mock() self.size.customize = mock.Mock(return_value=42) self.size.accumulate_mbyte_file_sizes = mock.Mock(return_value=42) kiwi.storage.setup.SystemSize = mock.Mock(return_value=self.size) description = XMLDescription('../data/example_disk_size_config.xml') self.setup = DiskSetup(XMLState(description.load()), 'root_dir') description = XMLDescription( '../data/example_disk_size_volume_config.xml') self.setup_volumes = DiskSetup(XMLState(description.load()), 'root_dir') description = XMLDescription( '../data/example_disk_size_oem_volume_config.xml') self.setup_oem_volumes = DiskSetup(XMLState(description.load()), 'root_dir') description = XMLDescription( '../data/example_disk_size_volume_too_small_config.xml') self.setup_volume_too_small = DiskSetup(XMLState(description.load()), 'root_dir') description = XMLDescription( '../data/example_disk_size_partition_too_small_config.xml') self.setup_partition_too_small = DiskSetup( XMLState(description.load()), 'root_dir') description = XMLDescription( '../data/example_disk_size_empty_vol_config.xml') self.setup_empty_volumes = DiskSetup(XMLState(description.load()), 'root_dir') description = XMLDescription( '../data/example_disk_size_vol_root_config.xml') self.setup_root_volume = DiskSetup(XMLState(description.load()), 'root_dir') description = XMLDescription( '../data/example_disk_size_partitions_config.xml') self.setup_partitions = DiskSetup(XMLState(description.load()), 'root_dir') Defaults.set_platform_name('ppc64') description = XMLDescription( '../data/example_ppc_disk_size_config.xml') self.setup_ppc = DiskSetup(XMLState(description.load()), 'root_dir') Defaults.set_platform_name('arm64') description = XMLDescription( '../data/example_arm_disk_size_config.xml') self.setup_arm = DiskSetup(XMLState(description.load()), 'root_dir')
def setup(self, mock_machine): mock_machine.return_value = 'x86_64' self.size = mock.Mock() self.size.customize = mock.Mock(return_value=42) self.size.accumulate_mbyte_file_sizes = mock.Mock(return_value=42) kiwi.storage.setup.SystemSize = mock.Mock(return_value=self.size) description = XMLDescription('../data/example_disk_size_config.xml') self.setup = DiskSetup(XMLState(description.load()), 'root_dir') description = XMLDescription( '../data/example_disk_size_volume_config.xml') self.setup_volumes = DiskSetup(XMLState(description.load()), 'root_dir') description = XMLDescription( '../data/example_disk_size_empty_vol_config.xml') self.setup_empty_volumes = DiskSetup(XMLState(description.load()), 'root_dir') description = XMLDescription( '../data/example_disk_size_vol_root_config.xml') self.setup_root_volume = DiskSetup(XMLState(description.load()), 'root_dir') mock_machine.return_value = 'ppc64' description = XMLDescription( '../data/example_ppc_disk_size_config.xml') self.setup_ppc = DiskSetup(XMLState(description.load()), 'root_dir') mock_machine.return_value = 'arm64' description = XMLDescription( '../data/example_arm_disk_size_config.xml') self.setup_arm = DiskSetup(XMLState(description.load()), 'root_dir')
def get_boot_path(self, target='disk'): """ Bootloader lookup path on boot device If the bootloader reads the data it needs to boot, it does that from the configured boot device. Depending if that device is an extra boot partition or the root partition or or based on a non standard filesystem like a btrfs snapshot, the path name varies :param string target: target name: disk|iso :return: path name :rtype: str """ if target != 'disk' and target != 'iso': raise KiwiBootLoaderTargetError( 'Invalid boot loader target %s' % target ) bootpath = '/boot' need_boot_partition = False if target == 'disk': disk_setup = DiskSetup(self.xml_state, self.boot_dir) need_boot_partition = disk_setup.need_boot_partition() if need_boot_partition: # if an extra boot partition is used we will find the # data directly in the root of this partition and not # below the boot/ directory bootpath = '/' if target == 'disk': if not need_boot_partition: filesystem = self.xml_state.build_type.get_filesystem() volumes = self.xml_state.get_volumes() if filesystem == 'btrfs' and volumes: # grub boot data paths must not be in a subvolume # otherwise grub won't be able to find its config file grub2_boot_data_paths = ['boot', 'boot/grub', 'boot/grub2'] for volume in volumes: if volume.name in grub2_boot_data_paths: raise KiwiBootLoaderTargetError( '{0} must not be a subvolume'.format( volume.name ) ) if target == 'iso': bootpath = '/boot/' + self.arch + '/loader' return bootpath
def __init__(self, xml_state, target_dir, root_dir, custom_args=None): self.arch = platform.machine() if self.arch == 'i686' or self.arch == 'i586': self.arch = 'ix86' self.root_dir = root_dir self.target_dir = target_dir self.xml_state = xml_state self.spare_part_mbsize = xml_state.get_build_type_spare_part_size() self.spare_part_fs = xml_state.build_type.get_spare_part_fs() self.spare_part_is_last = xml_state.build_type.get_spare_part_is_last() self.spare_part_mountpoint = \ xml_state.build_type.get_spare_part_mountpoint() self.persistency_type = xml_state.build_type.get_devicepersistency() self.root_filesystem_is_overlay = xml_state.build_type.get_overlayroot( ) self.custom_root_mount_args = xml_state.get_fs_mount_option_list() self.custom_root_creation_args = xml_state.get_fs_create_option_list() self.build_type_name = xml_state.get_build_type_name() self.image_format = xml_state.build_type.get_format() self.install_iso = xml_state.build_type.get_installiso() self.install_stick = xml_state.build_type.get_installstick() self.install_pxe = xml_state.build_type.get_installpxe() self.blocksize = xml_state.build_type.get_target_blocksize() self.volume_manager_name = xml_state.get_volume_management() self.volumes = xml_state.get_volumes() self.volume_group_name = xml_state.get_volume_group_name() self.mdraid = xml_state.build_type.get_mdraid() self.hybrid_mbr = xml_state.build_type.get_gpt_hybrid_mbr() self.force_mbr = xml_state.build_type.get_force_mbr() self.luks = xml_state.build_type.get_luks() self.luks_os = xml_state.build_type.get_luksOS() self.xen_server = xml_state.is_xen_server() self.requested_filesystem = xml_state.build_type.get_filesystem() self.requested_boot_filesystem = \ xml_state.build_type.get_bootfilesystem() self.bootloader = xml_state.build_type.get_bootloader() self.initrd_system = xml_state.get_initrd_system() self.target_removable = xml_state.build_type.get_target_removable() self.root_filesystem_is_multipath = \ xml_state.get_oemconfig_oem_multipath_scan() self.disk_setup = DiskSetup(xml_state, root_dir) self.unpartitioned_bytes = \ xml_state.get_build_type_unpartitioned_bytes() self.custom_args = custom_args self.signing_keys = None if custom_args and 'signing_keys' in custom_args: self.signing_keys = custom_args['signing_keys'] self.boot_image = BootImage(xml_state, target_dir, root_dir, signing_keys=self.signing_keys) self.firmware = FirmWare(xml_state) self.system_setup = SystemSetup(xml_state=xml_state, root_dir=self.root_dir) self.diskname = ''.join([ target_dir, '/', xml_state.xml_data.get_name(), '.' + self.arch, '-' + xml_state.get_image_version(), '.raw' ]) self.boot_is_crypto = True if self.luks and not \ self.disk_setup.need_boot_partition() else False self.install_media = self._install_image_requested() self.generic_fstab_entries = [] # an instance of a class with the sync_data capability # representing the entire image system except for the boot/ area # which could live on another part of the disk self.system = None # an instance of a class with the sync_data capability # representing the boot/ area of the disk if not part of # self.system self.system_boot = None # an instance of a class with the sync_data capability # representing the boot/efi area of the disk self.system_efi = None # an instance of a class with the sync_data capability # representing the spare_part_mountpoint area of the disk self.system_spare = None # result store self.result = Result(xml_state) self.runtime_config = RuntimeConfig()
def __init__(self, xml_state: XMLState, target_dir: str, root_dir: str, custom_args: Dict = None): self.arch = Defaults.get_platform_name() self.root_dir = root_dir self.target_dir = target_dir self.xml_state = xml_state self.spare_part_mbsize = xml_state.get_build_type_spare_part_size() self.spare_part_fs = xml_state.build_type.get_spare_part_fs() self.spare_part_is_last = xml_state.build_type.get_spare_part_is_last() self.spare_part_mountpoint = \ xml_state.build_type.get_spare_part_mountpoint() self.persistency_type = xml_state.build_type.get_devicepersistency() self.root_filesystem_is_overlay = xml_state.build_type.get_overlayroot( ) self.custom_root_mount_args = xml_state.get_fs_mount_option_list() self.custom_root_creation_args = xml_state.get_fs_create_option_list() self.build_type_name = xml_state.get_build_type_name() self.image_format = xml_state.build_type.get_format() self.install_iso = xml_state.build_type.get_installiso() self.install_stick = xml_state.build_type.get_installstick() self.install_pxe = xml_state.build_type.get_installpxe() self.blocksize = xml_state.build_type.get_target_blocksize() self.volume_manager_name = xml_state.get_volume_management() self.volumes = xml_state.get_volumes() self.custom_partitions = xml_state.get_partitions() self.volume_group_name = xml_state.get_volume_group_name() self.mdraid = xml_state.build_type.get_mdraid() self.hybrid_mbr = xml_state.build_type.get_gpt_hybrid_mbr() self.force_mbr = xml_state.build_type.get_force_mbr() self.luks = xml_state.build_type.get_luks() self.luks_os = xml_state.build_type.get_luksOS() self.xen_server = xml_state.is_xen_server() self.requested_filesystem = xml_state.build_type.get_filesystem() self.requested_boot_filesystem = \ xml_state.build_type.get_bootfilesystem() self.bootloader = xml_state.get_build_type_bootloader_name() self.initrd_system = xml_state.get_initrd_system() self.target_removable = xml_state.build_type.get_target_removable() self.root_filesystem_is_multipath = \ xml_state.get_oemconfig_oem_multipath_scan() self.disk_resize_requested = \ xml_state.get_oemconfig_oem_resize() self.swap_mbytes = xml_state.get_oemconfig_swap_mbytes() self.disk_setup = DiskSetup(xml_state, root_dir) self.unpartitioned_bytes = \ xml_state.get_build_type_unpartitioned_bytes() self.custom_args = custom_args self.signing_keys = None if custom_args and 'signing_keys' in custom_args: self.signing_keys = custom_args['signing_keys'] self.boot_image = BootImage.new(xml_state, target_dir, root_dir, signing_keys=self.signing_keys) self.firmware = FirmWare(xml_state) self.system_setup = SystemSetup(xml_state=xml_state, root_dir=self.root_dir) self.bundle_format = xml_state.get_build_type_bundle_format() self.diskname = ''.join([ target_dir, '/', xml_state.xml_data.get_name(), '.' + self.arch, '-' + xml_state.get_image_version(), '.raw' ]) self.boot_is_crypto = True if self.luks and not \ self.disk_setup.need_boot_partition() else False self.install_media = self._install_image_requested() self.fstab = Fstab() # result store self.result = Result(xml_state) self.runtime_config = RuntimeConfig() if not self.boot_image.has_initrd_support(): log.warning('Building without initrd support !')