From 9fbce782422dd30f2838b740a08ef63ce96d9764 Mon Sep 17 00:00:00 2001 From: Abner Silva Date: Fri, 18 Oct 2013 12:46:39 -0300 Subject: Add the manifest2cerbero script. --- manifest2cerbero.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 manifest2cerbero.py 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)) -- cgit v1.2.3