159 lines
6.4 KiB
Diff
159 lines
6.4 KiB
Diff
From 1bfea4523b803917e37f81f83519721848012674 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= <lsedlar@redhat.com>
|
|
Date: Wed, 7 Mar 2018 13:42:09 +0100
|
|
Subject: [PATCH 06/12] gather: Honor package whitelist
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Basically everything not on the list is excluded. This has to be applied
|
|
before we filter only the latest versions (otherwise we could lose
|
|
packages that are on the whitelist).
|
|
|
|
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
|
|
---
|
|
bin/pungi-gather | 1 +
|
|
pungi/gather_dnf.py | 29 +++++++++++++++++++-----
|
|
tests/test_gather.py | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
3 files changed, 88 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/bin/pungi-gather b/bin/pungi-gather
|
|
index daf80f2c..aa70977b 100755
|
|
--- a/bin/pungi-gather
|
|
+++ b/bin/pungi-gather
|
|
@@ -125,6 +125,7 @@ def main(persistdir, cachedir):
|
|
gather_opts.multilib_whitelist = ksparser.handler.multilib_whitelist
|
|
gather_opts.prepopulate = ksparser.handler.prepopulate
|
|
gather_opts.fulltree_excludes = ksparser.handler.fulltree_excludes
|
|
+ gather_opts.package_whitelist = ksparser.handler.package_whitelist
|
|
|
|
g = Gather(dnf_obj, gather_opts)
|
|
|
|
diff --git a/pungi/gather_dnf.py b/pungi/gather_dnf.py
|
|
index 1a47eea6..1023c57d 100644
|
|
--- a/pungi/gather_dnf.py
|
|
+++ b/pungi/gather_dnf.py
|
|
@@ -69,6 +69,8 @@ class GatherOptions(pungi.common.OptionsBase):
|
|
# lookaside repos; packages will be flagged accordingly
|
|
self.lookaside_repos = []
|
|
|
|
+ self.package_whitelist = set()
|
|
+
|
|
self.merge_options(**kwargs)
|
|
|
|
|
|
@@ -363,12 +365,29 @@ class Gather(GatherBase):
|
|
self.logger.debug("EXCLUDED by %s: %s", pattern, [str(p) for p in pkgs])
|
|
self.dnf._sack.add_excludes(pkgs)
|
|
|
|
+ all_queues = ['q_binary_packages', 'q_native_binary_packages',
|
|
+ 'q_multilib_binary_packages', 'q_noarch_binary_packages',
|
|
+ 'q_source_packages', 'q_native_debug_packages',
|
|
+ 'q_multilib_debug_packages']
|
|
+
|
|
+ if self.opts.package_whitelist:
|
|
+ with Profiler("Gather._apply_excludes():apply-package-whitelist'"):
|
|
+ to_keep = []
|
|
+ for pattern in self.opts.package_whitelist:
|
|
+ nvra = parse_nvra(pattern)
|
|
+ nvra.pop('src')
|
|
+ try:
|
|
+ nvra['epoch'] = int(nvra.pop('epoch'))
|
|
+ except ValueError:
|
|
+ pass
|
|
+ to_keep.extend(self._query.filter(**nvra).run())
|
|
+
|
|
+ for queue in all_queues:
|
|
+ setattr(self, queue, getattr(self, queue).filter(pkg=to_keep).latest().apply())
|
|
+
|
|
with Profiler("Gather._apply_excludes():exclude-queries"):
|
|
- self._filter_queue('q_binary_packages', exclude)
|
|
- self._filter_queue('q_native_binary_packages', exclude)
|
|
- self._filter_queue('q_multilib_binary_packages', exclude)
|
|
- self._filter_queue('q_noarch_binary_packages', exclude)
|
|
- self._filter_queue('q_source_packages', exclude)
|
|
+ for queue in all_queues:
|
|
+ self._filter_queue(queue, exclude)
|
|
|
|
@Profiler("Gather.add_initial_packages()")
|
|
def add_initial_packages(self, pattern_list):
|
|
diff --git a/tests/test_gather.py b/tests/test_gather.py
|
|
index 0b015abe..e73ae9c3 100644
|
|
--- a/tests/test_gather.py
|
|
+++ b/tests/test_gather.py
|
|
@@ -1791,8 +1791,71 @@ class DNFDepsolvingTestCase(DepsolvingBase, unittest.TestCase):
|
|
def test_bash_older(self):
|
|
pass
|
|
|
|
+ def test_whitelist_old_version(self):
|
|
+ # There are two version of dummy-bash in the package set; let's
|
|
+ # whitelist only the older one and its dependencies.
|
|
+ packages = [
|
|
+ "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",
|
|
+ ]
|
|
+ pkg_map = self.go(packages, None, greedy="none", package_whitelist=package_whitelist)
|
|
+
|
|
+ self.assertNotIn("dummy-bash-4.2.37-5.i686.rpm", pkg_map["rpm"])
|
|
+ self.assertNotIn("dummy-bash-4.2.37-6.i686.rpm", pkg_map["rpm"])
|
|
+ self.assertNotIn("dummy-bash-4.2.37-6.x86_64.rpm", pkg_map["rpm"])
|
|
+
|
|
+ self.assertItemsEqual(pkg_map["rpm"], [
|
|
+ "dummy-basesystem-10.0-6.noarch.rpm",
|
|
+ "dummy-bash-4.2.37-5.x86_64.rpm",
|
|
+ "dummy-filesystem-4.2.37-6.x86_64.rpm",
|
|
+ "dummy-glibc-2.14-5.x86_64.rpm",
|
|
+ "dummy-glibc-common-2.14-5.x86_64.rpm",
|
|
+ ])
|
|
+ self.assertItemsEqual(pkg_map["srpm"], [
|
|
+ "dummy-basesystem-10.0-6.src.rpm",
|
|
+ "dummy-bash-4.2.37-5.src.rpm",
|
|
+ "dummy-filesystem-4.2.37-6.src.rpm",
|
|
+ "dummy-glibc-2.14-5.src.rpm",
|
|
+ ])
|
|
+ self.assertItemsEqual(pkg_map["debuginfo"], [
|
|
+ "dummy-bash-debuginfo-4.2.37-5.x86_64.rpm",
|
|
+ "dummy-glibc-debuginfo-2.14-5.x86_64.rpm",
|
|
+ "dummy-glibc-debuginfo-common-2.14-5.x86_64.rpm",
|
|
+ ])
|
|
+
|
|
def test_firefox_selfhosting_with_krb5_lookaside(self):
|
|
super(DNFDepsolvingTestCase, self).test_firefox_selfhosting_with_krb5_lookaside()
|
|
self.assertFlags("dummy-krb5-devel-1.10-5.x86_64", [PkgFlag.lookaside])
|
|
self.assertFlags("dummy-krb5-1.10-5.src", [PkgFlag.lookaside])
|
|
self.assertFlags("dummy-krb5-debuginfo-1.10-5.x86_64", [PkgFlag.lookaside])
|
|
+
|
|
+ def test_package_whitelist(self):
|
|
+ packages = ['*']
|
|
+ whitelist = [
|
|
+ 'dummy-bash-4.2.37-6.x86_64',
|
|
+ 'dummy-bash-4.2.37-6.src',
|
|
+ ]
|
|
+
|
|
+ pkg_map = self.go(packages, None, package_whitelist=whitelist)
|
|
+
|
|
+ self.assertItemsEqual(pkg_map["rpm"], [
|
|
+ 'dummy-bash-4.2.37-6.x86_64.rpm',
|
|
+ ])
|
|
+ self.assertItemsEqual(pkg_map["srpm"], [
|
|
+ 'dummy-bash-4.2.37-6.src.rpm',
|
|
+ ])
|
|
+ self.assertItemsEqual(pkg_map["debuginfo"], [
|
|
+ ])
|
|
--
|
|
2.13.6
|
|
|