import optparse
from time import gmtime, strftime
import errno
+#import elementtree.ElementTree as etree
+from lxml import etree
def mkdir_p(path):
try:
help="outdir")
parser.add_option("-r", "--repos", type="string", dest="repofile",
help="repo meta file")
+ parser.add_option("-i", "--index", type="string", dest="indexfile",
+ help="generate index file")
(options, args) = parser.parse_args()
+
+
if options.configsfile is None or options.repofile is None:
print "you need to provide meta files with --configs and --repos"
sys.exit(1)
ks = KSWriter(options.configsfile, options.repofile, outdir)
repo_meta = yaml.load(ks.repo_stream)
image_meta = yaml.load(ks.image_stream)
+
r = repo_meta['Repositories']
for img in image_meta['Configurations']:
conf = ks.parse(img)
ks.process_files(conf, r)
+ if options.indexfile:
+ """
+<?xml version="1.0"?>
+<image-configs>
+ <config>
+ <name>developer.ks</name>
+ <path>image-config/developer.ks</path>
+ <description>Default Developer Moblin Configuration for netbooks, nettops and generic hardware</description>
+ <md5>e8184823bce48f72679743c2c47136dd</md5>
+ </config>
+ <config>
+ <name>default.ks</name>
+ <path>image-config/default.ks</path>
+ <description>Default Moblin Configuration for netbooks, nettops and generic hardware</description>
+ <md5>3526567cb67748f46464d295eb660931</md5>
+ </config>
+</image-configs>
+ """
+ root = etree.Element("image-configs")
+ for img in image_meta['Configurations']:
+ s = etree.Element("config")
+ c = etree.Element('name')
+ c.text = "%s.ks" %img['FileName']
+ s.append(c)
+ cc = etree.Element('path')
+ cc.text = "configurations/%s.ks" %img['FileName']
+ s.append(cc)
+ cc = etree.Element('description')
+ cc.text = "%s" %img['Name']
+ s.append(cc)
+
+ cc = etree.Element('md5')
+ cc.text = ""
+ s.append(cc)
+
+ cc = etree.Element('daily')
+ if img.has_key('Daily') and img['Daily']:
+ cc.text = 'yes'
+ else:
+ cc.text = 'no'
+ s.append(cc)
+ root.append(s)
+ str = etree.tostring(root, pretty_print=True)
+ f = open(options.indexfile, 'w')
+ f.write(str)
+ f.close()
+ sys.exit(0)