Пример #1
0
    def _run_kinit(self) -> None:
        """
        Run `kinit` if we have fas_user and keytab_path configured.
        """
        if (
            not self.config.fas_user
            or not self.config.keytab_path
            or not Path(self.config.keytab_path).is_file()
        ):
            logger.info("Won't be doing kinit, no credentials provided.")
            return

        cmd = [
            "kinit",
            f"{self.config.fas_user}@{self.config.kerberos_realm}",
            "-k",
            "-t",
            self.config.keytab_path,
        ]

        commands.run_command_remote(
            cmd=cmd,
            error_message="Failed to init kerberos ticket:",
            fail=True,
            # this prints debug logs from kerberos to stdout
            env={"KRB5_TRACE": "/dev/stdout"},
        )
Пример #2
0
    def _run_kinit(self) -> None:
        """Run `kinit`"""
        cmd = [
            "kinit",
            f"{self.config.fas_user}@{self.config.kerberos_realm}",
            "-k",
            "-t",
            self.config.keytab_path,
        ]

        commands.run_command_remote(
            cmd=cmd,
            error_message="Failed to init kerberos ticket:",
            fail=True,
            # this prints debug logs from kerberos to stdout
            env={"KRB5_TRACE": "/dev/stdout"},
        )
Пример #3
0
    def build(
        self,
        scratch: bool = False,
        nowait: bool = False,
        koji_target: Optional[str] = None,
        srpm_path: Optional[Path] = None,
    ):
        """
        build in koji

        :param scratch: scratch (temporary) build or not?
        :param nowait: False == wait for the build to finish
        :param koji_target: koji target to build in (`koji list-targets`)
        :param srpm_path: use selected SRPM for build, not dist-git repo & ref
        :return:
        """
        cmd = [self.fedpkg_exec, "build"]
        if scratch:
            cmd.append("--scratch")
        if nowait:
            cmd.append("--nowait")
        if koji_target:
            cmd += ["--target", koji_target]
        if srpm_path:
            cmd += ["--srpm", str(srpm_path)]

        try:
            commands.run_command_remote(
                cmd=cmd,
                cwd=self.directory,
                error_message="Submission of build to koji failed.",
                fail=True,
            )

        except PackitCommandFailedError as ex:
            # fail on the fedpkg side, the build is triggered
            if ("watch_tasks() got an unexpected keyword argument 'ki_handler'"
                    in ex.stderr_output):
                logger.info(
                    "The 'fedpkg build' command crashed which is a known issue: "
                    "the build is submitted in koji anyway.")
                logger.debug(ex.stdout_output)

            else:
                raise
Пример #4
0
    def new_sources(self, sources="", fail=True):
        if not Path(self.directory).is_dir():
            raise Exception("Cannot access fedpkg repository:")

        return commands.run_command_remote(
            cmd=[self.fedpkg_exec, "new-sources", sources],
            cwd=self.directory,
            error_message="Adding new sources failed:",
            fail=fail,
        )
Пример #5
0
    def new_sources(self, sources: Optional[Path] = None, fail: bool = True):
        if not self.directory.is_dir():
            raise Exception(
                f"Cannot access {self.tool} repository: {self.directory}")

        sources_ = str(sources) if sources else ""
        return commands.run_command_remote(
            cmd=[self.tool, "new-sources", sources_],
            cwd=self.directory,
            error_message="Adding new sources failed:",
            print_live=True,
            fail=fail,
        ).success
Пример #6
0
    def sources(self, fail: bool = True) -> str:
        """Run the 'sources' command

        Args:
            fail: Raise an exception if the command fails

        Returns:
            The 'stdout' of the sources command that is executed.
        """
        return commands.run_command_remote(
            cmd=[self.tool, "sources"],
            cwd=self.directory,
            error_message=
            "Downloading source files from the lookaside cache failed:",
            print_live=True,
            fail=fail,
        )
Пример #7
0
    def koji_build(
        self,
        scratch: bool = False,
        nowait: bool = False,
        koji_target: Optional[str] = None,
        srpm_path: Optional[Path] = None,
    ):
        """
        Perform a `koji build` in the repository

        :param scratch: should the build be a scratch build?
        :param nowait: don't wait on build?
        :param koji_target: koji target to pick (see `koji list-targets`)
        :param srpm_path: use selected SRPM for build, not dist-git repo & ref
        """
        if not koji_target:
            raise PackitException(
                "koji target needs to be set when building directly from upstream"
            )
        # we can't use fedpkg b/c upstream repo is not dist-git
        cmd = ["koji", "build"]
        if scratch:
            cmd.append("--scratch")
        if nowait:
            cmd.append("--nowait")
        cmd += [koji_target, str(srpm_path)]
        logger.info("Starting a koji build.")
        if not nowait:
            logger.info(
                "We will be actively waiting for the build to finish, it may take some time."
            )
        return commands.run_command_remote(
            cmd,
            cwd=self.local_project.working_dir,
            output=True,
            decode=True,
            print_live=True,
        )