summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnas Nashif <anas.nashif@intel.com>2012-11-09 15:37:04 -0800
committerAnas Nashif <anas.nashif@intel.com>2012-11-09 15:50:36 -0800
commitfcd55d4e82cc0988f9a8943defe85d20a1f5639d (patch)
tree801a1d616a6394c55679196d7040d395693510f7
parentf462271004233eae59f3af3b38dd771ed1679734 (diff)
downloadkickstarter-fcd55d4e82cc0988f9a8943defe85d20a1f5639d.tar.gz
kickstarter-fcd55d4e82cc0988f9a8943defe85d20a1f5639d.tar.bz2
kickstarter-fcd55d4e82cc0988f9a8943defe85d20a1f5639d.zip
support external configs via command line
check for external configs
-rw-r--r--demo/configurations.yaml1
-rw-r--r--kswriter/KSWriter.py15
-rwxr-xr-xtools/kickstarter11
3 files changed, 21 insertions, 6 deletions
diff --git a/demo/configurations.yaml b/demo/configurations.yaml
index b7d91ed..754028e 100644
--- a/demo/configurations.yaml
+++ b/demo/configurations.yaml
@@ -1,5 +1,4 @@
ExternalConfigs:
- - netbook
Default:
Active: True
diff --git a/kswriter/KSWriter.py b/kswriter/KSWriter.py
index a48dde8..c22f20d 100644
--- a/kswriter/KSWriter.py
+++ b/kswriter/KSWriter.py
@@ -18,11 +18,12 @@ def mkdir_p(path):
else: raise
class KSWriter():
- def __init__(self, configs=None, repos=None, outdir=".", config=None, packages=False):
+ def __init__(self, configs=None, repos=None, outdir=".", config=None, packages=False, external=[]):
self.dist = None
self.arch = None
self.image_filename = os.path.abspath(os.path.expanduser(configs))
self.outdir = outdir
+ self.external = external
self.packages = packages
self.config = config
self.image_stream = file(self.image_filename, 'r')
@@ -152,8 +153,18 @@ class KSWriter():
self.process_files(conf, self.repos)
else:
print "%s is inactive, not generating %s at this time" %(img['Name'], img['FileName'] )
- for path in self.image_meta['ExternalConfigs']:
+
+ external = []
+ if self.external:
+ external = external + self.external
+ if self.image_meta.has_key('ExternalConfigs') and self.image_meta['ExternalConfigs']:
+ external = external + self.image_meta['ExternalConfigs']
+
+ for path in external:
external_config_dir = os.path.join(os.path.dirname(self.image_filename), path)
+ if not os.path.exists(external_config_dir):
+ external_config_dir = os.path.abspath(os.path.expanduser(path))
+
for f in os.listdir(external_config_dir):
if f.endswith('.yaml'):
fp = file('%s/%s' %(external_config_dir, f), 'r')
diff --git a/tools/kickstarter b/tools/kickstarter
index 4ba10cb..5badc9c 100755
--- a/tools/kickstarter
+++ b/tools/kickstarter
@@ -62,7 +62,12 @@ def create_xml(image_meta):
if image_meta.has_key('Configurations'):
for img in image_meta['Configurations']:
image_xml(root,img)
- for path in image_meta['ExternalConfigs']:
+ external = []
+ if self.external:
+ external = external + self.external
+ if self.image_meta.has_key('ExternalConfigs') and self.image_meta['ExternalConfigs']:
+ external = external + self.image_meta['ExternalConfigs']
+ for path in external:
for f in os.listdir(path):
if f.endswith('.yaml'):
fp = file('%s/%s' %(path, f), 'r')
@@ -98,11 +103,11 @@ if __name__ == '__main__':
print "you need to provide meta files with --configs and --repos"
sys.exit(1)
- ks = KSWriter(options.configsfile, options.repofile, options.outdir, options.config, options.packages)
+ ks = KSWriter(options.configsfile, options.repofile, options.outdir, options.config, options.packages, options.external)
ks.generate()
if options.indexfile:
- str = create_xml(ks.image_meta)
+ str = create_xml(ks.image_meta, options.external)
f = open(options.indexfile, 'w')
f.write(str)
f.close()