Example #1
0
    def test_no_update(self, execute):
        """Don't update the DNF configuration."""
        with tempfile.TemporaryDirectory() as sysroot:
            data = PackagesConfigurationData()

            task = UpdateDNFConfigurationTask(sysroot, data)
            task.run()

            execute.assert_not_called()
Example #2
0
    def test_error_update(self, execute):
        """The update of the DNF configuration has failed."""
        execute.side_effect = OSError("Fake!")

        with tempfile.TemporaryDirectory() as sysroot:
            data = PackagesConfigurationData()
            data.multilib_policy = MULTILIB_POLICY_ALL

            task = UpdateDNFConfigurationTask(sysroot, data)

            with self.assertLogs(level="WARNING") as cm:
                task.run()

            msg = "Couldn't update the DNF configuration: Fake!"
            assert any(map(lambda x: msg in x, cm.output))
Example #3
0
    def test_failed_update(self, execute):
        """The update of the DNF configuration has failed."""
        execute.return_value = 1

        with tempfile.TemporaryDirectory() as sysroot:
            data = PackagesConfigurationData()
            data.multilib_policy = MULTILIB_POLICY_ALL

            task = UpdateDNFConfigurationTask(sysroot, data)

            with self.assertLogs(level="WARNING") as cm:
                task.run()

            msg = "Failed to update the DNF configuration (1)."
            assert any(map(lambda x: msg in x, cm.output))
Example #4
0
    def post_install(self):
        """Perform post-installation tasks."""
        # Write selected kickstart repos to target system
        repositories = list(
            map(convert_ks_repo_to_repo_data, self.data.repo.dataList()))

        task = WriteRepositoriesTask(
            sysroot=conf.target.system_root,
            dnf_manager=self.dnf_manager,
            repositories=repositories,
        )
        task.run()

        # We don't need the mother base anymore. Close it.
        self._base.close()
        super().post_install()

        # rpm needs importing installed certificates manually, see rhbz#748320 and rhbz#185800
        task = ImportRPMKeysTask(sysroot=conf.target.system_root,
                                 gpg_keys=conf.payload.default_rpm_gpg_keys)
        task.run()

        # Update the DNF configuration.
        task = UpdateDNFConfigurationTask(
            sysroot=conf.target.system_root,
            data=self.get_packages_configuration())
        task.run()
Example #5
0
    def test_multilib_policy(self, execute):
        """Update the multilib policy."""
        execute.return_value = 0

        with tempfile.TemporaryDirectory() as sysroot:
            data = PackagesConfigurationData()
            data.multilib_policy = MULTILIB_POLICY_ALL

            task = UpdateDNFConfigurationTask(sysroot, data)
            task.run()

            execute.assert_called_once_with("dnf", [
                "config-manager",
                "--save",
                "--setopt=multilib_policy=all",
            ],
                                            root=sysroot)
Example #6
0
    def post_install(self):
        """Perform post-installation tasks."""
        # Write selected kickstart repos to target system
        for ks_repo in self.data.repo.dataList():
            if not ks_repo.install:
                continue

            if ks_repo.baseurl.startswith("nfs://"):
                log.info("Skip writing nfs repo %s to target system.", ks_repo.name)
                continue

            try:
                repo = self._get_repo(ks_repo.name)
                if not repo:
                    continue
            except (dnf.exceptions.RepoError, KeyError):
                continue
            repo_path = conf.target.system_root + YUM_REPOS_DIR + "%s.repo" % repo.id
            try:
                log.info("Writing %s.repo to target system.", repo.id)
                self._write_dnf_repo(repo, repo_path)
            except PayloadSetupError as e:
                log.error(e)

        # We don't need the mother base anymore. Close it.
        self._base.close()
        super().post_install()

        # rpm needs importing installed certificates manually, see rhbz#748320 and rhbz#185800
        task = ImportRPMKeysTask(
            sysroot=conf.target.system_root,
            gpg_keys=conf.payload.default_rpm_gpg_keys
        )
        task.run()

        # Update the DNF configuration.
        task = UpdateDNFConfigurationTask(
            sysroot=conf.target.system_root,
            data=self.get_packages_configuration()
        )
        task.run()