summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Plugins/Packages/Collection.py
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2013-06-11 10:10:41 +0200
committerAlexander Sulfrian <alexander@sulfrian.net>2014-02-26 13:38:15 +0100
commitda1a7fa1c13d6c7a1d59f3239f1712e3a85a5ab4 (patch)
tree7421462f7587d9355e33aa617d581d9f3086fc6b /src/lib/Bcfg2/Server/Plugins/Packages/Collection.py
parente6e1f42847878c7abf0f4e454f84e510fe96f688 (diff)
downloadbcfg2-da1a7fa1c13d6c7a1d59f3239f1712e3a85a5ab4.tar.gz
bcfg2-da1a7fa1c13d6c7a1d59f3239f1712e3a85a5ab4.tar.bz2
bcfg2-da1a7fa1c13d6c7a1d59f3239f1712e3a85a5ab4.zip
Plugins/PkgVars: new plugin to set various vars per package
This plugins allows the setting of varius flags per package. It should be used f.e. to specify pinnings for debian packages or use flags and keywords for gentoo packages (needs to be implemented by future Portage plugin).
Diffstat (limited to 'src/lib/Bcfg2/Server/Plugins/Packages/Collection.py')
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Packages/Collection.py28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/Collection.py b/src/lib/Bcfg2/Server/Plugins/Packages/Collection.py
index c884b303e..2496d9aa1 100644
--- a/src/lib/Bcfg2/Server/Plugins/Packages/Collection.py
+++ b/src/lib/Bcfg2/Server/Plugins/Packages/Collection.py
@@ -308,7 +308,7 @@ class Collection(list, Bcfg2.Server.Plugin.Debuggable):
return any(source.is_virtual_package(self.metadata, package)
for source in self)
- def get_deps(self, package, recs=None):
+ def get_deps(self, package, recs=None, pinnings=None):
""" Get a list of the dependencies of the given package.
The base implementation simply aggregates the results of
@@ -316,16 +316,35 @@ class Collection(list, Bcfg2.Server.Plugin.Debuggable):
:param package: The name of the symbol, but see :ref:`pkg-objects`
:type package: string
+ :param pinnings: Mapping from package names to source names.
+ :type pinnings: dict
:returns: list of strings, but see :ref:`pkg-objects`
"""
recommended = None
if recs and package in recs:
recommended = recs[package]
+ pin_found = False
+ pin_source = None
+ if pinnings and package in pinnings:
+ pin_source = pinnings[package]
+
for source in self:
+ if pin_source and pin_source != source.name:
+ continue
+ pin_found = True
+
if source.is_package(self.metadata, package):
return source.get_deps(self.metadata, package, recommended)
+ if not pin_found:
+ if pin_source:
+ self.logger.error("Packages: Source '%s' for package '%s' not found" %
+ (pin_source, package))
+ else:
+ self.logger.error("Packages: No source found for package '%s'" %
+ package);
+
return []
def get_essential(self):
@@ -505,12 +524,15 @@ class Collection(list, Bcfg2.Server.Plugin.Debuggable):
return list(complete.difference(initial))
@Bcfg2.Server.Plugin.track_statistics()
- def complete(self, packagelist, recommended=None): # pylint: disable=R0912,R0914
+ def complete(self, packagelist, recommended=None,
+ pinnings=None): # pylint: disable=R0912,R0914
""" Build a complete list of all packages and their dependencies.
:param packagelist: Set of initial packages computed from the
specification.
:type packagelist: set of strings, but see :ref:`pkg-objects`
+ :param pinnings: Mapping from package names to source names.
+ :type pinnings: dict
:returns: tuple of sets - The first element contains a set of
strings (but see :ref:`pkg-objects`) describing the
complete package list, and the second element is a
@@ -569,7 +591,7 @@ class Collection(list, Bcfg2.Server.Plugin.Debuggable):
self.debug_log("Packages: handling package requirement %s" %
(current,))
packages.add(current)
- deps = self.get_deps(current, recommended)
+ deps = self.get_deps(current, recommended, pinnings)
newdeps = set(deps).difference(examined)
if newdeps:
self.debug_log("Packages: Package %s added requirements %s"