mirror of
https://github.com/xcat2/confluent.git
synced 2024-11-25 19:10:10 +00:00
Add '<' include syntax to syncfiles and pkglist
Provide means of combining multiple pkglist and syncfiles based on hierarchy. This enables construction of a more complex structure of images for those that may want it.
This commit is contained in:
parent
40dea6a747
commit
412e2aaf76
@ -32,6 +32,20 @@ def mkdirp(path):
|
||||
if e.errno != 17:
|
||||
raise
|
||||
|
||||
def get_entries(filename):
|
||||
with open(filename, 'r') as slfile:
|
||||
slist = slfile.read()
|
||||
entries = slist.split('\n')
|
||||
for ent in entries:
|
||||
ent = ent.split('#', 1)[0].strip()
|
||||
if not ent:
|
||||
continue
|
||||
if ent[0] == '<':
|
||||
for subent in get_entries(ent[1:]):
|
||||
yield subent
|
||||
else:
|
||||
yield subent
|
||||
|
||||
class SyncList(object):
|
||||
def __init__(self, filename, nodename, cfg):
|
||||
slist = None
|
||||
@ -40,9 +54,7 @@ class SyncList(object):
|
||||
self.appendoncemap = {}
|
||||
self.mergemap = {}
|
||||
self.optmap = {}
|
||||
with open(filename, 'r') as slfile:
|
||||
slist = slfile.read()
|
||||
entries = slist.split('\n')
|
||||
entries = get_entries(filename)
|
||||
currmap = self.replacemap
|
||||
for ent in entries:
|
||||
try:
|
||||
|
@ -409,10 +409,21 @@ class OsHandler(object):
|
||||
'version': odata[1], 'arch': odata[2], 'name': odata[3]}
|
||||
return json.dumps(info)
|
||||
|
||||
def list_packages(self):
|
||||
with open(self.pkglist, 'r') as pkglist:
|
||||
def list_packages(self, pkglistfile=None):
|
||||
if pkglistfile is None:
|
||||
pkglistfile = self.pkglist
|
||||
with open(pkglistfile, 'r') as pkglist:
|
||||
pkgs = pkglist.read()
|
||||
pkgs = pkgs.split()
|
||||
retpkgs = []
|
||||
for pkg in pkgs:
|
||||
pkg = pkg.split('#', 1)[0].strip()
|
||||
if not pkg:
|
||||
continue
|
||||
if pkg[0] == '<': # Include from specified file
|
||||
pkgs.extend(self.list_packages(pkg[1:]))
|
||||
else:
|
||||
pkgs.append(pkg)
|
||||
return pkgs
|
||||
|
||||
class SuseHandler(OsHandler):
|
||||
|
Loading…
Reference in New Issue
Block a user