Esempio n. 1
0
def prepare_0(repo):
    """
    Make up list of command strings to initialize repo.

    :param repo: myrepo.repo.Repo instance
    :return: List of command strings to deploy built RPMs.
    """
    assert_repo(repo)

    dirs_s = _join_dirs(repo.destdir, repo.archs + ["sources"])
    return [repo.mk_cmd("mkdir -p " + dirs_s)[0]]
Esempio n. 2
0
def gen_rpmspec_content(repo, ctx, tpaths):
    """
    Make up the content of RPM SPEC file for RPMs contain .repo and mock.cfg
    files for given repo ``repo``.

    :param repo: Repo object
    :param ctx: Context object to instantiate the template
    :param tpaths: Template path list :: [str]

    :return: String represents the content of RPM SPEC file :: str
    """
    assert_repo(repo)
    ctx["repo"] = repo.as_dict()
    ctx = _setup_extra_template_vars(ctx)

    return MU.compile_template("yum-repodata.spec", ctx, tpaths)
Esempio n. 3
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)]
Esempio n. 4
0
def prepare_0(repo, ctx, deploy=False, eof=None):
    """
    Make up list of command strings to generate repo's metadata rpms.

    :param repo: myrepo.repo.Repo instance
    :param ctx: Context object to instantiate the template
    :param deploy: Deploy generated yum repo metadata RPMs also if True
    :param eof: The function to generate EOF marker strings for here docuemnts
        or None, that is, it will be generated automatically.

    :return: List of command strings to deploy built RPMs.
    """
    assert_repo(repo)
    _check_vars_for_template(ctx, ["workdir", "tpaths"])

    files = list(gen_repo_files_g(repo, ctx, ctx["workdir"], ctx["tpaths"]))
    rpmspec = files[-1][0]  # FIXME: Ugly hack! (see ``gen_repo_files_g``)

    mockcfg_gen_cmds = list(gen_mockcfg_files_cmd_g(repo, ctx, ctx["workdir"], ctx["tpaths"], eof))

    cs = ["mkdir -p " + ctx["workdir"]]

    keyid = ctx.get("keyid", False)
    if keyid:
        cs.append(mk_export_gpgkey_cmd(keyid, ctx["workdir"], repo))

    cs += (
        [mk_write_file_cmd(p, c, eof) for p, c in files]
        + mockcfg_gen_cmds
        + [mk_build_srpm_cmd(rpmspec, ctx.get("verbose", False))]
    )

    # NOTE: cmd to build srpm must wait for the completion of previous commands
    # to generate files; .repo file, the rpm spec and mock.cfg files:
    c = MS.join(*cs)

    if not deploy:
        return [c]

    srpm = _mk_repo_metadata_srpm_obj(repo, ctx["workdir"])
    dcs = MCD.prepare_0(repo, srpm, build=True)

    assert len(dcs) == 1, "Deploy commands not matched w/ expected: \n" + str(dcs)

    return [MS.join(c, *dcs)]
Esempio n. 5
0
 def test_02_assert_repo__ng(self):
     with self.assertRaises(AssertionError) as cm:
         TT.assert_repo(None)
Esempio n. 6
0
 def test_00_assert_repo__ok(self):
     TT.assert_repo(_REMOTE_REPO_0)
Esempio n. 7
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