Example #1
0
File: live.py Project: isbm/kiwi
    def __init__(self, xml_state, target_dir, root_dir, custom_args=None):
        self.media_dir = None
        self.live_container_dir = None
        self.arch = Defaults.get_platform_name()
        self.root_dir = root_dir
        self.target_dir = target_dir
        self.xml_state = xml_state
        self.live_type = xml_state.build_type.get_flags()
        self.volume_id = xml_state.build_type.get_volid() or \
            Defaults.get_volume_id()
        self.mbrid = SystemIdentifier()
        self.mbrid.calculate_id()
        self.publisher = xml_state.build_type.get_publisher() or \
            Defaults.get_publisher()
        self.custom_args = custom_args

        if not self.live_type:
            self.live_type = Defaults.get_default_live_iso_type()

        self.boot_image = BootImageDracut(xml_state, target_dir, self.root_dir)
        self.firmware = FirmWare(xml_state)
        self.system_setup = SystemSetup(xml_state=xml_state,
                                        root_dir=self.root_dir)
        self.isoname = ''.join([
            target_dir, '/',
            xml_state.xml_data.get_name(), '.' + Defaults.get_platform_name(),
            '-' + xml_state.get_image_version(), '.iso'
        ])
        self.result = Result(xml_state)
        self.runtime_config = RuntimeConfig()
Example #2
0
 def test_firmware_unsupported(self):
     xml_state = mock.Mock()
     xml_state.build_type.get_firmware = mock.Mock(
         return_value='bogus'
     )
     with raises(KiwiNotImplementedError):
         FirmWare(xml_state)
Example #3
0
    def check_syslinux_installed_if_isolinux_is_used(self) -> None:
        """
        ISO images that are configured to use isolinux
        requires the host to provide a set of syslinux
        binaries.
        """
        message = dedent('''\n
            Required syslinux module(s) not found

            The ISO image build for this image setup uses isolinux
            and therefore requires the syslinux modules to be
            available on the build host. Please make sure your
            build host has the syslinux package installed.
        ''')
        firmware = FirmWare(self.xml_state)
        if Defaults.is_x86_arch(
            Defaults.get_platform_name()
        ) and not firmware.efi_mode():
            image_builds_iso = False
            build_type = self.xml_state.get_build_type_name()
            if build_type == 'iso':
                image_builds_iso = True
            elif build_type == 'oem':
                install_iso = self.xml_state.build_type.get_installiso()
                install_stick = self.xml_state.build_type.get_installstick()
                if install_iso or install_stick:
                    image_builds_iso = True
            if image_builds_iso:
                syslinux_check_file = Path.which(
                    'isohdpfx.bin', Defaults.get_syslinux_search_paths()
                )
                if not syslinux_check_file:
                    raise KiwiRuntimeError(message)
Example #4
0
    def __init__(self, xml_state, root_dir):
        self.root_filesystem_is_overlay = xml_state.build_type.get_overlayroot()
        self.swap_mbytes = xml_state.get_oemconfig_swap_mbytes()
        self.configured_size = xml_state.get_build_type_size()
        self.build_type_name = xml_state.get_build_type_name()
        self.filesystem = xml_state.build_type.get_filesystem()
        self.bootpart_requested = xml_state.build_type.get_bootpartition()
        self.bootpart_mbytes = xml_state.build_type.get_bootpartsize()
        self.spare_part_mbytes = xml_state.get_build_type_spare_part_size()
        self.mdraid = xml_state.build_type.get_mdraid()
        self.luks = xml_state.build_type.get_luks()
        self.volume_manager = xml_state.get_volume_management()
        self.bootloader = xml_state.build_type.get_bootloader()
        self.oemconfig = xml_state.get_build_type_oemconfig_section()
        self.volumes = xml_state.get_volumes()

        self.firmware = FirmWare(
            xml_state
        )
        self.rootsize = SystemSize(
            root_dir
        )

        self.root_dir = root_dir
        self.xml_state = xml_state
Example #5
0
    def __init__(self, xml_state, target_dir, root_dir, custom_args=None):
        self.media_dir = None
        self.live_container_dir = 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.live_type = xml_state.build_type.get_flags()
        self.hybrid = xml_state.build_type.get_hybrid()
        self.volume_id = xml_state.build_type.get_volid() or \
            Defaults.get_volume_id()
        self.mbrid = SystemIdentifier()
        self.mbrid.calculate_id()
        self.filesystem_custom_parameters = {
            'mount_options': xml_state.get_fs_mount_option_list()
        }

        if not self.live_type:
            self.live_type = Defaults.get_default_live_iso_type()

        self.boot_image = BootImageDracut(xml_state, target_dir, self.root_dir)
        self.firmware = FirmWare(xml_state)
        self.system_setup = SystemSetup(xml_state=xml_state,
                                        root_dir=self.root_dir)
        self.isoname = ''.join([
            target_dir, '/',
            xml_state.xml_data.get_name(), '.' + platform.machine(),
            '-' + xml_state.get_image_version(), '.iso'
        ])
        self.result = Result(xml_state)
Example #6
0
File: grub2.py Project: pyzh/kiwi
    def post_init(self, custom_args):
        """
        grub2 post initialization method

        Setup class attributes
        """
        self.custom_args = custom_args
        arch = platform.machine()
        if arch == 'x86_64':
            # grub2 support for bios and efi systems
            self.arch = arch
        elif arch.startswith('ppc64'):
            # grub2 support for ofw and opal systems
            self.arch = arch
        elif arch == 'i686' or arch == 'i586':
            # grub2 support for bios systems
            self.arch = 'ix86'
        elif arch == 'aarch64' or arch.startswith('arm'):
            # grub2 support for efi systems
            self.arch = arch
        else:
            raise KiwiBootLoaderGrubPlatformError(
                'host architecture %s not supported for grub2 setup' % arch
            )

        if self.custom_args and 'grub_directory_name' in self.custom_args:
            self.boot_directory_name = self.custom_args['grub_directory_name']
        else:
            self.boot_directory_name = 'grub'

        self.terminal = self.xml_state.build_type.get_bootloader_console() \
            or 'gfxterm'
        self.gfxmode = self.get_gfxmode('grub2')
        self.bootpath = self.get_boot_path()
        self.theme = self.get_boot_theme()
        self.timeout = self.get_boot_timeout_seconds()
        self.failsafe_boot = self.failsafe_boot_entry_requested()
        self.xen_guest = self.xml_state.is_xen_guest()
        self.firmware = FirmWare(
            self.xml_state
        )

        if self.xml_state.is_xen_server():
            self.hybrid_boot = False
            self.multiboot = True
        elif self.xen_guest:
            self.hybrid_boot = False
            self.multiboot = False
        else:
            self.hybrid_boot = True
            self.multiboot = False

        self.grub2 = BootLoaderTemplateGrub2()
        self.config = None
        self.efi_boot_path = None
        self.cmdline_failsafe = None
        self.cmdline = None
        self.iso_boot = False
        self.shim_fallback_setup = False
Example #7
0
    def setup(self, mock_platform):
        mock_platform.return_value = 'x86_64'
        xml_state = mock.Mock()
        xml_state.build_type.get_firmware = mock.Mock()
        xml_state.build_type.get_firmware.return_value = 'bios'
        self.firmware_bios = FirmWare(xml_state)

        xml_state.build_type.get_efiparttable.return_value = None
        xml_state.build_type.get_efipartsize.return_value = None
        xml_state.build_type.get_firmware.return_value = 'efi'
        self.firmware_efi = FirmWare(xml_state)

        xml_state.build_type.get_efiparttable.return_value = 'msdos'
        xml_state.build_type.get_efipartsize.return_value = None
        xml_state.build_type.get_firmware.return_value = 'efi'
        self.firmware_efi_mbr = FirmWare(xml_state)

        xml_state.build_type.get_efipartsize.return_value = 42
        self.firmware_efi_custom_efi_part = FirmWare(xml_state)

        xml_state.build_type.get_firmware.return_value = 'ec2'
        self.firmware_ec2 = FirmWare(xml_state)

        mock_platform.return_value = 's390x'
        xml_state.build_type.get_firmware.return_value = None
        xml_state.build_type.get_zipl_targettype = mock.Mock()
        xml_state.build_type.get_zipl_targettype.return_value = 'LDL'
        self.firmware_s390_ldl = FirmWare(xml_state)

        xml_state.build_type.get_zipl_targettype.return_value = 'CDL'
        self.firmware_s390_cdl = FirmWare(xml_state)

        xml_state.build_type.get_zipl_targettype.return_value = 'SCSI'
        self.firmware_s390_scsi = FirmWare(xml_state)

        mock_platform.return_value = 'ppc64le'
        xml_state.build_type.get_firmware.return_value = 'ofw'
        self.firmware_ofw = FirmWare(xml_state)

        xml_state.build_type.get_firmware.return_value = 'opal'
        self.firmware_opal = FirmWare(xml_state)

        mock_platform.return_value = 'arm64'
Example #8
0
    def __init__(self,
                 xml_state: XMLState,
                 root_dir: str,
                 target_dir: str,
                 boot_image_task: Optional[BootImageBase],
                 custom_args: Dict = None) -> None:
        self.arch = Defaults.get_platform_name()
        self.root_dir = root_dir
        self.target_dir = target_dir
        self.xml_state = xml_state
        self.root_filesystem_is_multipath = \
            xml_state.get_oemconfig_oem_multipath_scan()
        self.initrd_system = xml_state.get_initrd_system()
        self.firmware = FirmWare(xml_state)
        self.setup = SystemSetup(self.xml_state, self.root_dir)
        self.iso_volume_id = self.xml_state.build_type.get_volid() or \
            Defaults.get_install_volume_id()
        self.diskname = ''.join([
            target_dir, '/',
            xml_state.xml_data.get_name(), '.' + self.arch,
            '-' + xml_state.get_image_version(), '.raw'
        ])
        self.isoname = ''.join([
            target_dir, '/',
            xml_state.xml_data.get_name(), '.' + self.arch,
            '-' + xml_state.get_image_version(), '.install.iso'
        ])
        self.pxename = ''.join([
            xml_state.xml_data.get_name(), '.' + self.arch,
            '-' + xml_state.get_image_version()
        ])
        self.pxetarball = ''.join(
            [target_dir, '/', self.pxename, '.install.tar'])
        self.dracut_config_file = ''.join(
            [self.root_dir, Defaults.get_dracut_conf_name()])
        self.squashed_diskname = ''.join(
            [xml_state.xml_data.get_name(), '.raw'])
        self.md5name = ''.join([xml_state.xml_data.get_name(), '.md5'])
        self.xz_options = custom_args['xz_options'] if custom_args \
            and 'xz_options' in custom_args else None

        self.mbrid = SystemIdentifier()
        self.mbrid.calculate_id()

        self.custom_iso_args: Dict = {}

        if not boot_image_task:
            self.boot_image_task = BootImage.new(xml_state, target_dir,
                                                 root_dir)
            self.boot_image_task.prepare()
        else:
            self.boot_image_task = boot_image_task
Example #9
0
    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))
Example #10
0
    def __init__(self,
                 xml_state,
                 root_dir,
                 target_dir,
                 boot_image_task,
                 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.boot_image_task = boot_image_task
        self.xml_state = xml_state
        self.root_filesystem_is_multipath = \
            xml_state.get_oemconfig_oem_multipath_scan()
        self.initrd_system = xml_state.get_initrd_system()
        self.firmware = FirmWare(xml_state)
        self.setup = SystemSetup(self.xml_state, self.root_dir)
        self.iso_volume_id = self.xml_state.build_type.get_volid() or \
            Defaults.get_install_volume_id()
        self.diskname = ''.join([
            target_dir, '/',
            xml_state.xml_data.get_name(), '.' + self.arch,
            '-' + xml_state.get_image_version(), '.raw'
        ])
        self.isoname = ''.join([
            target_dir, '/',
            xml_state.xml_data.get_name(), '.' + self.arch,
            '-' + xml_state.get_image_version(), '.install.iso'
        ])
        self.pxename = ''.join([
            xml_state.xml_data.get_name(), '.' + self.arch,
            '-' + xml_state.get_image_version()
        ])
        self.pxetarball = ''.join(
            [target_dir, '/', self.pxename, '.install.tar'])
        self.dracut_config_file = ''.join(
            [self.root_dir, Defaults.get_dracut_conf_name()])
        self.squashed_diskname = ''.join(
            [xml_state.xml_data.get_name(), '.raw'])
        self.md5name = ''.join([xml_state.xml_data.get_name(), '.md5'])
        self.xz_options = custom_args['xz_options'] if custom_args \
            and 'xz_options' in custom_args else None

        self.mbrid = SystemIdentifier()
        self.mbrid.calculate_id()

        self.media_dir = None
        self.pxe_dir = None
        self.squashed_contents = None
        self.custom_iso_args = None
Example #11
0
    def setup(self):
        Defaults.set_platform_name('x86_64')
        xml_state = mock.Mock()
        xml_state.build_type.get_firmware = mock.Mock()
        xml_state.build_type.get_firmware.return_value = 'bios'
        self.firmware_bios = FirmWare(xml_state)

        xml_state.build_type.get_efiparttable.return_value = None
        xml_state.build_type.get_efipartsize.return_value = None
        xml_state.build_type.get_firmware.return_value = 'efi'
        self.firmware_efi = FirmWare(xml_state)

        xml_state.build_type.get_efiparttable.return_value = 'msdos'
        xml_state.build_type.get_efipartsize.return_value = None
        xml_state.build_type.get_firmware.return_value = 'efi'
        self.firmware_efi_mbr = FirmWare(xml_state)

        xml_state.build_type.get_efipartsize.return_value = 42
        self.firmware_efi_custom_efi_part = FirmWare(xml_state)

        xml_state.build_type.get_firmware.return_value = 'ec2'
        self.firmware_ec2 = FirmWare(xml_state)

        Defaults.set_platform_name('s390x')
        xml_state.build_type.get_firmware.return_value = None
        xml_state.get_build_type_bootloader_targettype = mock.Mock()

        xml_state.get_build_type_bootloader_targettype.return_value = 'CDL'
        self.firmware_s390_cdl = FirmWare(xml_state)

        xml_state.get_build_type_bootloader_targettype.return_value = 'SCSI'
        self.firmware_s390_scsi = FirmWare(xml_state)

        Defaults.set_platform_name('ppc64le')
        xml_state.build_type.get_firmware.return_value = 'ofw'
        self.firmware_ofw = FirmWare(xml_state)

        xml_state.build_type.get_firmware.return_value = 'opal'
        self.firmware_opal = FirmWare(xml_state)

        Defaults.set_platform_name('x86_64')
Example #12
0
    def post_init(self, custom_args):
        """
        zipl post initialization method

        :param dict custom_args:
            Contains zipl config arguments

            .. code:: python

                {'targetbase': 'device_name'}
        """
        self.custom_args = custom_args
        arch = Defaults.get_platform_name()
        if 's390' in arch:
            self.arch = arch
        else:
            raise KiwiBootLoaderZiplPlatformError(
                'host architecture %s not supported for zipl setup' % arch
            )

        if not custom_args or 'targetbase' not in custom_args:
            raise KiwiBootLoaderZiplSetupError(
                'targetbase device name is required for zipl setup'
            )

        self.bootpath = '.'
        self.timeout = self.get_boot_timeout_seconds()
        self.cmdline = self.get_boot_cmdline()
        self.cmdline_failsafe = ' '.join(
            [self.cmdline, Defaults.get_failsafe_kernel_options()]
        )
        self.target_blocksize = \
            self.xml_state.build_type.get_target_blocksize()
        if not self.target_blocksize:
            self.target_blocksize = Defaults.get_s390_disk_block_size()

        self.target_type = \
            self.xml_state.get_build_type_bootloader_targettype()
        if not self.target_type:
            self.target_type = Defaults.get_s390_disk_type()

        self.failsafe_boot = self.failsafe_boot_entry_requested()
        self.target_device = custom_args['targetbase']
        self.firmware = FirmWare(self.xml_state)
        self.target_table_type = self.firmware.get_partition_table_type()

        self.zipl = BootLoaderTemplateZipl()
        self.config = None
Example #13
0
 def append_unpartitioned_space(self):
     """
     Extends the raw disk if an unpartitioned area is specified
     """
     if self.unpartitioned_bytes:
         log.info('Expanding disk with %d bytes of unpartitioned space',
                  self.unpartitioned_bytes)
         disk_format = DiskFormat('raw', self.xml_state, self.root_dir,
                                  self.target_dir)
         disk_format.resize_raw_disk(self.unpartitioned_bytes, append=True)
         firmware = FirmWare(self.xml_state)
         loop_provider = LoopDevice(disk_format.diskname)
         loop_provider.create(overwrite=False)
         partitioner = Partitioner(firmware.get_partition_table_type(),
                                   loop_provider)
         partitioner.resize_table()
Example #14
0
    def __init__(self, xml_state, target_dir, root_dir, custom_args=None):
        self.media_dir = 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.live_type = xml_state.build_type.get_flags()
        self.types = Defaults.get_live_iso_types()
        self.hybrid = xml_state.build_type.get_hybrid()
        self.volume_id = xml_state.build_type.get_volid()
        self.machine = xml_state.get_build_type_machine_section()
        self.mbrid = SystemIdentifier()
        self.mbrid.calculate_id()
        self.filesystem_custom_parameters = {
            'mount_options': xml_state.get_fs_mount_option_list()
        }

        if not self.live_type:
            self.live_type = Defaults.get_default_live_iso_type()

        boot_signing_keys = None
        if custom_args and 'signing_keys' in custom_args:
            boot_signing_keys = custom_args['signing_keys']

        self.boot_image_task = BootImage(xml_state,
                                         target_dir,
                                         signing_keys=boot_signing_keys)
        self.firmware = FirmWare(xml_state)
        self.system_setup = SystemSetup(xml_state=xml_state,
                                        root_dir=self.root_dir)
        self.isoname = ''.join([
            target_dir, '/',
            xml_state.xml_data.get_name(), '.' + platform.machine(),
            '-' + xml_state.get_image_version(), '.iso'
        ])
        self.live_image_file = ''.join([
            target_dir, '/',
            xml_state.xml_data.get_name(), '-read-only.', self.arch, '-',
            xml_state.get_image_version()
        ])
        self.result = Result(xml_state)
Example #15
0
    def __init__(self,
                 xml_state,
                 root_dir,
                 target_dir,
                 boot_image_task,
                 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.boot_image_task = boot_image_task
        self.xml_state = xml_state
        self.firmware = FirmWare(xml_state)
        self.diskname = ''.join([
            target_dir, '/',
            xml_state.xml_data.get_name(), '.' + self.arch,
            '-' + xml_state.get_image_version(), '.raw'
        ])
        self.isoname = ''.join([
            target_dir, '/',
            xml_state.xml_data.get_name(), '.' + self.arch,
            '-' + xml_state.get_image_version(), '.install.iso'
        ])
        self.pxename = ''.join([
            target_dir, '/',
            xml_state.xml_data.get_name(), '.' + self.arch,
            '-' + xml_state.get_image_version(), '.install.tar.xz'
        ])
        self.squashed_diskname = ''.join(
            [xml_state.xml_data.get_name(), '.raw'])
        self.md5name = ''.join([xml_state.xml_data.get_name(), '.md5'])
        self.xz_options = custom_args['xz_options'] if custom_args \
            and 'xz_options' in custom_args else None

        self.mbrid = SystemIdentifier()
        self.mbrid.calculate_id()

        self.media_dir = None
        self.pxe_dir = None
        self.squashed_contents = None
        self.custom_iso_args = None
Example #16
0
    def check_partuuid_persistency_type_used_with_mbr(self) -> None:
        """
        The devicepersistency setting by-partuuid can only be
        used in combination with a partition table type that
        supports UUIDs. In any other case Linux creates artificial
        values for PTUUID and PARTUUID from the disk signature
        which can change without touching the actual partition
        table. We consider this unsafe and only allow the use
        of by-partuuid in combination with partition tables that
        actually supports it properly.
        """
        message = dedent('''\n
            devicepersistency={0!r} used with non UUID capable partition table

            PTUUID and PARTUUID exists in the GUID (GPT) partition table.
            According to the firmware setting: {1!r}, the selected partition
            table type is: {2!r}. This table type does not natively support
            UUIDs. In such a case Linux creates artificial values for PTUUID
            and PARTUUID from the disk signature which can change without
            touching the actual partition table. This is considered unsafe
            and KIWI only allows the use of by-partuuid in combination with
            partition tables that actually supports UUIDs properly.

            Please make sure to use one of the following firmware settings
            which leads to an image using an UUID capable partition table
            and therefore supporting consistent by-partuuid device names:

            <type ... firmware="efi|uefi">
        ''')
        persistency_type = self.xml_state.build_type.get_devicepersistency()
        if persistency_type and persistency_type == 'by-partuuid':
            supported_table_types = ['gpt']
            firmware = FirmWare(self.xml_state)
            table_type = firmware.get_partition_table_type()
            if table_type not in supported_table_types:
                raise KiwiRuntimeError(
                    message.format(
                        persistency_type, firmware.firmware, table_type
                    )
                )
Example #17
0
 def setup(self, mock_platform):
     mock_platform.return_value = 'x86_64'
     xml_state = mock.Mock()
     xml_state.build_type.get_firmware = mock.Mock()
     xml_state.build_type.get_firmware.return_value = 'bios'
     self.firmware_bios = FirmWare(xml_state)
     xml_state.build_type.get_firmware.return_value = 'efi'
     self.firmware_efi = FirmWare(xml_state)
     xml_state.build_type.get_firmware.return_value = 'ec2'
     self.firmware_ec2 = FirmWare(xml_state)
     mock_platform.return_value = 's390x'
     xml_state.build_type.get_firmware.return_value = None
     xml_state.build_type.get_zipl_targettype = mock.Mock()
     xml_state.build_type.get_zipl_targettype.return_value = 'LDL'
     self.firmware_s390_ldl = FirmWare(xml_state)
     xml_state.build_type.get_zipl_targettype.return_value = 'CDL'
     self.firmware_s390_cdl = FirmWare(xml_state)
     xml_state.build_type.get_zipl_targettype.return_value = 'SCSI'
     self.firmware_s390_scsi = FirmWare(xml_state)
Example #18
0
    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()
Example #19
0
 def test_firmware_unsupported(self):
     xml_state = mock.Mock()
     xml_state.build_type.get_firmware = mock.Mock(
         return_value='bogus'
     )
     FirmWare(xml_state)
Example #20
0
    def post_init(self, custom_args):
        """
        grub2 post initialization method

        :param dict custom_args:
            Contains grub config arguments

            .. code:: python

                {'grub_directory_name': 'grub|grub2'}
        """
        self.custom_args = custom_args
        arch = platform.machine()
        if arch == 'x86_64':
            # grub2 support for bios and efi systems
            self.arch = arch
        elif arch.startswith('ppc64'):
            # grub2 support for ofw and opal systems
            self.arch = arch
        elif arch == 'i686' or arch == 'i586':
            # grub2 support for bios systems
            self.arch = 'ix86'
        elif arch == 'aarch64' or arch.startswith('arm'):
            # grub2 support for efi systems
            self.arch = arch
        else:
            raise KiwiBootLoaderGrubPlatformError(
                'host architecture %s not supported for grub2 setup' % arch
            )

        if self.custom_args and 'grub_directory_name' in self.custom_args:
            self.boot_directory_name = self.custom_args['grub_directory_name']
        else:
            self.boot_directory_name = 'grub'

        self.terminal = self.xml_state.build_type.get_bootloader_console() \
            or 'gfxterm'
        self.gfxmode = self.get_gfxmode('grub2')
        self.theme = self.get_boot_theme()
        self.timeout = self.get_boot_timeout_seconds()
        self.continue_on_timeout = self.get_continue_on_timeout()
        self.failsafe_boot = self.failsafe_boot_entry_requested()
        self.mediacheck_boot = self.xml_state.build_type.get_mediacheck()
        self.xen_guest = self.xml_state.is_xen_guest()
        self.firmware = FirmWare(
            self.xml_state
        )

        self.live_type = self.xml_state.build_type.get_flags()
        if not self.live_type:
            self.live_type = Defaults.get_default_live_iso_type()

        self.volume_id = self.xml_state.build_type.get_volid() or \
            Defaults.get_volume_id()
        self.install_volid = self.xml_state.build_type.get_volid() or \
            Defaults.get_install_volume_id()

        self.live_boot_options = [
            'root=live:CDLABEL={0}'.format(self.volume_id),
            'rd.live.image'
        ]
        self.install_boot_options = [
            'loglevel=0'
        ]
        if self.xml_state.get_initrd_system() == 'dracut':
            self.install_boot_options.append(
                'root=install:CDLABEL={0}'.format(self.install_volid)
            )
        if self.xml_state.build_type.get_hybridpersistent():
            self.live_boot_options += \
                Defaults.get_live_iso_persistent_boot_options(
                    self.xml_state.build_type.get_hybridpersistent_filesystem()
                )

        if self.xml_state.is_xen_server():
            self.hybrid_boot = False
            self.multiboot = True
        elif self.xen_guest:
            self.hybrid_boot = False
            self.multiboot = False
        else:
            self.hybrid_boot = True
            self.multiboot = False

        self.grub2 = BootLoaderTemplateGrub2()
        self.config = None
        self.efi_boot_path = None
        self.cmdline_failsafe = None
        self.root_reference = None
        self.cmdline = None
        self.iso_boot = False
        self.shim_fallback_setup = False
        self.validate_use_of_linuxefi = False
Example #21
0
    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 !')