def setup(self):
        with patch.dict('os.environ', {'HOME': '../data'}):
            self.runtime_config = RuntimeConfig()

        # pretend that none of the runtime config files exist, even if they do
        # (e.g. the system wide config file in /etc/kiwi.yml)
        # => this will give us the defaults
        with patch('os.path.exists', return_value=False):
            self.default_runtime_config = RuntimeConfig()
Exemple #2
0
    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()
Exemple #3
0
    def sign_verification_metadata(self) -> None:
        """
        Create an openssl based signature from the metadata block
        and attach it at the end of the block. This method requires
        access to a private key for signing. The path to the private
        key is read from the kiwi runtime config file from the
        following section:

        credentials:
          - verification_metadata_signing_key_file: /path/to/pkey
        """
        if self.verification_metadata_file:
            runtime_config = RuntimeConfig()
            signing_key_file = runtime_config.\
                get_credentials_verification_metadata_signing_key_file()
            if not signing_key_file:
                raise KiwiCredentialsError(
                    '{0} not configured in runtime config'.format(
                        'verification_metadata_signing_key_file'))
            signature_file = Temporary().new_file()
            Command.run([
                'openssl', 'dgst', '-sha256', '-sigopt',
                'rsa_padding_mode:pss', '-sigopt', 'rsa_pss_saltlen:-1',
                '-sigopt', 'rsa_mgf1_md:sha256', '-sign', signing_key_file,
                '-out', signature_file.name,
                self.verification_metadata_file.name
            ])
            with open(signature_file.name, 'rb') as sig_fd:
                signature = sig_fd.read()
                with open(self.verification_metadata_file.name, 'ab') as meta:
                    meta.write(signature)
Exemple #4
0
    def __init__(self, xml_state, target_dir, root_dir, custom_args=None):
        self.target_dir = target_dir
        self.compressed = xml_state.build_type.get_compressed()
        self.xen_server = xml_state.is_xen_server()
        self.filesystem = FileSystemBuilder(xml_state, target_dir,
                                            root_dir + '/')
        self.system_setup = SystemSetup(xml_state=xml_state, root_dir=root_dir)

        self.boot_signing_keys = custom_args['signing_keys'] if custom_args \
            and 'signing_keys' in custom_args else None

        self.xz_options = custom_args['xz_options'] if custom_args \
            and 'xz_options' in custom_args else None

        self.boot_image_task = BootImage(xml_state,
                                         target_dir,
                                         signing_keys=self.boot_signing_keys)
        self.image_name = ''.join([
            target_dir, '/',
            xml_state.xml_data.get_name(), '.' + platform.machine(),
            '-' + xml_state.get_image_version()
        ])
        self.archive_name = ''.join([self.image_name, '.tar.xz'])
        self.checksum_name = ''.join([self.image_name, '.md5'])
        self.kernel_filename = None
        self.hypervisor_filename = None
        self.result = Result(xml_state)
        self.runtime_config = RuntimeConfig()
Exemple #5
0
 def __init__(self, xml_state, target_dir, root_dir):
     self.label = None
     self.root_uuid = None
     self.root_dir = root_dir
     self.target_dir = target_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.filesystem_custom_parameters = {
         'mount_options': xml_state.get_fs_mount_option_list(),
         'create_options': xml_state.get_fs_create_option_list()
     }
     self.system_setup = SystemSetup(xml_state=xml_state,
                                     root_dir=self.root_dir)
     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(xml_state)
     self.runtime_config = RuntimeConfig()
Exemple #6
0
    def __init__(
        self, xml_state: XMLState, target_dir: str,
        root_dir: str, custom_args: Dict = None
    ):
        self.custom_args = custom_args or {}
        self.root_dir = root_dir
        self.target_dir = target_dir
        self.bundle_format = xml_state.get_build_type_bundle_format()
        self.container_config = xml_state.get_container_config()
        self.requested_container_type = xml_state.get_build_type_name()
        self.base_image = None
        self.base_image_md5 = None
        self.ensure_empty_tmpdirs = True

        self.container_config['xz_options'] = \
            self.custom_args.get('xz_options')

        self.container_config['metadata_path'] = \
            xml_state.build_type.get_metadata_path()

        if xml_state.get_derived_from_image_uri():
            # The base image is expected to be unpacked by the kiwi
            # prepare step and stored inside of the root_dir/image directory.
            # In addition a md5 file of the image is expected too
            self.base_image = Defaults.get_imported_root_image(
                self.root_dir
            )
            self.base_image_md5 = ''.join([self.base_image, '.md5'])

            if not os.path.exists(self.base_image):
                raise KiwiContainerBuilderError(
                    'Unpacked Base image {0} not found'.format(
                        self.base_image
                    )
                )
            if not os.path.exists(self.base_image_md5):
                raise KiwiContainerBuilderError(
                    'Base image MD5 sum {0} not found at'.format(
                        self.base_image_md5
                    )
                )

        if xml_state.build_type.get_ensure_empty_tmpdirs() is False:
            self.ensure_empty_tmpdirs = False

        self.system_setup = SystemSetup(
            xml_state=xml_state, root_dir=self.root_dir
        )
        self.filename = ''.join(
            [
                target_dir, '/',
                xml_state.xml_data.get_name(),
                '.' + Defaults.get_platform_name(),
                '-' + xml_state.get_image_version(),
                '.', self.requested_container_type,
                '.tar' if self.requested_container_type != 'appx' else ''
            ]
        )
        self.result = Result(xml_state)
        self.runtime_config = RuntimeConfig()
Exemple #7
0
    def test_config_sections_from_home_base_config(self, mock_Cli):
        cli = Mock()
        cli.get_global_args.return_value = {}
        mock_Cli.return_value = cli
        with patch.dict('os.environ', {'HOME': '../data/kiwi_config/ok'}):
            runtime_config = RuntimeConfig(reread=True)

        assert runtime_config.get_xz_options() == ['-a', '-b', 'xxx']
        assert runtime_config.is_obs_public() is True
        assert runtime_config.get_bundle_compression() is True
        assert runtime_config.get_obs_download_server_url() == \
            'http://example.com'
        assert runtime_config.get_obs_api_server_url() == \
            'https://api.example.com'
        assert runtime_config.get_container_compression() is None
        assert runtime_config.get_iso_tool_category() == 'cdrtools'
        assert runtime_config.get_oci_archive_tool() == 'umoci'
        assert runtime_config.get_package_changes() is True
        assert runtime_config.get_disabled_runtime_checks() == [
            'check_dracut_module_for_oem_install_in_package_list',
            'check_container_tool_chain_installed'
        ]
        assert runtime_config.get_obs_api_credentials() == [{
            'user_name':
            'user_credentials'
        }]
Exemple #8
0
    def __init__(self, should_perform_task_setup=True):
        from ..logger import log

        self.cli = Cli()

        # initialize runtime checker
        self.runtime_checker = None

        # initialize runtime configuration
        self.runtime_config = RuntimeConfig()

        # help requested
        self.cli.show_and_exit_on_help_request()

        # load/import task module
        self.task = self.cli.load_command()

        # get command specific args
        self.command_args = self.cli.get_command_args()

        # get global args
        self.global_args = self.cli.get_global_args()

        # initialize generic runtime check dicts
        self.checks_before_command_args = {
            'check_minimal_required_preferences': [],
            'check_efi_mode_for_disk_overlay_correctly_setup': [],
            'check_boot_description_exists': [],
            'check_consistent_kernel_in_boot_and_system_image': [],
            'check_container_tool_chain_installed': [],
            'check_volume_setup_defines_multiple_fullsize_volumes': [],
            'check_volume_setup_has_no_root_definition': [],
            'check_volume_label_used_with_lvm': [],
            'check_xen_uniquely_setup_as_server_or_guest': [],
            'check_mediacheck_installed': [],
            'check_dracut_module_for_live_iso_in_package_list': [],
            'check_dracut_module_for_disk_overlay_in_package_list': [],
            'check_dracut_module_for_disk_oem_in_package_list': [],
            'check_dracut_module_for_oem_install_in_package_list': [],
            'check_architecture_supports_iso_firmware_setup': []
        }
        self.checks_after_command_args = {
            'check_repositories_configured': [],
            'check_image_include_repos_publicly_resolvable': []
        }

        if should_perform_task_setup:
            # set log level
            if self.global_args['--debug']:
                log.setLogLevel(logging.DEBUG)
            else:
                log.setLogLevel(logging.INFO)

            # set log file
            if self.global_args['--logfile']:
                log.set_logfile(self.global_args['--logfile'])

            if self.global_args['--color-output']:
                log.set_color_format()
Exemple #9
0
 def __new__(self, container_tag, container_dir=None):
     runtime_config = RuntimeConfig()
     tool_name = runtime_config.get_oci_archive_tool()
     if tool_name == 'umoci':
         return OCIUmoci(container_tag, container_dir)
     else:
         raise KiwiOCIArchiveToolError(
             'No support for {0} tool available'.format(tool_name))
 def test__get_attribute_raises_on_invalid_structure(self, mock_Cli):
     cli = Mock()
     cli.get_global_args.return_value = {}
     mock_Cli.return_value = cli
     with patch.dict('os.environ', {'HOME': '../data/kiwi_config/broken'}):
         runtime_config = RuntimeConfig(reread=True)
         with raises(KiwiRuntimeConfigFormatError):
             runtime_config._get_attribute('foo', 'bar')
Exemple #11
0
 def test_init_raises_custom_config_file_not_found(self, mock_Cli):
     cli = Mock()
     cli.get_global_args.return_value = {}
     mock_Cli.return_value = cli
     cli.get_global_args.return_value = {'--config': '../data/kiwi.yml'}
     with patch('os.path.isfile', return_value=False):
         with raises(KiwiRuntimeConfigFileError):
             RuntimeConfig(reread=True)
    def test_config_sections_other_settings(self, mock_Cli):
        cli = Mock()
        cli.get_global_args.return_value = {}
        mock_Cli.return_value = cli
        with patch.dict('os.environ', {'HOME': '../data/kiwi_config/other'}):
            runtime_config = RuntimeConfig(reread=True)

        assert runtime_config.get_container_compression() == 'xz'
        assert runtime_config.get_package_changes() is True
Exemple #13
0
    def test_reading_system_wide_config_file(self, mock_yaml, mock_exists):
        exists_call_results = [True, False]

        def os_path_exists(config):
            return exists_call_results.pop()

        mock_exists.side_effect = os_path_exists
        with patch_open as mock_open:
            self.runtime_config = RuntimeConfig()
            mock_open.assert_called_once_with('/etc/kiwi.yml', 'r')
Exemple #14
0
    def __init__(self,
                 uri: str,
                 repo_type: str = 'rpm-md',
                 source_type: str = ''):
        """
        Manage kiwi source URIs and allow transformation into
        standard URLs

        :param str uri: URI, remote, local or metalink repository location
            The resource type as part of the URI can be set to one of:
            * http:
            * https:
            * ftp:
            * obs:
            * dir:
            * file:
            * obsrepositories:
            * this:
            The special this:// type resolve to the image description
            directory. The code to resolve this is not part of the Uri
            class because it has no state information about the image
            description directory. Therefore the resolving of the this://
            path happens on construction of an XMLState object as
            part of the resolve_this_path() method. The method resolves
            the path into a native dir:// URI which can be properly
            handled here.
        :param str repo_type:
            repository type name, defaults to 'rpm-md' and is only
            effectively used when building inside of the open
            build service which maps local repositories to a
            specific environment
        :param str source_type:
            specify source type if the provided URI is a service.
            Currently only the metalink source type is handled
        """
        self.runtime_config = RuntimeConfig()

        if source_type == 'metalink':
            uri = self._resolve_metalink_uri(uri)

        self.repo_type = repo_type
        self.uri = uri if not uri.startswith(os.sep) else ''.join(
            [Defaults.get_default_uri_type(), uri])

        self.remote_uri_types = {
            'http': True,
            'https': True,
            'ftp': True,
            'obs': True
        }
        self.local_uri_type = {
            'dir': True,
            'file': True,
            'obsrepositories': True
        }
Exemple #15
0
 def __init__(self, xml_state, root_dir):
     self.runtime_config = RuntimeConfig()
     self.arch = Defaults.get_platform_name()
     self.xml_state = xml_state
     self.description_dir = \
         xml_state.xml_data.description_dir
     self.derived_description_dir = \
         xml_state.xml_data.derived_description_dir
     self.root_dir = root_dir
     self._preferences_lookup()
     self._oemconfig_lookup()
Exemple #16
0
    def test_config_sections_invalid(self):
        with patch.dict('os.environ', {'HOME': '../data/kiwi_config/invalid'}):
            runtime_config = RuntimeConfig(reread=True)

        with self._caplog.at_level(logging.WARNING):
            assert runtime_config.get_container_compression() is True
            assert 'Skipping invalid container compression: foo' in \
                self._caplog.text
        with self._caplog.at_level(logging.WARNING):
            assert runtime_config.get_iso_tool_category() == 'xorriso'
            assert 'Skipping invalid iso tool category: foo' in \
                self._caplog.text
Exemple #17
0
    def __init__(self, xml_state, root_dir, target_dir, custom_args=None):
        self.xml_state = xml_state
        self.root_dir = root_dir
        self.arch = platform.machine()
        self.target_dir = target_dir
        self.custom_args = {}
        self.temp_image_dir = None
        self.image_format = None
        self.diskname = self.get_target_file_path_for_format('raw')
        self.runtime_config = RuntimeConfig()

        self.post_init(custom_args)
Exemple #18
0
 def new(source_dir):
     name_map = {'xorriso': 'XorrIso', 'cdrtools': 'CdrTools'}
     runtime_config = RuntimeConfig()
     tool = runtime_config.get_iso_tool_category()
     try:
         iso_tool = importlib.import_module(
             'kiwi.iso_tools.{}'.format(tool))
         module_name = 'IsoTools{}'.format(name_map[tool])
         return iso_tool.__dict__[module_name](source_dir)
     except Exception:
         raise KiwiIsoToolError(
             'No support for {} tool available'.format(tool))
Exemple #19
0
 def new():
     name_map = {'umoci': 'Umoci', 'buildah': 'Buildah'}
     runtime_config = RuntimeConfig()
     tool_name = runtime_config.get_oci_archive_tool()
     try:
         oci_tool = importlib.import_module(
             'kiwi.oci_tools.{}'.format(tool_name))
         module_name = 'OCI{}'.format(name_map[tool_name])
         return oci_tool.__dict__[module_name]()
     except Exception:
         raise KiwiOCIArchiveToolError(
             'No support for {0} tool available'.format(tool_name))
Exemple #20
0
    def check_container_tool_chain_installed(self) -> None:
        """
        When creating container images the specific tools are used in order
        to import and export OCI or Docker compatible images. This check
        searches for those tools to be installed in the build system and
        fails if it can't find them
        """
        message_tool_not_found = dedent('''\n
            Required tool {name} not found in caller environment

            Creation of OCI or Docker images requires the tools {name} and
            skopeo to be installed on the build system. For SUSE based systems
            you can find the tools at:

            http://download.opensuse.org/repositories/Virtualization:/containers
        ''')
        message_version_unsupported = dedent('''\n
            {name} tool found with unknown version
        ''')
        message_unknown_tool = dedent('''\n
            Unknown tool: {0}.

            Please configure KIWI with an appropriate value (umoci or buildah).
            Consider this runtime configuration file syntax (/etc/kiwi.yml):

            oci:
                - archive_tool: umoci | buildah
        ''')

        expected_version = (0, 1, 0)

        if self.xml_state.get_build_type_name() in ['docker', 'oci']:
            runtime_config = RuntimeConfig()
            tool_name = runtime_config.get_oci_archive_tool()
            if tool_name == 'buildah':
                oci_tools = ['buildah', 'skopeo']
            elif tool_name == 'umoci':
                oci_tools = ['umoci', 'skopeo']
            else:
                raise KiwiRuntimeError(message_unknown_tool.format(tool_name))
            for tool in oci_tools:
                if not Path.which(filename=tool, access_mode=os.X_OK):
                    raise KiwiRuntimeError(
                        message_tool_not_found.format(name=tool)
                    )
                elif not CommandCapabilities.check_version(
                    tool, expected_version, raise_on_error=False
                ):
                    raise KiwiRuntimeError(
                        message_version_unsupported.format(name=tool)
                    )
            self._check_multitag_support()
Exemple #21
0
    def __init__(self, xml_state, target_dir, root_dir, custom_args=None):
        self.root_dir = root_dir
        self.target_dir = target_dir
        self.xml_state = xml_state
        self.requested_archive_type = xml_state.get_build_type_name()
        self.result = Result(xml_state)
        self.system_setup = SystemSetup(xml_state=xml_state,
                                        root_dir=self.root_dir)
        self.filename = self._target_file_for('tar.xz')
        self.xz_options = custom_args['xz_options'] if custom_args \
            and 'xz_options' in custom_args else None

        self.runtime_config = RuntimeConfig()
Exemple #22
0
    def __init__(
            self, xml_state: XMLState, root_dir: str, target_dir: str,
            custom_args: dict = None
    ):
        self.xml_state = xml_state
        self.root_dir = root_dir
        self.arch = Defaults.get_platform_name()
        self.target_dir = target_dir
        self.temp_image_dir: str = ''
        self.image_format: str = ''
        self.diskname = self.get_target_file_path_for_format('raw')
        self.runtime_config = RuntimeConfig()

        self.post_init(custom_args or {})
Exemple #23
0
    def test_reading_system_wide_config_file(self, mock_Cli, mock_yaml,
                                             mock_exists):
        cli = Mock()
        cli.get_global_args.return_value = {}
        mock_Cli.return_value = cli
        exists_call_results = [True, False]

        def os_path_exists(config):
            return exists_call_results.pop()

        mock_exists.side_effect = os_path_exists
        with patch('builtins.open') as m_open:
            RuntimeConfig(reread=True)
            m_open.assert_called_once_with('/etc/kiwi.yml', 'r')
    def test_config_sections_invalid(self, mock_Cli):
        cli = Mock()
        cli.get_global_args.return_value = {}
        mock_Cli.return_value = cli
        with patch.dict('os.environ', {'HOME': '../data/kiwi_config/invalid'}):
            runtime_config = RuntimeConfig(reread=True)

        with self._caplog.at_level(logging.WARNING):
            assert runtime_config.get_container_compression() == 'xz'
            assert 'Skipping invalid container compression: foo' in \
                self._caplog.text
        with self._caplog.at_level(logging.WARNING):
            assert runtime_config.get_iso_tool_category() == 'xorriso'
            assert 'Skipping invalid iso tool category: foo' in \
                self._caplog.text
Exemple #25
0
    def test_config_sections_defaults(self, mock_is_buildservice_worker):
        mock_is_buildservice_worker.return_value = True
        with patch.dict('os.environ', {'HOME': '../data/kiwi_config/defaults'}):
            runtime_config = RuntimeConfig(reread=True)

        assert runtime_config.get_bundle_compression(default=True) is True
        assert runtime_config.get_bundle_compression(default=False) is False
        assert runtime_config.is_obs_public() is True
        assert runtime_config.get_obs_download_server_url() == \
            Defaults.get_obs_download_server_url()
        assert runtime_config.get_obs_api_server_url() == \
            Defaults.get_obs_api_server_url()
        assert runtime_config.get_container_compression() is True
        assert runtime_config.get_iso_tool_category() == 'xorriso'
        assert runtime_config.get_oci_archive_tool() == 'umoci'
        assert runtime_config.get_package_changes() is False
Exemple #26
0
    def __init__(
        self, xml_state: XMLState, target_dir: str,
        root_dir: str, custom_args: Dict = None
    ):
        self.target_dir = target_dir
        self.compressed = xml_state.build_type.get_compressed()
        self.xen_server = xml_state.is_xen_server()
        self.custom_cmdline = xml_state.build_type.get_kernelcmdline()
        self.filesystem = FileSystemBuilder(
            xml_state, target_dir, root_dir + '/'
        ) if xml_state.build_type.get_filesystem() else None
        self.system_setup = SystemSetup(
            xml_state=xml_state, root_dir=root_dir
        )
        self.initrd_system = xml_state.get_initrd_system()

        self.boot_signing_keys = custom_args['signing_keys'] if custom_args \
            and 'signing_keys' in custom_args else None

        self.xz_options = custom_args['xz_options'] if custom_args \
            and 'xz_options' in custom_args else None

        self.boot_image_task = BootImage.new(
            xml_state, target_dir, root_dir,
            signing_keys=self.boot_signing_keys
        )
        self.bundle_format = xml_state.get_build_type_bundle_format()
        self.image_name = ''.join(
            [
                target_dir, '/',
                xml_state.xml_data.get_name(),
                '.' + Defaults.get_platform_name(),
                '-' + xml_state.get_image_version()
            ]
        )
        self.image: str = ''
        self.append_file = ''.join([self.image_name, '.append'])
        self.archive_name = ''.join([self.image_name, '.tar'])
        self.checksum_name = ''.join([self.image_name, '.md5'])
        self.kernel_filename: str = ''
        self.hypervisor_filename: str = ''
        self.result = Result(xml_state)
        self.runtime_config = RuntimeConfig()

        if not self.boot_image_task.has_initrd_support():
            log.warning('Building without initrd support !')
Exemple #27
0
    def __init__(
        self, xml_state: XMLState, target_dir: str,
        root_dir: str, custom_args: Dict = None
    ):
        self.label = None
        self.root_uuid = ''
        self.root_dir = root_dir
        self.target_dir = target_dir
        self.bundle_format = xml_state.get_build_type_bundle_format()
        self.requested_image_type = xml_state.get_build_type_name()
        if self.requested_image_type in Defaults.get_kis_image_types():
            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.filesystem_custom_parameters = {
            'mount_options': xml_state.get_fs_mount_option_list(),
            'create_options': xml_state.get_fs_create_option_list()
        }
        if self.requested_filesystem == 'squashfs':
            self.filesystem_custom_parameters['compression'] = \
                xml_state.build_type.get_squashfscompression()

        self.system_setup = SystemSetup(
            xml_state=xml_state, root_dir=self.root_dir
        )
        self.filename = ''.join(
            [
                target_dir, '/',
                xml_state.xml_data.get_name(),
                '.' + Defaults.get_platform_name(),
                '-' + 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(xml_state)
        self.runtime_config = RuntimeConfig()
Exemple #28
0
    def __init__(self, root_dir, transport, custom_args=None):
        self.root_dir = root_dir
        self.archive_transport = transport
        if custom_args:
            self.oci_config = custom_args
        else:
            self.oci_config = {}

        self.runtime_config = RuntimeConfig()

        # for builds inside the buildservice we include a reference to the
        # specific build. Thus disturl label only exists inside the
        # buildservice.
        if Defaults.is_buildservice_worker():
            bs_label = 'org.openbuildservice.disturl'
            # Do not label anything if the build service label is
            # already present
            if 'labels' not in self.oci_config or \
                    bs_label not in self.oci_config['labels']:
                self._append_buildservice_disturl_label()

        if 'container_name' not in self.oci_config:
            log.info(
                'No container configuration provided, '
                'using default container name "kiwi-container:latest"'
            )
            self.oci_config['container_name'] = \
                Defaults.get_default_container_name()
            self.oci_config['container_tag'] = \
                Defaults.get_default_container_tag()

        if 'container_tag' not in self.oci_config:
            self.oci_config['container_tag'] = \
                Defaults.get_default_container_tag()

        if 'entry_command' not in self.oci_config and \
                'entry_subcommand' not in self.oci_config:
            self.oci_config['entry_subcommand'] = \
                Defaults.get_default_container_subcommand()

        if 'history' not in self.oci_config:
            self.oci_config['history'] = {}
        if 'created_by' not in self.oci_config['history']:
            self.oci_config['history']['created_by'] = \
                Defaults.get_default_container_created_by()
Exemple #29
0
    def __init__(self, uri, repo_type=None):
        self.runtime_config = RuntimeConfig()
        self.repo_type = repo_type
        self.uri = uri
        self.mount_stack = []

        self.remote_uri_types = {
            'http': True,
            'https': True,
            'ftp': True,
            'obs': True
        }
        self.local_uri_type = {
            'iso': True,
            'dir': True,
            'file': True,
            'obsrepositories': True
        }
Exemple #30
0
    def __init__(self, root_dir, custom_args=None):
        self.root_dir = root_dir
        self.wsl_config = custom_args or {}
        self.runtime_config = RuntimeConfig()

        self.meta_data_path = self.wsl_config.get('metadata_path')

        if not self.meta_data_path:
            raise KiwiContainerSetupError(
                'No metadata path specified to build appx container'
            )

        if not os.path.exists(self.meta_data_path):
            raise KiwiContainerSetupError(
                'Specified metadata path {0} does not exist'.format(
                    self.meta_data_path
                )
            )