Ejemplo n.º 1
0
def prepare_0(repo, srpm, level=None):
    """
    Make up list of command strings to deploy built RPMs.

    :param repo: myrepo.repo.Repo instance
    :param srpm: myrepo.srpm.Srpm instance
    :param level: Logging level

    :return: List of command strings to deploy built RPMs.
    """
    MCU.assert_repo(repo)
    MCU.assert_srpm(srpm)

    f = lambda b: "mock -r %s %s%s" % (b, srpm.path, _log_opt(level))

    return [f(b) for b in repo.list_build_labels(srpm)]
Ejemplo n.º 2
0
 def test_12_assert_srpm__ng(self):
     with self.assertRaises(AssertionError) as cm:
         TT.assert_srpm(None)
Ejemplo n.º 3
0
 def test_10_assert_srpm__ok(self):
     srpm = MS.Srpm("/a/b/c/dummy/path/to/srpm.rpm")
     TT.assert_srpm(srpm)
Ejemplo n.º 4
0
def prepare_0(repo, srpm, build=False):
    """
    Make up list of command strings to deploy built RPMs.

    :param repo: myrepo.repo.Repo instance
    :param srpm: myrepo.srpm.Srpm instance
    :param build: Build given srpm before deployment

    :return: List of command strings to deploy built RPMs.
    """
    assert_repo(repo)
    assert_srpm(srpm)

    if build:
        bcs = MCB.prepare_0(repo, srpm)

    ucs = MCU.prepare_0(repo)

    dcmd = repo.server.deploy_cmd
    rpmdirs = repo.mockdirs(srpm)

    # TODO: Sub RPM packages may have completely different names.
    #rpmname_pre = "%s-%s-" % (srpm.name, srpm.version)
    rpmname_pre = ''
    c0 = dcmd(os.path.join(rpmdirs[0], rpmname_pre + "*.src.rpm"),
              os.path.join(repo.destdir, "sources"))

    if srpm.noarch:
        noarch_rpms = rpmname_pre + "*.noarch.rpm"

        if repo.other_archs:
            ctx = dict(other_archs_s=' '.join(repo.other_archs),
                       primary_arch=repo.primary_arch,
                       noarch_rpms=noarch_rpms)
            (sc, sc_dir) = repo.adjust_cmd(_MK_SYMLINKS_TO_NOARCH_RPM % ctx,
                                           repo.destdir)

            bc = MS.bind(dcmd(os.path.join(rpmdirs[0], noarch_rpms),
                              os.path.join(repo.destdir, repo.primary_arch)),
                         sc)[0]
        else:
            bc = dcmd(os.path.join(rpmdirs[0], noarch_rpms),
                      os.path.join(repo.destdir, repo.primary_arch))

        if build:
            cs = [MS.join(bcs[0], c0, bc, *ucs)]
        else:
            cs = [MS.join(c0, ucs[0]), MS.join(bc, *ucs[1:])]
    else:
        cs = [dcmd(os.path.join(d, rpmname_pre + "*.%s.rpm" % a),
              os.path.join(repo.destdir, a)) for d, a
              in itertools.izip(rpmdirs, repo.archs)]

        if build:
            cs = [MS.bind(bc, c)[0] for bc, c in itertools.izip(bcs, cs)]
            cs = [MS.join(c, uc) for c, uc in itertools.izip(cs, ucs[1:])]
            cs[0] = MS.join(cs[0], c0, ucs[0])
        else:
            cs = [MS.join(c0, ucs[0])] + \
                 [MS.join(c, uc) for c, uc in itertools.izip(cs, ucs[1:])]

    return cs