diff --git a/bin/pungi-gather b/bin/pungi-gather index a497edfd..7e5611cf 100755 --- a/bin/pungi-gather +++ b/bin/pungi-gather @@ -28,6 +28,11 @@ def get_parser(): required=True, help="path to kickstart config file", ) + parser.add_argument( + "--download-to", + metavar='PATH', + help="download packages to given directory instead of just printing paths", + ) group = parser.add_argument_group("Repository options") group.add_argument( @@ -130,7 +135,10 @@ def main(persistdir, cachedir): g.gather(packages, conditional_packages) - print_rpms(g) + if ns.download_to: + g.download(ns.download_to) + else: + print_rpms(g) if ns.profiler: Profiler.print_results() diff --git a/pungi/gather_dnf.py b/pungi/gather_dnf.py index 01983f4c..46c2d8c4 100644 --- a/pungi/gather_dnf.py +++ b/pungi/gather_dnf.py @@ -17,12 +17,15 @@ from enum import Enum from itertools import count import logging +import os from kobo.rpmlib import parse_nvra import pungi.common import pungi.dnf_wrapper import pungi.multilib_dnf +import pungi.util +from pungi.linker import Linker from pungi.profiler import Profiler from pungi.util import DEBUG_PATTERNS @@ -782,6 +785,22 @@ class Gather(GatherBase): # nothing added -> break depsolving cycle break + def download(self, destdir): + pkglist = (self.result_binary_packages | self.result_debug_packages | self.result_source_packages) + self.dnf.download_packages(pkglist) + linker = Linker(logger=self.logger) + + for pkg in pkglist: + basename = os.path.basename(pkg.relativepath) + target = os.path.join(destdir, basename) + + # Link downloaded package in (or link package from file repo) + try: + linker.hardlink(pkg.localPkg(), target) + except: + self.logger.error("Unable to link %s from the yum cache." % pkg.name) + raise + def log_count(self, msg, method, *args): """ Print a message, run the function with given arguments and log length diff --git a/pungi/phases/pkgset/sources/source_repos.py b/pungi/phases/pkgset/sources/source_repos.py index 55a58f54..f8e36479 100644 --- a/pungi/phases/pkgset/sources/source_repos.py +++ b/pungi/phases/pkgset/sources/source_repos.py @@ -70,8 +70,18 @@ def get_pkgset_from_repos(compose): pungi_conf = compose.paths.work.pungi_conf(arch=arch) pungi_log = compose.paths.log.log_file(arch, "pkgset_source") pungi_dir = compose.paths.work.pungi_download_dir(arch) - cmd = pungi.get_pungi_cmd(pungi_conf, destdir=pungi_dir, name="FOO", selfhosting=True, fulltree=True, multilib_methods=["all"], nodownload=False, full_archlist=True, arch=arch, cache_dir=compose.paths.work.pungi_cache_dir(arch=arch)) - cmd.append("--force") + + backends = { + 'yum': pungi.get_pungi_cmd, + 'dnf': pungi.get_pungi_cmd_dnf, + } + get_cmd = backends[compose.conf['gather_backend']] + cmd = get_cmd(pungi_conf, destdir=pungi_dir, name="FOO", + selfhosting=True, fulltree=True, multilib_methods=["all"], + nodownload=False, full_archlist=True, arch=arch, + cache_dir=compose.paths.work.pungi_cache_dir(arch=arch)) + if compose.conf['gather_backend'] == 'yum': + cmd.append("--force") # TODO: runroot run(cmd, logfile=pungi_log, show_cmd=True, stdout=False) diff --git a/pungi/wrappers/pungi.py b/pungi/wrappers/pungi.py index 1819228b..b127f7ff 100644 --- a/pungi/wrappers/pungi.py +++ b/pungi/wrappers/pungi.py @@ -192,6 +192,9 @@ class PungiWrapper(object): if arch: cmd.append("--arch=%s" % arch) + if not nodownload: + cmd.append("--download-to=%s" % destdir) + if multilib_methods: for i in multilib_methods: cmd.append("--multilib=%s" % i)