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ář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2017-08-14 14:15:18 +02:00
parent be4501c54b
commit c3b49f7ffb
4 changed files with 43 additions and 3 deletions

View File

@ -28,6 +28,11 @@ def get_parser():
required=True, required=True,
help="path to kickstart config file", 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 = parser.add_argument_group("Repository options")
group.add_argument( group.add_argument(
@ -130,6 +135,9 @@ def main(persistdir, cachedir):
g.gather(packages, conditional_packages) g.gather(packages, conditional_packages)
if ns.download_to:
g.download(ns.download_to)
else:
print_rpms(g) print_rpms(g)
if ns.profiler: if ns.profiler:
Profiler.print_results() Profiler.print_results()

View File

@ -17,12 +17,15 @@
from enum import Enum from enum import Enum
from itertools import count from itertools import count
import logging import logging
import os
from kobo.rpmlib import parse_nvra from kobo.rpmlib import parse_nvra
import pungi.common import pungi.common
import pungi.dnf_wrapper import pungi.dnf_wrapper
import pungi.multilib_dnf import pungi.multilib_dnf
import pungi.util
from pungi.linker import Linker
from pungi.profiler import Profiler from pungi.profiler import Profiler
from pungi.util import DEBUG_PATTERNS from pungi.util import DEBUG_PATTERNS
@ -782,6 +785,22 @@ class Gather(GatherBase):
# nothing added -> break depsolving cycle # nothing added -> break depsolving cycle
break 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): def log_count(self, msg, method, *args):
""" """
Print a message, run the function with given arguments and log length Print a message, run the function with given arguments and log length

View File

@ -70,7 +70,17 @@ def get_pkgset_from_repos(compose):
pungi_conf = compose.paths.work.pungi_conf(arch=arch) pungi_conf = compose.paths.work.pungi_conf(arch=arch)
pungi_log = compose.paths.log.log_file(arch, "pkgset_source") pungi_log = compose.paths.log.log_file(arch, "pkgset_source")
pungi_dir = compose.paths.work.pungi_download_dir(arch) 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))
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") cmd.append("--force")
# TODO: runroot # TODO: runroot

View File

@ -192,6 +192,9 @@ class PungiWrapper(object):
if arch: if arch:
cmd.append("--arch=%s" % arch) cmd.append("--arch=%s" % arch)
if not nodownload:
cmd.append("--download-to=%s" % destdir)
if multilib_methods: if multilib_methods:
for i in multilib_methods: for i in multilib_methods:
cmd.append("--multilib=%s" % i) cmd.append("--multilib=%s" % i)