Implement %fulltree-excludes kickstart section to exclude packages from --fulltree processing.
This commit is contained in:
parent
17221a33f3
commit
854899344c
@ -15,8 +15,7 @@
|
|||||||
import os
|
import os
|
||||||
import pypungi
|
import pypungi
|
||||||
import pypungi.config
|
import pypungi.config
|
||||||
import pykickstart.parser
|
import pypungi.ks
|
||||||
import pykickstart.version
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@ -42,8 +41,7 @@ def main():
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
# Set up the kickstart parser and pass in the kickstart file we were handed
|
# Set up the kickstart parser and pass in the kickstart file we were handed
|
||||||
ksparser = pykickstart.parser.KickstartParser(pykickstart.version.makeVersion())
|
ksparser = pypungi.ks.get_ksparser(ks_path=opts.config)
|
||||||
ksparser.readKickstart(opts.config)
|
|
||||||
|
|
||||||
if opts.sourceisos:
|
if opts.sourceisos:
|
||||||
config.set('pungi', 'arch', 'source')
|
config.set('pungi', 'arch', 'source')
|
||||||
|
@ -223,6 +223,8 @@ class Pungi(pypungi.PungiBase):
|
|||||||
self.is_greedy = self.config.getboolean("pungi", "alldeps")
|
self.is_greedy = self.config.getboolean("pungi", "alldeps")
|
||||||
self.is_resolve_deps = True # TODO: implement --nodepsolve
|
self.is_resolve_deps = True # TODO: implement --nodepsolve
|
||||||
|
|
||||||
|
self.fulltree_excludes = set(self.ksparser.handler.fulltree_excludes)
|
||||||
|
|
||||||
def _add_yum_repo(self, name, url, mirrorlist=False, groups=True,
|
def _add_yum_repo(self, name, url, mirrorlist=False, groups=True,
|
||||||
cost=1000, includepkgs=None, excludepkgs=None,
|
cost=1000, includepkgs=None, excludepkgs=None,
|
||||||
proxy=None):
|
proxy=None):
|
||||||
@ -682,7 +684,7 @@ class Pungi(pypungi.PungiBase):
|
|||||||
packages_by_name.setdefault(po.name, []).append(po)
|
packages_by_name.setdefault(po.name, []).append(po)
|
||||||
|
|
||||||
for name, packages in packages_by_name.iteritems():
|
for name, packages in packages_by_name.iteritems():
|
||||||
packages = self.excludePackages(packages)
|
packages = self.excludePackages(packages or [])
|
||||||
if self.is_greedy:
|
if self.is_greedy:
|
||||||
packages = yum.packageSack.ListPackageSack(packages).returnNewestByNameArch()
|
packages = yum.packageSack.ListPackageSack(packages).returnNewestByNameArch()
|
||||||
else:
|
else:
|
||||||
@ -810,6 +812,7 @@ class Pungi(pypungi.PungiBase):
|
|||||||
for srpm_po in srpm_po_list:
|
for srpm_po in srpm_po_list:
|
||||||
if srpm_po in self.completed_fulltree:
|
if srpm_po in self.completed_fulltree:
|
||||||
continue
|
continue
|
||||||
|
if srpm_po.name not in self.fulltree_excludes:
|
||||||
srpms.append(srpm_po)
|
srpms.append(srpm_po)
|
||||||
self.completed_fulltree.add(srpm_po)
|
self.completed_fulltree.add(srpm_po)
|
||||||
|
|
||||||
|
56
src/pypungi/ks.py
Normal file
56
src/pypungi/ks.py
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
Kickstart syntax is extended with:
|
||||||
|
|
||||||
|
%fulltree-excludes
|
||||||
|
<srpm_name>
|
||||||
|
<srpm_name>
|
||||||
|
...
|
||||||
|
%end
|
||||||
|
|
||||||
|
Fulltree excludes allow us to define SRPM names
|
||||||
|
we don't want to be part of fulltree processing.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
import pykickstart.parser
|
||||||
|
import pykickstart.sections
|
||||||
|
|
||||||
|
|
||||||
|
class FulltreeExcludesSection(pykickstart.sections.Section):
|
||||||
|
sectionOpen = "%fulltree-excludes"
|
||||||
|
|
||||||
|
def handleLine(self, line):
|
||||||
|
if not self.handler:
|
||||||
|
return
|
||||||
|
|
||||||
|
(h, s, t) = line.partition('#')
|
||||||
|
line = h.rstrip()
|
||||||
|
|
||||||
|
self.handler.fulltree_excludes.add(line)
|
||||||
|
|
||||||
|
|
||||||
|
class KickstartParser(pykickstart.parser.KickstartParser):
|
||||||
|
def setupSections(self):
|
||||||
|
pykickstart.parser.KickstartParser.setupSections(self)
|
||||||
|
self.registerSection(FulltreeExcludesSection(self.handler))
|
||||||
|
|
||||||
|
|
||||||
|
HandlerClass = pykickstart.version.returnClassForVersion()
|
||||||
|
class PungiHandler(HandlerClass):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
HandlerClass.__init__(self, *args, **kwargs)
|
||||||
|
self.fulltree_excludes = set()
|
||||||
|
|
||||||
|
|
||||||
|
def get_ksparser(ks_path=None):
|
||||||
|
"""
|
||||||
|
Return a kickstart parser instance.
|
||||||
|
Read kickstart if ks_path provided.
|
||||||
|
"""
|
||||||
|
ksparser = KickstartParser(PungiHandler())
|
||||||
|
if ks_path:
|
||||||
|
ksparser.readKickstart(ks_path)
|
||||||
|
return ksparser
|
Loading…
Reference in New Issue
Block a user