Exemple #1
0
class RPMOSTreePayloadWithFlatpaks(RPMOSTreePayload):
    def __init__(self, *args, **kwargs):
        """Variant of rpmostree payload with flatpak support.

        This variant will be used if flatpaks are available for system.
        """
        super().__init__(*args, **kwargs)

        self._flatpak_payload = FlatpakPayload(conf.target.system_root)
        # Initialize temporal repo to enable reading of the remote
        self._flatpak_payload.initialize_with_path(
            "/var/tmp/anaconda-flatpak-temp")

    @property
    def space_required(self):
        return super().space_required + Size(
            self._flatpak_payload.get_required_size())

    def install(self):
        # install ostree payload first
        super().install()

        # then flatpaks
        self._flatpak_install()

    def _flatpak_install(self):
        # Install flatpak from the local source on SilverBlue
        progressQ.send_message(_("Starting Flatpak installation"))
        # Cleanup temporal repo created in the __init__
        self._flatpak_payload.cleanup()

        # Initialize new repo on the installed system
        self._flatpak_payload.initialize_with_system_path()

        try:
            self._flatpak_payload.install_all()
        except FlatpakInstallError as e:
            exn = PayloadInstallError("Failed to install flatpaks: %s" % e)
            log.error(str(exn))
            if errors.errorHandler.cb(exn) == errors.ERROR_RAISE:
                progressQ.send_quit(1)
                util.ipmi_abort(scripts=self.data.scripts)
                sys.exit(1)

        progressQ.send_message(_("Post-installation flatpak tasks"))

        self._flatpak_payload.add_remote(
            "fedora", "oci+https://registry.fedoraproject.org")
        self._flatpak_payload.replace_installed_refs_remote("fedora")
        self._flatpak_payload.remove_remote(FlatpakPayload.LOCAL_REMOTE_NAME)

        progressQ.send_message(_("Flatpak installation has finished"))
Exemple #2
0
    def cleanup_call_no_repo_test(self, remote_cls, installation_cls, transaction_cls, rmtree):
        """Test the cleanup call with no repository created."""
        flatpak = FlatpakPayload("any path")

        self._setup_flatpak_objects(remote_cls, installation_cls, transaction_cls)

        file_mock_path = Mock()
        file_mock_path.get_path.return_value = "/install/test/path"
        self._installation.get_path.return_value = file_mock_path

        flatpak.initialize_with_path("/install/test/path")
        flatpak.cleanup()

        rmtree.assert_not_called()
Exemple #3
0
    def cleanup_call_mock_repo_test(self, remote_cls, installation_cls, transaction_cls, rmtree):
        """Test the cleanup call with mocked repository."""
        flatpak = FlatpakPayload("any path")

        self._setup_flatpak_objects(remote_cls, installation_cls, transaction_cls)

        with TemporaryDirectory() as temp:
            install_path = os.path.join(temp, "install/test/path")
            file_mock_path = Mock()
            file_mock_path.get_path.return_value = install_path
            self._installation.get_path.return_value = file_mock_path

            os.makedirs(install_path)

            flatpak.initialize_with_path(install_path)
            flatpak.cleanup()

            rmtree.assert_called_once_with(install_path)
Exemple #4
0
    def cleanup_call_without_initialize_test(self):
        """Test the cleanup call without initialize."""
        flatpak = FlatpakPayload("/tmp/flatpak-test")

        flatpak.cleanup()