diff options
Diffstat (limited to 'src/lib/Bcfg2')
4 files changed, 15 insertions, 4 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/Apt.py b/src/lib/Bcfg2/Server/Plugins/Packages/Apt.py index f76bf7fa1..cbe2b4f2c 100644 --- a/src/lib/Bcfg2/Server/Plugins/Packages/Apt.py +++ b/src/lib/Bcfg2/Server/Plugins/Packages/Apt.py @@ -12,6 +12,7 @@ class AptCollection(Collection): class AptSource(Source): basegroups = ['apt', 'debian', 'ubuntu', 'nexenta'] ptype = 'deb' + essentialpkgs = set() def __init__(self, basepath, xsource, config): Source.__init__(self, basepath, xsource, config) @@ -50,10 +51,9 @@ class AptSource(Source): def read_files(self): bdeps = dict() bprov = dict() + depfnames = ['Depends', 'Pre-Depends'] if self.recommended: - depfnames = ['Depends', 'Pre-Depends', 'Recommends'] - else: - depfnames = ['Depends', 'Pre-Depends'] + depfnames.append('Recommends') for fname in self.files: if not self.rawurl: barch = [x @@ -77,6 +77,8 @@ class AptSource(Source): pkgname = words[1].strip().rstrip() self.pkgnames.add(pkgname) bdeps[barch][pkgname] = [] + elif words[0] == 'Essential' and self.essential: + self.essentialpkgs.add(pkgname) elif words[0] in depfnames: vindex = 0 for dep in words[1].split(','): diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/Collection.py b/src/lib/Bcfg2/Server/Plugins/Packages/Collection.py index 59c50fe8b..959dac03b 100644 --- a/src/lib/Bcfg2/Server/Plugins/Packages/Collection.py +++ b/src/lib/Bcfg2/Server/Plugins/Packages/Collection.py @@ -97,6 +97,12 @@ class Collection(Bcfg2.Server.Plugin.Debuggable): return source.get_deps(self.metadata, package) return [] + def get_essential(self): + essential = set() + for source in self.sources: + essential |= source.essentialpkgs + return essential + def get_provides(self, package): for source in self.sources: providers = source.get_provides(self.metadata, package) diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/Source.py b/src/lib/Bcfg2/Server/Plugins/Packages/Source.py index b33fde60a..5394a4bbd 100644 --- a/src/lib/Bcfg2/Server/Plugins/Packages/Source.py +++ b/src/lib/Bcfg2/Server/Plugins/Packages/Source.py @@ -54,6 +54,7 @@ class Source(Bcfg2.Server.Plugin.Debuggable): self.gpgkeys = [el.text for el in xsource.findall("GPGKey")] + self.essential = xsource.get('essential', 'true').lower() == 'true' self.recommended = xsource.get('recommended', 'false').lower() == 'true' self.rawurl = xsource.get('rawurl', '') diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/__init__.py b/src/lib/Bcfg2/Server/Plugins/Packages/__init__.py index 0d5e7d50f..e4793a28d 100644 --- a/src/lib/Bcfg2/Server/Plugins/Packages/__init__.py +++ b/src/lib/Bcfg2/Server/Plugins/Packages/__init__.py @@ -146,6 +146,8 @@ class Packages(Bcfg2.Server.Plugin.Plugin, initial = set() # base is the set of initial packages with groups expanded base = set() + # essential pkgs are those marked as such by the distribution + essential = collection.get_essential() to_remove = [] for struct in structures: for pkg in struct.xpath('//Package | //BoundPackage'): @@ -167,7 +169,7 @@ class Packages(Bcfg2.Server.Plugin.Plugin, else: self.logger.error("Packages: Malformed Package: %s" % lxml.etree.tostring(pkg)) - base.update(initial) + base.update(initial | essential) for el in to_remove: el.getparent().remove(el) |