From c3b49f7ffbeed665efe206ac47985689caed41be Mon Sep 17 00:00:00 2001 From: Lubomír Sedlář Date: Aug 16 2017 12:32:26 +0000 Subject: pkgset: Download packages with dnf When using repos as gather_source, we should use DNF backend even for constructing initial package set and to download the packages from source repos. Without this the repos source would not be usable on Python 3. Signed-off-by: Lubomír Sedlář --- diff --git a/bin/pungi-gather b/bin/pungi-gather index a497edf..7e5611c 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 01983f4..46c2d8c 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 55a58f5..f8e3647 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 1819228..b127f7f 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)