Beispiel #1
0
    def install(self):
        """ Install the payload if it is a tar.
            Otherwise fall back to rsync of INSTALL_TREE
        """
        # If it doesn't look like a tarfile use the super's install()
        if not self.is_tarfile:
            super().install()
            return

        # Use 2x the archive's size to estimate the size of the install
        # This is used to drive the progress display
        self.source_size = os.stat(self.image_path)[stat.ST_SIZE] * 2

        self.pct_lock = Lock()
        self.pct = 0
        threadMgr.add(AnacondaThread(name=THREAD_LIVE_PROGRESS,
                                     target=self.progress))

        # Run the installation task.
        task = InstallFromTarTask(
            sysroot=conf.target.system_root,
            tarfile=self.image_path
        )
        task.run()

        # Wait for progress thread to finish
        with self.pct_lock:
            self.pct = 100
        threadMgr.wait(THREAD_LIVE_PROGRESS)
Beispiel #2
0
    def test_install_tar_task_failed_exception(self, exec_with_redirect):
        """Test installation from a tarball with an exception."""
        exec_with_redirect.side_effect = OSError("Fake!")
        task = InstallFromTarTask(sysroot="/mnt/root", tarfile="/source.tar")

        with pytest.raises(PayloadInstallationError) as cm:
            task.run()

        msg = "Failed to install tar: Fake!"
        assert str(cm.value) == msg
    def test_install_tar_task_failed_exception(self, exec_with_redirect,
                                               os_sync):
        """Test installation from a tarball with an exception."""
        exec_with_redirect.side_effect = OSError("Fake!")

        with tempfile.NamedTemporaryFile("w") as f:
            task = InstallFromTarTask(sysroot="/mnt/root", tarfile=f.name)

            with pytest.raises(PayloadInstallationError) as cm:
                task.run()

        msg = "Failed to install tar: Fake!"
        assert str(cm.value) == msg
Beispiel #4
0
    def test_install_tar_task(self, exec_with_redirect):
        """Test installation from a tarball."""
        exec_with_redirect.return_value = 0
        task = InstallFromTarTask(sysroot="/mnt/root", tarfile="/source.tar")
        task.run()

        exec_with_redirect.assert_called_once_with("tar", [
            "--numeric-owner", "--selinux", "--acls", "--xattrs",
            "--xattrs-include", "*", "--exclude", "./dev/*", "--exclude",
            "./proc/*", "--exclude", "./tmp/*", "--exclude", "./sys/*",
            "--exclude", "./run/*", "--exclude", "./boot/*rescue*",
            "--exclude", "./boot/loader", "--exclude", "./boot/efi/loader",
            "--exclude", "./etc/machine-id", "-xaf", "/source.tar", "-C",
            "/mnt/root"
        ])
 def _install_tarball(self):
     """Install the content of the tarball."""
     task = InstallFromTarTask(
         sysroot=self._sysroot,
         tarfile=self._tarball_path
     )
     self._run_task(task)
    def test_install_tar_task(self, exec_with_redirect, os_sync):
        """Test installation from a tarball."""
        exec_with_redirect.return_value = 0

        with tempfile.NamedTemporaryFile("w") as f:
            task = InstallFromTarTask(sysroot="/mnt/root", tarfile=f.name)
            task.run()

        exec_with_redirect.assert_called_once_with("tar", [
            "--numeric-owner", "--selinux", "--acls", "--xattrs",
            "--xattrs-include", "*", "--exclude", "./dev/*", "--exclude",
            "./proc/*", "--exclude", "./tmp/*", "--exclude", "./sys/*",
            "--exclude", "./run/*", "--exclude", "./boot/*rescue*",
            "--exclude", "./boot/loader", "--exclude", "./boot/efi/loader",
            "--exclude", "./etc/machine-id", "--exclude", "./etc/machine-info",
            "-xaf", f.name, "-C", "/mnt/root"
        ])
Beispiel #7
0
    def install_with_tasks(self):
        """Install the payload."""
        if url_target_is_tarfile(self._url):
            task = InstallFromTarTask(
                self.image_path,
                conf.target.system_root,
                self.kernel_version_list
            )
        else:
            task = InstallFromImageTask(
                conf.target.system_root,
                self.kernel_version_list
            )

        return [task]
Beispiel #8
0
 def _install_tar(self):
     # Run the installation task.
     task = InstallFromTarTask(sysroot=conf.target.system_root,
                               tarfile=self.image_path)
     task.run()