gather: Fix package set whitelist
We need to include all relevant arches, not just the base one (including noarch and src). However the list can be shortened by only listing NEVRs, because that should be unique. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
c83316da31
commit
56e00505e0
@ -19,7 +19,7 @@ from itertools import count
|
||||
import logging
|
||||
import os
|
||||
|
||||
from kobo.rpmlib import parse_nvra
|
||||
from kobo.rpmlib import parse_nvra, parse_nvr
|
||||
|
||||
import pungi.common
|
||||
import pungi.dnf_wrapper
|
||||
@ -374,13 +374,12 @@ class Gather(GatherBase):
|
||||
with Profiler("Gather._apply_excludes():apply-package-whitelist'"):
|
||||
to_keep = []
|
||||
for pattern in self.opts.package_whitelist:
|
||||
nvra = parse_nvra(pattern)
|
||||
nvra.pop('src')
|
||||
nvr = parse_nvr(pattern)
|
||||
try:
|
||||
nvra['epoch'] = int(nvra.pop('epoch'))
|
||||
nvr['epoch'] = int(nvr.pop('epoch'))
|
||||
except ValueError:
|
||||
pass
|
||||
to_keep.extend(self._query.filter(**nvra).run())
|
||||
to_keep.extend(self._query.filter(**nvr).run())
|
||||
|
||||
for queue in all_queues:
|
||||
setattr(self, queue, getattr(self, queue).filter(pkg=to_keep).latest().apply())
|
||||
|
@ -23,7 +23,7 @@ from kobo.rpmlib import parse_nvra
|
||||
from pungi.util import rmtree, get_arch_variant_data
|
||||
from pungi.wrappers.pungi import PungiWrapper
|
||||
|
||||
from pungi.arch import tree_arch_to_yum_arch
|
||||
from pungi.arch import tree_arch_to_yum_arch, get_valid_arches
|
||||
import pungi.phases.gather
|
||||
|
||||
import pungi.phases.gather.method
|
||||
@ -109,8 +109,11 @@ def write_pungi_config(compose, arch, variant, packages, groups, filter_packages
|
||||
|
||||
package_whitelist = set()
|
||||
if variant.pkgset:
|
||||
for rpm_obj in variant.pkgset.rpms_by_arch.get(arch, []):
|
||||
package_whitelist.add(rpm_obj.nevra)
|
||||
multilib = get_arch_variant_data(compose.conf, 'multilib', arch, variant)
|
||||
for i in get_valid_arches(arch, multilib=multilib, add_noarch=True, add_src=True):
|
||||
for rpm_obj in variant.pkgset.rpms_by_arch.get(i, []):
|
||||
package_whitelist.add(
|
||||
'{0.name}-{1}:{0.version}-{0.release}'.format(rpm_obj, rpm_obj.epoch or 0))
|
||||
|
||||
pungi_wrapper.write_kickstart(
|
||||
ks_path=pungi_cfg, repos=repos, groups=groups, packages=packages_str,
|
||||
|
@ -1853,18 +1853,14 @@ class DNFDepsolvingTestCase(DepsolvingBase, unittest.TestCase):
|
||||
"dummy-bash",
|
||||
]
|
||||
package_whitelist = [
|
||||
"dummy-basesystem-10.0-6.noarch",
|
||||
"dummy-basesystem-10.0-6.src",
|
||||
"dummy-bash-debuginfo-4.2.37-5.x86_64",
|
||||
"dummy-bash-4.2.37-5.x86_64",
|
||||
"dummy-bash-4.2.37-5.src",
|
||||
"dummy-filesystem-4.2.37-6.x86_64",
|
||||
"dummy-filesystem-4.2.37-6.src",
|
||||
"dummy-glibc-common-2.14-5.x86_64",
|
||||
"dummy-glibc-debuginfo-common-2.14-5.x86_64",
|
||||
"dummy-glibc-debuginfo-2.14-5.x86_64",
|
||||
"dummy-glibc-2.14-5.x86_64",
|
||||
"dummy-glibc-2.14-5.src",
|
||||
"dummy-basesystem-10.0-6",
|
||||
"dummy-bash-debuginfo-4.2.37-5",
|
||||
"dummy-bash-4.2.37-5",
|
||||
"dummy-filesystem-4.2.37-6",
|
||||
"dummy-glibc-common-2.14-5",
|
||||
"dummy-glibc-debuginfo-common-2.14-5",
|
||||
"dummy-glibc-debuginfo-2.14-5",
|
||||
"dummy-glibc-2.14-5",
|
||||
]
|
||||
pkg_map = self.go(packages, None, greedy="none", package_whitelist=package_whitelist)
|
||||
|
||||
@ -1900,8 +1896,7 @@ class DNFDepsolvingTestCase(DepsolvingBase, unittest.TestCase):
|
||||
def test_package_whitelist(self):
|
||||
packages = ['*']
|
||||
whitelist = [
|
||||
'dummy-bash-4.2.37-6.x86_64',
|
||||
'dummy-bash-4.2.37-6.src',
|
||||
'dummy-bash-4.2.37-6',
|
||||
]
|
||||
|
||||
pkg_map = self.go(packages, None, package_whitelist=whitelist)
|
||||
|
@ -64,9 +64,9 @@ class TestWritePungiConfig(helpers.PungiTestCase):
|
||||
pkgs = [('pkg1', None), ('pkg2', 'x86_64')]
|
||||
grps = ['grp1']
|
||||
filter = [('pkg3', None), ('pkg4', 'x86_64')]
|
||||
self.compose.variants['Server'].pkgset.rpms_by_arch['x86_64'] = [
|
||||
mock.Mock(nevra='pkg-1.0.0-1')
|
||||
]
|
||||
mock_rpm = mock.Mock(version='1.0.0', release='1', epoch=0)
|
||||
mock_rpm.name = 'pkg'
|
||||
self.compose.variants['Server'].pkgset.rpms_by_arch['x86_64'] = [mock_rpm]
|
||||
white = mock.Mock()
|
||||
black = mock.Mock()
|
||||
prepopulate = mock.Mock()
|
||||
@ -81,7 +81,7 @@ class TestWritePungiConfig(helpers.PungiTestCase):
|
||||
repos={'pungi-repo': self.topdir + '/work/x86_64/repo'},
|
||||
exclude_packages=['pkg3', 'pkg4.x86_64'],
|
||||
fulltree_excludes=fulltree,
|
||||
package_whitelist=set(['pkg-1.0.0-1']))
|
||||
package_whitelist=set(['pkg-0:1.0.0-1']))
|
||||
|
||||
@mock.patch('pungi.phases.gather.methods.method_deps.PungiWrapper')
|
||||
def test_without_input(self, PungiWrapper):
|
||||
|
Loading…
Reference in New Issue
Block a user