Esempio n. 1
0
def get_koji_cmd(use_osg_koji):
    """Get the command used to call koji."""
    # Use osg-koji wrapper if available and configured.
    if utils.which("osg-koji") and use_osg_koji:
        return ["osg-koji"]
    elif utils.which("koji"):
        # Not using osg-koji, so we need to find the conf file and do some
        # checks ourselves.
        conf_file = (utils.find_file(KOJI_CONF, DATA_FILE_SEARCH_PATH)
                     or utils.find_file(OLD_KOJI_CONF, DATA_FILE_SEARCH_PATH))
        if not conf_file:
            raise KojiError("Can't find %s or %s; search path was: %s" %
                            (KOJI_CONF, OLD_KOJI_CONF,
                             os.pathsep.join(DATA_FILE_SEARCH_PATH)))

        return ["koji", "--config", conf_file, "--authtype", "ssl"]
    else:
        raise KojiError("Can't find koji or osg-koji!")
Esempio n. 2
0
    def lint(self):
        """lint task. Prebuild the package and run rpmlint on the SRPM."""
        if not utils.which("rpmlint"):
            raise ProgramNotFoundError("rpmlint")
        conf_file = utils.find_file("rpmlint.cfg", DATA_FILE_SEARCH_PATH)
        if not conf_file:
            raise FileNotFoundError("rpmlint.cfg", DATA_FILE_SEARCH_PATH)
        srpm = self.prebuild()
        lint_output, lint_returncode = utils.sbacktick(
            ["rpmlint", "-f", conf_file, srpm])

        print lint_output
        if lint_returncode == 0:
            print "rpmlint ok for " + self.package_name
        elif lint_returncode < 64:
            print "Error running rpmlint for " + self.package_name
        elif lint_returncode == 64:
            print "rpmlint found problems with " + self.package_name
        elif lint_returncode == 66:
            print "rpmlint found many problems with " + self.package_name
        else:
            print "unrecognized return code from rpmlint: " + str(lint_returncode)
Esempio n. 3
0
    def quilt(self):
        """quilt task. Prebuild the package (except for making the SRPM)
        and run 'quilt setup' on the spec file.

        """
        if not utils.which("quilt"):
            raise ProgramNotFoundError("quilt")

        if self.buildopts['autoclean']:
            if os.path.exists(self.quilt_dir):
                log.debug("autoclean removing " + self.quilt_dir)
                shutil.rmtree(self.quilt_dir)

        utils.safe_makedirs(self.quilt_dir)
        spec_filename = self.prebuild_external_sources(destdir=self.quilt_dir)

        os.chdir(self.quilt_dir)
        ret = utils.unchecked_call(["quilt", "-v", "setup", spec_filename])
        if ret != 0:
            raise Error("Error running 'quilt setup' on the spec file.")

        log.info("quilt files ready in %s", self.quilt_dir)
Esempio n. 4
0
    def lint(self):
        """lint task. Prebuild the package and run rpmlint on the SRPM."""
        if not utils.which("rpmlint"):
            raise ProgramNotFoundError("rpmlint")
        conf_file = utils.find_file("rpmlint.cfg", DATA_FILE_SEARCH_PATH)
        if not conf_file:
            raise FileNotFoundError("rpmlint.cfg", DATA_FILE_SEARCH_PATH)
        srpm = self.prebuild()
        lint_output, lint_returncode = utils.sbacktick(
            ["rpmlint", "-f", conf_file, srpm])

        print lint_output
        if lint_returncode == 0:
            print "rpmlint ok for " + self.package_name
        elif lint_returncode < 64:
            print "Error running rpmlint for " + self.package_name
        elif lint_returncode == 64:
            print "rpmlint found problems with " + self.package_name
        elif lint_returncode == 66:
            print "rpmlint found many problems with " + self.package_name
        else:
            print "unrecognized return code from rpmlint: " + str(lint_returncode)
Esempio n. 5
0
    def quilt(self):
        """quilt task. Prebuild the package (except for making the SRPM)
        and run 'quilt setup' on the spec file.

        """
        if not utils.which("quilt"):
            raise ProgramNotFoundError("quilt")

        if self.buildopts['autoclean']:
            if os.path.exists(self.quilt_dir):
                log.debug("autoclean removing " + self.quilt_dir)
                shutil.rmtree(self.quilt_dir)

        utils.safe_makedirs(self.quilt_dir)
        spec_filename = self.prebuild_external_sources(destdir=self.quilt_dir)

        os.chdir(self.quilt_dir)
        ret = utils.unchecked_call(["quilt", "-v", "setup", spec_filename])
        if ret != 0:
            raise Error("Error running 'quilt setup' on the spec file.")

        log.info("quilt files ready in %s", self.quilt_dir)
Esempio n. 6
0
    # Hack to load koji modules
    # This loads the koji libraries (koji/__init__.py) as kojilib, and the
    # script that is the koji cli (cli/koji or /usr/bin/koji) as kojicli
    import imp
    # UW CSL hack
    if os.path.isdir(CSL_KOJI_DIR):
        # explicitly import koji (as kojilib) from CSL_KOJI_DIR
        kojilib_filehandle, kojilib_filename, kojilib_desc = (imp.find_module(
            'koji', [CSL_KOJI_DIR]))
        kojilib = imp.load_module('koji', kojilib_filehandle, kojilib_filename,
                                  kojilib_desc)
        # HAAACK
        kojicli_filename = os.path.join(CSL_KOJI_DIR, "cli", "koji")
    else:
        import koji as kojilib  # pylint: disable=F0401
        kojicli_filename = utils.which("koji")
    # load koji cli (as kojicli) from either somewhere in $PATH or CSL_KOJI_DIR/cli/koji
    # I can't use imp.find_module here to get the values I need because
    # /usr/bin/koji doesn't end in .py
    kojicli_filehandle = open(kojicli_filename)
    kojicli_desc = ('', kojicli_filehandle.mode, imp.PY_SOURCE)
    kojicli = imp.load_module('kojicli', kojicli_filehandle, kojicli_filename,
                              kojicli_desc)
    if kojilib.BR_STATES and kojilib.BUILD_STATES and kojilib.REPO_STATES and kojilib.TASK_STATES:
        HAVE_KOJILIB = True
    else:
        HAVE_KOJILIB = False
except ImportError:
    HAVE_KOJILIB = False
except AttributeError:
    HAVE_KOJILIB = False