diff options
Diffstat (limited to 'scripts/update-release.py.in')
-rw-r--r-- | scripts/update-release.py.in | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/scripts/update-release.py.in b/scripts/update-release.py.in new file mode 100644 index 0000000..95350c9 --- /dev/null +++ b/scripts/update-release.py.in | |||
@@ -0,0 +1,62 @@ | |||
1 | @PYTHON@ | ||
2 | # vim: set ts=4 et: | ||
3 | |||
4 | import json | ||
5 | import os | ||
6 | import re | ||
7 | import sys | ||
8 | import yaml | ||
9 | |||
10 | if len(sys.argv) != 3: | ||
11 | sys.exit("Usage: " + os.path.basename(__file__) + " <profile> <build>") | ||
12 | |||
13 | PROFILE = sys.argv[1] | ||
14 | BUILD = sys.argv[2] | ||
15 | |||
16 | SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__)) | ||
17 | MANIFEST_JSON = os.path.join( | ||
18 | SCRIPT_DIR, 'profile', PROFILE, BUILD, 'manifest.json' | ||
19 | ) | ||
20 | |||
21 | RELEASE_DIR = os.path.join(SCRIPT_DIR, '..', 'releases') | ||
22 | RELEASE_YAML = os.path.join(RELEASE_DIR, PROFILE + '.yaml') | ||
23 | |||
24 | if not os.path.exists(RELEASE_DIR): | ||
25 | os.makedirs(RELEASE_DIR) | ||
26 | |||
27 | releases = {} | ||
28 | if os.path.exists(RELEASE_YAML): | ||
29 | with open(RELEASE_YAML, 'r') as data: | ||
30 | releases = yaml.safe_load(data) | ||
31 | |||
32 | with open(MANIFEST_JSON, 'r') as data: | ||
33 | MANIFEST = json.load(data) | ||
34 | |||
35 | A = re.split(':|,', MANIFEST['builds'][0]['artifact_id']) | ||
36 | ARTIFACTS = dict(zip(A[0::2], A[1::2])) | ||
37 | BUILD_TIME = MANIFEST['builds'][0]['build_time'] | ||
38 | DATA = MANIFEST['builds'][0]['custom_data'] | ||
39 | RELEASE = DATA['release'] | ||
40 | |||
41 | if BUILD not in releases: | ||
42 | releases[BUILD] = {} | ||
43 | if RELEASE not in releases[BUILD]: | ||
44 | releases[BUILD][RELEASE] = {} | ||
45 | |||
46 | REVISION = { | ||
47 | 'description': DATA['ami_desc'], | ||
48 | 'profile': PROFILE, | ||
49 | 'profile_build': BUILD, | ||
50 | 'version': DATA['version'], | ||
51 | 'release': RELEASE, | ||
52 | 'arch': DATA['arch'], | ||
53 | 'revision': DATA['revision'], | ||
54 | 'end_of_life': DATA['end_of_life'], | ||
55 | 'build_time': BUILD_TIME, | ||
56 | 'artifacts': ARTIFACTS | ||
57 | } | ||
58 | |||
59 | releases[BUILD][RELEASE][DATA['ami_name']] = REVISION | ||
60 | |||
61 | with open(RELEASE_YAML, 'w') as data: | ||
62 | yaml.dump(releases, data, sort_keys=False) | ||