add support for choosing all arches for sack (RhBug:1443467)

References: https://bugzilla.redhat.com/show_bug.cgi?id=1443467
Reported-and-Tested-by: Petr Šabata <psabata@redhat.com>
Signed-off-by: Igor Gnatenko <ignatenko@redhat.com>
This commit is contained in:
Igor Gnatenko 2017-04-19 12:35:03 +02:00
parent b4583a3a58
commit 2bbd5252a7
5 changed files with 14 additions and 6 deletions

View File

@ -285,14 +285,14 @@ class Base(object):
logger.info(_('Metadata cache created.'))
return True
def fill_sack(self, load_system_repo=True, load_available_repos=True):
def fill_sack(self, load_system_repo=True, load_available_repos=True, all_arch=False):
# :api
"""Prepare the Sack and the Goal objects. """
timer = dnf.logging.Timer('sack setup')
if self._sack is not None and self._repos is not None:
for repo in self._repos.values():
repo._hawkey_repo = repo._init_hawkey_repo()
self._sack = dnf.sack._build_sack(self)
self._sack = dnf.sack._build_sack(self, all_arch=all_arch)
lock = dnf.lock.build_metadata_lock(self.conf.cachedir, self.conf.exit_on_lock)
with lock:
if load_system_repo is not False:

View File

@ -745,7 +745,8 @@ class Cli(object):
if demands.sack_activation:
self.base.fill_sack(load_system_repo='auto',
load_available_repos=self.demands.available_repos)
load_available_repos=self.demands.available_repos,
all_arch=demands.all_arch)
def _parse_commands(self, opts, args):
"""Check that the requested CLI command exists."""

View File

@ -245,6 +245,7 @@ class RepoQueryCommand(commands.Command):
demands.available_repos = True
demands.sack_activation = True
demands.all_arch = True
def build_format_fn(self, opts, pkg):
po = PackageWrapper(pkg)

View File

@ -49,6 +49,7 @@ class DemandSheet(object):
resolving = _BoolDefault(False)
root_user = _BoolDefault(False)
sack_activation = _BoolDefault(False)
all_arch = _BoolDefault(False)
success_exit_status = 0
cacheonly = _BoolDefault(False)

View File

@ -93,14 +93,19 @@ class Sack(hawkey.Sack):
return main
def _build_sack(base):
def _build_sack(base, all_arch=False):
cachedir = base.conf.cachedir
# create the dir ourselves so we have the permissions under control:
dnf.util.ensure_dir(cachedir)
kwargs = {}
if all_arch:
kwargs["all_arch"] = True
else:
kwargs["arch"] = base.conf.substitutions["arch"]
return Sack(pkgcls=dnf.package.Package, pkginitval=base,
arch=base.conf.substitutions["arch"],
cachedir=cachedir, rootdir=base.conf.installroot,
logfile=os.path.join(base.conf.logdir, dnf.const.LOG_HAWKEY))
logfile=os.path.join(base.conf.logdir, dnf.const.LOG_HAWKEY),
**kwargs)
def _rpmdb_sack(base):