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)]
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