Beispiel #1
0
    def create(self) -> Result:
        """
        Builds a container image which is usually a data archive
        including container specific metadata.

        Image types which triggers this builder are:

        * image="docker"
        * image="oci"
        * image="appx"

        :return: result

        :rtype: instance of :class:`Result`
        """
        if not self.base_image:
            log.info('Setting up %s container', self.requested_container_type)
            container_setup = ContainerSetup.new(self.requested_container_type,
                                                 self.root_dir,
                                                 self.container_config)
            container_setup.setup()
        else:
            checksum = Checksum(self.base_image)
            if not checksum.matches(checksum.md5(), self.base_image_md5):
                raise KiwiContainerBuilderError(
                    'base image file {0} checksum validation failed'.format(
                        self.base_image))

        log.info('--> Creating container image')
        container_image = ContainerImage.new(self.requested_container_type,
                                             self.root_dir,
                                             self.container_config)
        self.filename = container_image.create(self.filename, self.base_image)
        Result.verify_image_size(self.runtime_config.get_max_size_constraint(),
                                 self.filename)
        self.result.add(key='container',
                        filename=self.filename,
                        use_for_bundle=True,
                        compress=False,
                        shasum=True)
        self.result.add(key='image_packages',
                        filename=self.system_setup.export_package_list(
                            self.target_dir),
                        use_for_bundle=True,
                        compress=False,
                        shasum=False)
        self.result.add(key='image_changes',
                        filename=self.system_setup.export_package_changes(
                            self.target_dir),
                        use_for_bundle=True,
                        compress=True,
                        shasum=False)
        self.result.add(key='image_verified',
                        filename=self.system_setup.export_package_verification(
                            self.target_dir),
                        use_for_bundle=True,
                        compress=False,
                        shasum=False)
        return self.result
Beispiel #2
0
 def test_container_not_implemented(self):
     with raises(KiwiContainerSetupError):
         ContainerSetup.new('foo', 'root_dir')
Beispiel #3
0
 def test_container_oci(self, mock_oci):
     ContainerSetup.new('oci', 'root_dir')
     mock_oci.assert_called_once_with('root_dir', None)
Beispiel #4
0
 def test_container_appx(self, mock_appx):
     ContainerSetup.new('appx', 'root_dir')
     mock_appx.assert_called_once_with('root_dir', None)
Beispiel #5
0
 def test_container_docker(self, mock_docker):
     ContainerSetup.new('docker', 'root_dir')
     mock_docker.assert_called_once_with('root_dir', None)