Beispiel #1
0
def run(ctx):
    """
    Initialize yum repos.

    :param ctx: Application context
    :return: True if commands run successfully else False
    """
    assert_ctx_has_key(ctx, "repos")

    cs = prepare(ctx["repos"])

    if ctx.get("dryrun", False):
        for c in cs:
            print c

        if ctx.get("genconf", False):
            return MCG.run(ctx)

        return True

    logging.info("Run myrepo.commands.init.run...")
    if all(MS.prun(cs, dict(logfile=False, ))):
        return MCG.run(ctx) if ctx.get("genconf", False) else True
    else:
        RuntimeError("Could not initialize the yum repos")
Beispiel #2
0
    def test_200_run__deploy(self):
        topdir = os.path.join(self.workdir, "yum")
        repos = mk_local_repos(topdir)
        ctx = mk_ctx(repos[:1])
        ctx["workdir"] = self.workdir
        ctx["deploy"] = True

        repo = repos[0]

        # ensure dirs to deploy rpms exists:
        rpmdirs = [os.path.join(repo.destdir, a) for a
                   in repo.archs + ["sources"]]

        for d in rpmdirs:
            os.makedirs(d)

        self.assertTrue(TT.run(ctx))

        def _list_rpms(d, pat="*.src.rpm"):
            return glob.glob(os.path.join(d, pat))

        srpms = _list_rpms(self.workdir)
        self.assertTrue(srpms)
        self.assertEquals(len(srpms), 1)  # A srpm should exist.
        srpm = Srpm(srpms[0])
        srpm.resolve()

        for d in rpmdirs:
            rpms = _list_rpms(d, "*.rpm")
            self.assertTrue(rpms)
Beispiel #3
0
    def test_112_run_multi_repos(self):
        repos = mk_local_repos(os.path.join(self.workdir, "yum"))
        ctx = mk_ctx(repos)
        ctx["workdir"] = self.workdir

        self.assertTrue(TT.run(ctx))

        # FIXME: Likewise
        reposrpms = glob.glob(os.path.join(self.workdir, "*.src.rpm"))

        self.assertTrue(reposrpms)
        self.assertEquals(len(reposrpms), 3)  # There are 3 repos.
Beispiel #4
0
    def test_110_run(self):
        repos = mk_local_repos(os.path.join(self.workdir, "yum"))
        ctx = mk_ctx(repos[:1])
        ctx["workdir"] = self.workdir

        self.assertTrue(TT.run(ctx))

        # FIXME: What should be done with the result to check its success ?
        reposrpms = glob.glob(os.path.join(self.workdir, "*.src.rpm"))

        self.assertTrue(reposrpms)
        self.assertEquals(len(reposrpms), 1)  # A srpm should exist.
Beispiel #5
0
    def test_120_run__w_gpgkey(self):
        repos = mk_local_repos(os.path.join(self.workdir, "yum"))
        ctx = mk_ctx(repos[:1])
        ctx["workdir"] = self.workdir

        keyids = _find_gpg_keyids()
        if keyids:
            ctx["keyid"] = keyid = random.choice(keyids)
        else:
            sys.stderr.write("No GPG keyid was found. Skip this test...\n")
            return

        self.assertTrue(TT.run(ctx))

        # FIXME: What should be done with the result to check its success ?
        reposrpms = glob.glob(os.path.join(self.workdir, "*.src.rpm"))

        self.assertTrue(reposrpms)
        self.assertEquals(len(reposrpms), 1)  # A srpm should exist.
Beispiel #6
0
    def test_202_run__deploy_w_gpgkey(self):
        topdir = os.path.join(self.workdir, "yum")
        repos = mk_local_repos(topdir)
        ctx = mk_ctx(repos[:1])
        ctx["workdir"] = self.workdir
        ctx["deploy"] = True

        repo = repos[0]

        # ensure dirs to deploy rpms exists:
        rpmdirs = [os.path.join(repo.destdir, a) for a
                   in repo.archs + ["sources"]]

        for d in rpmdirs:
            os.makedirs(d)

        keyids = _find_gpg_keyids()
        if keyids:
            ctx["keyid"] = keyid = random.choice(keyids)
        else:
            sys.stderr.write("No GPG keyid was found. Skip this test...\n")
            return

        self.assertTrue(TT.run(ctx))

        def _list_rpms(d, pat="*.src.rpm"):
            return glob.glob(os.path.join(d, pat))

        srpms = _list_rpms(self.workdir)
        self.assertTrue(srpms)
        self.assertEquals(len(srpms), 1)  # A srpm should exist.
        srpm = Srpm(srpms[0])
        srpm.resolve()

        for d in rpmdirs:
            rpms = _list_rpms(d, "*.rpm")
            self.assertTrue(rpms)