summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbner Silva <abner@collabora.co.uk>2013-10-18 12:46:39 -0300
committerEdward Hervey <edward@collabora.com>2013-12-10 09:55:01 -0500
commit9fbce782422dd30f2838b740a08ef63ce96d9764 (patch)
tree1d1587fe44b2a0a07eed5692b46e7d3a044e6057
parent9dd91894d2ca8f0af9f519cefca4c88e6443b184 (diff)
Add the manifest2cerbero script.
-rwxr-xr-xmanifest2cerbero.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/manifest2cerbero.py b/manifest2cerbero.py
new file mode 100755
index 0000000..72c4939
--- /dev/null
+++ b/manifest2cerbero.py
@@ -0,0 +1,44 @@
+#! /usr/bin/python
+
+# Script that converts manifest project revisions into cerbero commmit revisions.
+
+# Important: The script assumes that the cerbero config file has no
+# recipes_commits parameter originally set and will not replace in case it is set.
+
+import argparse, shutil
+import xml.etree.ElementTree as ET
+
+def main(**kwargs):
+ try:
+ print "Loading the manifest file."
+
+ # Parse the manifest file
+ tree = ET.parse(kwargs["manifest"])
+ root = tree.getroot()
+
+ output = {}
+
+ # Create a output dictionary based on the manifest
+ for atype in root.findall('project'):
+ print "Adding package: %s - revision: %s" % (atype.get('name'), atype.get('revision'))
+ output[atype.get('name')] = atype.get('revision')
+
+ # Copy the original cerbero config file to the output destination
+ shutil.copy2(kwargs['cerbero'], kwargs['output'])
+
+ # Append to the output file the dictionary
+ print "Writing the output file."
+ with open(kwargs['output'], "a") as outfile:
+ outfile.write("recipes_commits = %s" % output)
+ except:
+ print "ERROR: Cannot convert manifest into cerbero file. Check manifest file."
+
+if __name__ == '__main__':
+ parser = argparse.ArgumentParser(description='manifest2cerbero: Translate repo \
+ manifest project revisions in cerbero commmit revisions', version='%(prog)s 1.0')
+ parser.add_argument('manifest', type=str, help='Manifest file path')
+ parser.add_argument('cerbero', type=str, default='', help='Cerbero file path')
+ parser.add_argument('--output', type=str, default='', help='Cerbero output file')
+ args = parser.parse_args()
+
+ main(**vars(args))