Ejemplo n.º 1
0
    def get_repo(self):
        """
        Return string of generated repository located LOCALLY
        It downloads all tagged packages and creates repo via createrepo

        :return: str
        """
        dir_prefix = BASEPATHDIR
        process.run(
            "{HOSTPACKAGER} install createrepo koji".format(**trans_dict),
            ignore_status=True)
        if is_recursive_download():
            dirname = os.path.join(dir_prefix, "localrepo_recursive")
        else:
            dirname = os.path.join(
                dir_prefix,
                "localrepo_%s_%s_%s" % (self.name, self.stream, self.version))
        absdir = os.path.abspath(dirname)
        # Test if directory contains repository, otherwise download everything again
        if os.path.exists(os.path.join(absdir, "repodata", "repomd.xml")):
            pass
        else:
            if not os.path.exists(absdir):
                os.mkdir(absdir)
            self.download_tagged(absdir)
            if is_recursive_download():
                allmodules = self.generateDepModules()
                for mo in allmodules:
                    localrepo = PDCParserKoji(mo, allmodules[mo])
                    localrepo.download_tagged(dirname)

            process.run("cd %s; createrepo -v %s" % (absdir, absdir),
                        shell=True,
                        verbose=is_debug())
        return "file://%s" % absdir
Ejemplo n.º 2
0
 def tmpfunc():
     a = process.run(
         "cd %s; koji download-build %s  -a %s -a noarch" %
         (dirname, pkgbouid, ARCH),
         shell=True,
         verbose=is_debug(),
         ignore_status=True)
     if a.exit_status == 1:
         if "packages available for" in a.stdout.strip():
             print_debug(
                 'UNABLE TO DOWNLOAD package (intended for other architectures, GOOD):',
                 a.command)
         else:
             raise mtfexceptions.KojiExc(
                 'UNABLE TO DOWNLOAD package (KOJI issue, BAD):',
                 a.command)
Ejemplo n.º 3
0
    def download_tagged(self, dirname):
        """
        Downloads packages to directory, based on koji tags
        It downloads just ARCH and noarch packages

        :param dirname: string
        :return: None
        """
        print_info("DOWNLOADING ALL packages for %s_%s_%s" %
                   (self.name, self.stream, self.version))
        for foo in process.run("koji list-tagged --quiet %s" %
                               self.get_pdc_info()["koji_tag"],
                               verbose=is_debug()).stdout.split("\n"):
            pkgbouid = foo.strip().split(" ")[0]
            if len(pkgbouid) > 4:
                print_debug("DOWNLOADING: %s" % foo)

                @Retry(
                    attempts=DEFAULTRETRYCOUNT * 10,
                    timeout=DEFAULTRETRYTIMEOUT * 60,
                    delay=DEFAULTRETRYTIMEOUT,
                    error=mtfexceptions.KojiExc(
                        "RETRY: Unbale to fetch package from koji after %d attempts"
                        % (DEFAULTRETRYCOUNT * 10)))
                def tmpfunc():
                    a = process.run(
                        "cd %s; koji download-build %s  -a %s -a noarch" %
                        (dirname, pkgbouid, ARCH),
                        shell=True,
                        verbose=is_debug(),
                        ignore_status=True)
                    if a.exit_status == 1:
                        if "packages available for" in a.stdout.strip():
                            print_debug(
                                'UNABLE TO DOWNLOAD package (intended for other architectures, GOOD):',
                                a.command)
                        else:
                            raise mtfexceptions.KojiExc(
                                'UNABLE TO DOWNLOAD package (KOJI issue, BAD):',
                                a.command)

                tmpfunc()
        print_info("DOWNLOADING finished")