Exemplo n.º 1
0
    def install_test(self, sysroot_cls, gio_file_cls):
        """Test the ChangeOSTreeRemoteTask installation task."""
        data = self._get_data()
        repo = self._get_repo(sysroot_cls)

        task = ChangeOSTreeRemoteTask(data, physroot="/physroot")
        task.run()

        self._check_remote_changed(repo, sysroot_file=None)
Exemplo n.º 2
0
    def post_install_test(self, sysroot_cls, gio_file_cls):
        """Test the ChangeOSTreeRemoteTask post-installation task."""
        data = self._get_data()
        repo = self._get_repo(sysroot_cls)
        sysroot_file = gio_file_cls.new_for_path("/sysroot")

        task = ChangeOSTreeRemoteTask(data, sysroot="/sysroot")
        task.run()

        self._check_remote_changed(repo, sysroot_file)
Exemplo n.º 3
0
    def options_test(self, sysroot_cls, gio_file_cls, conf_mock):
        """Test the remote options of the ChangeOSTreeRemoteTask task."""
        options = {
            "gpg-verify": False,
            "tls-permissive": True,
        }

        data = self._get_data()
        repo = self._get_repo(sysroot_cls)
        conf_mock.payload.verify_ssl = False
        data.gpg_verification_enabled = False

        task = ChangeOSTreeRemoteTask(data, physroot="/physroot")
        task.run()

        self._check_remote_changed(repo, sysroot_file=None, options=options)
Exemplo n.º 4
0
    def install_with_tasks(self):
        """Install the payload.

        :return: list of tasks
        """
        ostree_source = self._get_source(SourceType.RPM_OSTREE)

        if not ostree_source:
            log.debug("No OSTree RPM source is available.")
            return []

        tasks = [
            InitOSTreeFsAndRepoTask(physroot=conf.target.physical_root),
            ChangeOSTreeRemoteTask(physroot=conf.target.physical_root,
                                   data=ostree_source.configuration),
            PullRemoteAndDeleteTask(data=ostree_source.configuration),
            DeployOSTreeTask(physroot=conf.target.physical_root,
                             data=ostree_source.configuration),
            SetSystemRootTask(physroot=conf.target.physical_root),
            CopyBootloaderDataTask(physroot=conf.target.physical_root,
                                   sysroot=conf.target.system_root),
            PrepareOSTreeMountTargetsTask(physroot=conf.target.physical_root,
                                          sysroot=conf.target.system_root,
                                          data=ostree_source.configuration)
        ]

        flatpak_source = self._get_source(SourceType.FLATPAK)

        if flatpak_source:
            task = InstallFlatpaksTask(sysroot=conf.target.system_root)
            tasks.append(task)

        self._collect_mount_points_on_success(tasks)
        return tasks
Exemplo n.º 5
0
    def post_install(self):
        super().post_install()
        data = self._get_source_configuration()

        # Following up on the "remote delete" earlier, we removed the remote from
        # /ostree/repo/config.  But we want it in /etc, so re-add it to /etc/ostree/remotes.d,
        # using the sysroot path.
        #
        # However, we ignore the case where the remote already exists, which occurs when the
        # content itself provides the remote config file.
        #
        # Note here we use the deployment as sysroot, because it's that version of /etc that we
        # want.

        from pyanaconda.modules.payloads.payload.rpm_ostree.installation import \
            ChangeOSTreeRemoteTask
        task = ChangeOSTreeRemoteTask(data,
                                      use_root=True,
                                      root=conf.target.system_root)
        task.run()

        # Handle bootloader configuration
        from pyanaconda.modules.payloads.payload.rpm_ostree.installation import \
            ConfigureBootloader
        task = ConfigureBootloader(sysroot=conf.target.system_root,
                                   is_dirinstall=conf.target.is_directory)
        task.run()
Exemplo n.º 6
0
    def _execute_run_once(self, use_sysroot, gpg_verify, verify_ssl,
                          gio_file_mock, conf_mock, sysroot_mock):
        new_mock = sysroot_mock.new()
        repo_mock = MagicMock()
        new_mock.get_repo.return_value = [None, repo_mock]
        conf_mock.payload.verify_ssl = verify_ssl
        path_mock = gio_file_mock.new_for_path()

        data = RPMOSTreeConfigurationData()
        data.url = "url"
        data.osname = "osname"
        data.gpg_verification_enabled = gpg_verify
        data.ref = "ref"
        data.remote = "remote"

        task = ChangeOSTreeRemoteTask(data, use_sysroot, "/physroot")
        task.run()

        repo_mock.remote_change.assert_called_once()
        the_call = repo_mock.remote_change.mock_calls[0]
        name, args, kwargs = the_call
        print(the_call, name, args, kwargs)
        self.assertEqual(len(args), 6)

        if use_sysroot:
            self.assertEqual(args[0], path_mock)
        else:
            self.assertEqual(args[0], None)
        self.assertEqual(args[2], "remote")
        self.assertEqual(args[3], "url")

        expected = {}
        if not gpg_verify:
            expected["gpg-verify"] = False
        if not verify_ssl:
            expected["tls-permissive"] = True
        var = args[4]
        self.assertEqual(type(var), Variant)
        self.assertDictEqual(var.unpack(), expected)
Exemplo n.º 7
0
    def post_install_with_tasks(self):
        """Execute post installation steps.

        :return: list of tasks
        """
        ostree_source = self._get_source(SourceType.RPM_OSTREE)

        if not ostree_source:
            log.debug("No OSTree RPM source is available.")
            return []

        return [
            ChangeOSTreeRemoteTask(data=ostree_source.configuration,
                                   sysroot=conf.target.system_root),
            ConfigureBootloader(sysroot=conf.target.system_root, )
        ]
Exemplo n.º 8
0
    def _install(self, data):
        log.info("executing ostreesetup=%r", data)

        from pyanaconda.modules.payloads.payload.rpm_ostree.installation import \
            InitOSTreeFsAndRepoTask
        task = InitOSTreeFsAndRepoTask(conf.target.physical_root)
        task.run()

        # Here, we use the physical root as sysroot, because we haven't
        # yet made a deployment.
        from pyanaconda.modules.payloads.payload.rpm_ostree.installation import \
            ChangeOSTreeRemoteTask
        task = ChangeOSTreeRemoteTask(data,
                                      use_root=False,
                                      root=conf.target.physical_root)
        task.run()

        from pyanaconda.modules.payloads.payload.rpm_ostree.installation import \
            PullRemoteAndDeleteTask
        task = PullRemoteAndDeleteTask(data)
        task.progress_changed_signal.connect(self._progress_cb)
        task.run()

        from pyanaconda.modules.payloads.payload.rpm_ostree.installation import DeployOSTreeTask
        task = DeployOSTreeTask(data, conf.target.physical_root)
        task.progress_changed_signal.connect(self._progress_cb)
        task.run()

        # Reload now that we've deployed, find the path to the new deployment
        from pyanaconda.modules.payloads.payload.rpm_ostree.installation import SetSystemRootTask
        task = SetSystemRootTask(conf.target.physical_root)
        task.run()

        try:
            from pyanaconda.modules.payloads.payload.rpm_ostree.installation import \
                CopyBootloaderDataTask
            task = CopyBootloaderDataTask(sysroot=conf.target.system_root,
                                          physroot=conf.target.physical_root)
            task.run()
        except (OSError, RuntimeError) as e:
            raise PayloadInstallError("Failed to copy bootloader data: %s" %
                                      e) from e