summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Plugins/Packages.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Server/Plugins/Packages.py')
-rw-r--r--src/lib/Server/Plugins/Packages.py35
1 files changed, 24 insertions, 11 deletions
diff --git a/src/lib/Server/Plugins/Packages.py b/src/lib/Server/Plugins/Packages.py
index 438c1d5c0..a84d8dc70 100644
--- a/src/lib/Server/Plugins/Packages.py
+++ b/src/lib/Server/Plugins/Packages.py
@@ -22,14 +22,17 @@ import Bcfg2.Server.Plugin
# build sources.list?
# caching for yum
+
class NoData(Exception):
pass
+
class SomeData(Exception):
pass
logger = logging.getLogger('Packages')
+
def source_from_xml(xsource):
ret = dict([('rawurl', False), ('url', False)])
for key, tag in [('groups', 'Group'), ('components', 'Component'),
@@ -60,6 +63,7 @@ def source_from_xml(xsource):
ret['url'] += '/'
return ret
+
def _fetch_url(url):
if '@' in url:
mobj = re.match('(\w+://)([^:]+):([^@]+)@(.*)$', url)
@@ -73,6 +77,7 @@ def _fetch_url(url):
urllib2.install_opener(urllib2.build_opener(auth))
return urllib2.urlopen(url).read()
+
class Source(object):
basegroups = []
@@ -135,7 +140,7 @@ class Source(object):
agroups = ['global'] + [a for a in self.arches if a in meta.groups]
vdict = dict()
for agrp in agroups:
- for key, value in self.provides[agrp].iteritems():
+ for key, value in list(self.provides[agrp].items()):
if key not in vdict:
vdict[key] = set(value)
else:
@@ -193,6 +198,7 @@ class Source(object):
return {'groups': copy.copy(self.groups), \
'urls': [copy.deepcopy(url) for url in self.url_map]}
+
class YUMSource(Source):
xp = '{http://linux.duke.edu/metadata/common}'
rp = '{http://linux.duke.edu/metadata/rpm}'
@@ -277,7 +283,7 @@ class YUMSource(Source):
fdata = lxml.etree.parse(fname).getroot()
self.parse_filelist(fdata, farch)
# merge data
- sdata = self.packages.values()
+ sdata = list(self.packages.values())
self.packages['global'] = copy.deepcopy(sdata.pop())
while sdata:
self.packages['global'] = self.packages['global'].intersection(sdata.pop())
@@ -337,10 +343,10 @@ class YUMSource(Source):
def get_vpkgs(self, metadata):
rv = Source.get_vpkgs(self, metadata)
- for arch, fmdata in self.filemap.iteritems():
+ for arch, fmdata in list(self.filemap.items()):
if arch not in metadata.groups and arch != 'global':
continue
- for filename, pkgs in fmdata.iteritems():
+ for filename, pkgs in list(fmdata.items()):
rv[filename] = pkgs
return rv
@@ -348,6 +354,7 @@ class YUMSource(Source):
filtered = set([u for u in unknown if u.startswith('rpmlib')])
unknown.difference_update(filtered)
+
class APTSource(Source):
basegroups = ['apt', 'debian', 'ubuntu', 'nexenta']
ptype = 'deb'
@@ -449,7 +456,7 @@ class APTSource(Source):
for barch in bdeps:
self.deps[barch][pkgname] = bdeps[barch][pkgname]
provided = set()
- for bprovided in bprov.values():
+ for bprovided in list(bprov.values()):
provided.update(set(bprovided))
for prov in provided:
prset = set()
@@ -469,6 +476,7 @@ class APTSource(Source):
pkg not in self.blacklist and \
(len(self.whitelist) == 0 or pkg in self.whitelist)
+
class PACSource(Source):
basegroups = ['arch', 'parabola']
ptype = 'pacman'
@@ -526,7 +534,7 @@ class PACSource(Source):
bdeps[barch] = dict()
bprov[barch] = dict()
try:
- print "try to read : " + fname
+ print("try to read : " + fname)
tar = tarfile.open(fname, "r")
reader = gzip.GzipFile(fname)
except:
@@ -536,7 +544,7 @@ class PACSource(Source):
for tarinfo in tar:
if tarinfo.isdir():
self.pkgnames.add(tarinfo.name.rsplit("-", 2)[0])
- print "added : " + tarinfo.name.rsplit("-", 2)[0]
+ print("added : " + tarinfo.name.rsplit("-", 2)[0])
tar.close()
self.deps['global'] = dict()
@@ -556,7 +564,7 @@ class PACSource(Source):
for barch in bdeps:
self.deps[barch][pkgname] = bdeps[barch][pkgname]
provided = set()
- for bprovided in bprov.values():
+ for bprovided in list(bprov.values()):
provided.update(set(bprovided))
for prov in provided:
prset = set()
@@ -576,6 +584,7 @@ class PACSource(Source):
pkg not in self.blacklist and \
(len(self.whitelist) == 0 or pkg in self.whitelist)
+
class Packages(Bcfg2.Server.Plugin.Plugin,
Bcfg2.Server.Plugin.StructureValidator,
Bcfg2.Server.Plugin.Generator,
@@ -614,7 +623,7 @@ class Packages(Bcfg2.Server.Plugin.Plugin,
vpkgs = dict()
for source in self.get_matching_sources(meta):
s_vpkgs = source.get_vpkgs(meta)
- for name, prov_set in s_vpkgs.iteritems():
+ for name, prov_set in list(s_vpkgs.items()):
if name not in vpkgs:
vpkgs[name] = set(prov_set)
else:
@@ -726,7 +735,9 @@ class Packages(Bcfg2.Server.Plugin.Plugin,
satisfied_vpkgs.add(current)
elif [item for item in vpkg_cache[current] if item in packages]:
if debug:
- self.logger.debug("Packages: requirement %s satisfied by %s" % (current, [item for item in vpkg_cache[current] if item in packages]))
+ self.logger.debug("Packages: requirement %s satisfied by %s" % (current,
+ [item for item in vpkg_cache[current]
+ if item in packages]))
satisfied_vpkgs.add(current)
vpkgs.difference_update(satisfied_vpkgs)
@@ -736,7 +747,9 @@ class Packages(Bcfg2.Server.Plugin.Plugin,
# allow use of virt through explicit specification, then fall back to forcing current on last pass
if [item for item in vpkg_cache[current] if item in packages]:
if debug:
- self.logger.debug("Packages: requirement %s satisfied by %s" % (current, [item for item in vpkg_cache[current] if item in packages]))
+ self.logger.debug("Packages: requirement %s satisfied by %s" % (current,
+ [item for item in vpkg_cache[current]
+ if item in packages]))
satisfied_both.add(current)
elif current in input_requirements or final_pass:
pkgs.add(current)