Write package whitelist for each variant
If we have a package set for the variant (which happens if there are modules), include a list of all NEVRAs in the pungi kickstart. This can be used to make sure only packages from correct tag get into the compose. If two packages with same name but different version get into the compose, this can help get even older version into a particular variant. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
11c2af3246
commit
41d0139b39
15
pungi/ks.py
15
pungi/ks.py
@ -127,6 +127,19 @@ class PrepopulateSection(pykickstart.sections.Section):
|
|||||||
self.handler.prepopulate.add(line)
|
self.handler.prepopulate.add(line)
|
||||||
|
|
||||||
|
|
||||||
|
class PackageWhitelistSection(pykickstart.sections.Section):
|
||||||
|
sectionOpen = "%package-whitelist"
|
||||||
|
|
||||||
|
def handleLine(self, line):
|
||||||
|
if not self.handler:
|
||||||
|
return
|
||||||
|
|
||||||
|
(h, s, t) = line.partition('#')
|
||||||
|
line = h.rstrip()
|
||||||
|
|
||||||
|
self.handler.package_whitelist.add(line)
|
||||||
|
|
||||||
|
|
||||||
class KickstartParser(pykickstart.parser.KickstartParser):
|
class KickstartParser(pykickstart.parser.KickstartParser):
|
||||||
def setupSections(self):
|
def setupSections(self):
|
||||||
pykickstart.parser.KickstartParser.setupSections(self)
|
pykickstart.parser.KickstartParser.setupSections(self)
|
||||||
@ -134,6 +147,7 @@ class KickstartParser(pykickstart.parser.KickstartParser):
|
|||||||
self.registerSection(MultilibBlacklistSection(self.handler))
|
self.registerSection(MultilibBlacklistSection(self.handler))
|
||||||
self.registerSection(MultilibWhitelistSection(self.handler))
|
self.registerSection(MultilibWhitelistSection(self.handler))
|
||||||
self.registerSection(PrepopulateSection(self.handler))
|
self.registerSection(PrepopulateSection(self.handler))
|
||||||
|
self.registerSection(PackageWhitelistSection(self.handler))
|
||||||
|
|
||||||
def get_packages(self, dnf_obj):
|
def get_packages(self, dnf_obj):
|
||||||
packages = set()
|
packages = set()
|
||||||
@ -194,6 +208,7 @@ class PungiHandler(HandlerClass):
|
|||||||
self.multilib_blacklist = set()
|
self.multilib_blacklist = set()
|
||||||
self.multilib_whitelist = set()
|
self.multilib_whitelist = set()
|
||||||
self.prepopulate = set()
|
self.prepopulate = set()
|
||||||
|
self.package_whitelist = set()
|
||||||
|
|
||||||
|
|
||||||
def get_ksparser(ks_path=None):
|
def get_ksparser(ks_path=None):
|
||||||
|
@ -107,12 +107,17 @@ def write_pungi_config(compose, arch, variant, packages, groups, filter_packages
|
|||||||
'No packages included in %s.%s (no comps groups, no input packages, no prepopulate)'
|
'No packages included in %s.%s (no comps groups, no input packages, no prepopulate)'
|
||||||
% (variant.uid, arch))
|
% (variant.uid, arch))
|
||||||
|
|
||||||
|
package_whitelist = set()
|
||||||
|
if variant.pkgset:
|
||||||
|
for rpm_obj in variant.pkgset.rpms_by_arch.get(arch, []):
|
||||||
|
package_whitelist.add(rpm_obj.nevra)
|
||||||
|
|
||||||
pungi_wrapper.write_kickstart(
|
pungi_wrapper.write_kickstart(
|
||||||
ks_path=pungi_cfg, repos=repos, groups=groups, packages=packages_str,
|
ks_path=pungi_cfg, repos=repos, groups=groups, packages=packages_str,
|
||||||
exclude_packages=filter_packages_str,
|
exclude_packages=filter_packages_str,
|
||||||
lookaside_repos=lookaside_repos, fulltree_excludes=fulltree_excludes,
|
lookaside_repos=lookaside_repos, fulltree_excludes=fulltree_excludes,
|
||||||
multilib_whitelist=multilib_whitelist, multilib_blacklist=multilib_blacklist,
|
multilib_whitelist=multilib_whitelist, multilib_blacklist=multilib_blacklist,
|
||||||
prepopulate=prepopulate)
|
prepopulate=prepopulate, package_whitelist=package_whitelist)
|
||||||
|
|
||||||
|
|
||||||
def resolve_deps(compose, arch, variant, source_name=None):
|
def resolve_deps(compose, arch, variant, source_name=None):
|
||||||
|
@ -32,9 +32,22 @@ UNRESOLVED_DEPENDENCY_RE = re.compile(r"^.*Unresolvable dependency (.+) in ([^ ]
|
|||||||
MISSING_COMPS_PACKAGE_RE = re.compile(r"^.*Could not find a match for (.+) in any configured repo")
|
MISSING_COMPS_PACKAGE_RE = re.compile(r"^.*Could not find a match for (.+) in any configured repo")
|
||||||
|
|
||||||
|
|
||||||
|
def _write_ks_section(f, section, lines):
|
||||||
|
if lines:
|
||||||
|
f.write("\n%%%s\n" % section)
|
||||||
|
for i in sorted(lines):
|
||||||
|
f.write("%s\n" % i)
|
||||||
|
|
||||||
|
f.write("%end\n")
|
||||||
|
|
||||||
|
|
||||||
class PungiWrapper(object):
|
class PungiWrapper(object):
|
||||||
|
|
||||||
def write_kickstart(self, ks_path, repos, groups, packages, exclude_packages=None, comps_repo=None, lookaside_repos=None, fulltree_excludes=None, multilib_blacklist=None, multilib_whitelist=None, prepopulate=None):
|
def write_kickstart(self, ks_path, repos, groups, packages,
|
||||||
|
exclude_packages=None, comps_repo=None,
|
||||||
|
lookaside_repos=None, fulltree_excludes=None,
|
||||||
|
multilib_blacklist=None, multilib_whitelist=None,
|
||||||
|
prepopulate=None, package_whitelist=None):
|
||||||
groups = groups or []
|
groups = groups or []
|
||||||
exclude_packages = exclude_packages or {}
|
exclude_packages = exclude_packages or {}
|
||||||
lookaside_repos = lookaside_repos or {}
|
lookaside_repos = lookaside_repos or {}
|
||||||
@ -75,37 +88,11 @@ class PungiWrapper(object):
|
|||||||
|
|
||||||
kickstart.write("%end\n")
|
kickstart.write("%end\n")
|
||||||
|
|
||||||
# %fulltree-excludes
|
_write_ks_section(kickstart, "fulltree-excludes", fulltree_excludes)
|
||||||
if fulltree_excludes:
|
_write_ks_section(kickstart, "multilib-blacklist", multilib_blacklist)
|
||||||
kickstart.write("\n")
|
_write_ks_section(kickstart, "multilib-whitelist", multilib_whitelist)
|
||||||
kickstart.write("%fulltree-excludes\n")
|
_write_ks_section(kickstart, "prepopulate", prepopulate)
|
||||||
for i in sorted(fulltree_excludes):
|
_write_ks_section(kickstart, "package-whitelist", package_whitelist)
|
||||||
kickstart.write("%s\n" % i)
|
|
||||||
kickstart.write("%end\n")
|
|
||||||
|
|
||||||
# %multilib-blacklist
|
|
||||||
if multilib_blacklist:
|
|
||||||
kickstart.write("\n")
|
|
||||||
kickstart.write("%multilib-blacklist\n")
|
|
||||||
for i in sorted(multilib_blacklist):
|
|
||||||
kickstart.write("%s\n" % i)
|
|
||||||
kickstart.write("%end\n")
|
|
||||||
|
|
||||||
# %multilib-whitelist
|
|
||||||
if multilib_whitelist:
|
|
||||||
kickstart.write("\n")
|
|
||||||
kickstart.write("%multilib-whitelist\n")
|
|
||||||
for i in sorted(multilib_whitelist):
|
|
||||||
kickstart.write("%s\n" % i)
|
|
||||||
kickstart.write("%end\n")
|
|
||||||
|
|
||||||
# %prepopulate
|
|
||||||
if prepopulate:
|
|
||||||
kickstart.write("\n")
|
|
||||||
kickstart.write("%prepopulate\n")
|
|
||||||
for i in sorted(prepopulate):
|
|
||||||
kickstart.write("%s\n" % i)
|
|
||||||
kickstart.write("%end\n")
|
|
||||||
|
|
||||||
kickstart.close()
|
kickstart.close()
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ class MockVariant(mock.Mock):
|
|||||||
self.mmds = []
|
self.mmds = []
|
||||||
self.arch_mmds = {}
|
self.arch_mmds = {}
|
||||||
self.variants = {}
|
self.variants = {}
|
||||||
|
self.pkgset = mock.Mock(rpms_by_arch={})
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.uid
|
return self.uid
|
||||||
|
@ -39,7 +39,7 @@ class TestWritePungiConfig(helpers.PungiTestCase):
|
|||||||
groups=['grp1'], prepopulate=prepopulate,
|
groups=['grp1'], prepopulate=prepopulate,
|
||||||
repos={'pungi-repo': self.topdir + '/work/x86_64/repo'},
|
repos={'pungi-repo': self.topdir + '/work/x86_64/repo'},
|
||||||
exclude_packages=['pkg3', 'pkg4.x86_64'],
|
exclude_packages=['pkg3', 'pkg4.x86_64'],
|
||||||
fulltree_excludes=fulltree)
|
fulltree_excludes=fulltree, package_whitelist=set())
|
||||||
|
|
||||||
@mock.patch('pungi.phases.gather.get_lookaside_repos')
|
@mock.patch('pungi.phases.gather.get_lookaside_repos')
|
||||||
@mock.patch('pungi.phases.gather.methods.method_deps.PungiWrapper')
|
@mock.patch('pungi.phases.gather.methods.method_deps.PungiWrapper')
|
||||||
@ -54,10 +54,35 @@ class TestWritePungiConfig(helpers.PungiTestCase):
|
|||||||
multilib_whitelist=[], multilib_blacklist=[],
|
multilib_whitelist=[], multilib_blacklist=[],
|
||||||
groups=[], prepopulate=None,
|
groups=[], prepopulate=None,
|
||||||
repos={'pungi-repo': self.topdir + '/work/x86_64/repo'},
|
repos={'pungi-repo': self.topdir + '/work/x86_64/repo'},
|
||||||
exclude_packages=[], fulltree_excludes=None)
|
exclude_packages=[], fulltree_excludes=None,
|
||||||
|
package_whitelist=set())
|
||||||
self.assertEqual(glr.call_args_list,
|
self.assertEqual(glr.call_args_list,
|
||||||
[mock.call(self.compose, 'x86_64', self.compose.variants['Server'])])
|
[mock.call(self.compose, 'x86_64', self.compose.variants['Server'])])
|
||||||
|
|
||||||
|
@mock.patch('pungi.phases.gather.methods.method_deps.PungiWrapper')
|
||||||
|
def test_with_whitelist(self, PungiWrapper):
|
||||||
|
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')
|
||||||
|
]
|
||||||
|
white = mock.Mock()
|
||||||
|
black = mock.Mock()
|
||||||
|
prepopulate = mock.Mock()
|
||||||
|
fulltree = mock.Mock()
|
||||||
|
deps.write_pungi_config(self.compose, 'x86_64', self.compose.variants['Server'],
|
||||||
|
pkgs, grps, filter, white, black,
|
||||||
|
prepopulate=prepopulate, fulltree_excludes=fulltree)
|
||||||
|
self.assertWritten(PungiWrapper, packages=['pkg1', 'pkg2.x86_64'],
|
||||||
|
ks_path=self.topdir + '/work/x86_64/pungi/Server.x86_64.conf',
|
||||||
|
lookaside_repos={}, multilib_whitelist=white, multilib_blacklist=black,
|
||||||
|
groups=['grp1'], prepopulate=prepopulate,
|
||||||
|
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']))
|
||||||
|
|
||||||
@mock.patch('pungi.phases.gather.methods.method_deps.PungiWrapper')
|
@mock.patch('pungi.phases.gather.methods.method_deps.PungiWrapper')
|
||||||
def test_without_input(self, PungiWrapper):
|
def test_without_input(self, PungiWrapper):
|
||||||
with self.assertRaises(RuntimeError) as ctx:
|
with self.assertRaises(RuntimeError) as ctx:
|
||||||
|
Loading…
Reference in New Issue
Block a user