summaryrefslogtreecommitdiff
path: root/manifest2cerbero.py
blob: b66f86fe0ac23a1c1b80a1f0b5aaeebe9b79f6be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#! /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
import sys

toconvert = [
    "gstreamer", "gst-plugins-base", "gst-plugins-good",
    "gst-plugins-bad", "gst-plugins-ugly", "gst-libav",
    "gst-editing-services", "gst-rtsp-server", "gst-plugins-gl"
]

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'):
            aname = atype.get('name')
            arev = atype.get('revision')
            print "Adding package: %s - revision: %s" % (aname, arev)
            if aname in toconvert:
                output["%s-1.0" % aname] = arev
                output["%s-1.0-static" % aname] = arev
            elif aname == "gst-devtools":
                output["gst-validate"] = arev
            else:
                output[aname] = arev

        print "output:", output
        print kwargs
        # 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("\nrecipes_commits = %s\n" % output)
    except:
        print "Unexpected error:", sys.exc_info()[0]
        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))