Update git submodules
[LibreOffice.git] / bin / update / create_build_config.py
blobde39b645ce8e1d08f11d40a79edd1fa75e4c50b4
1 #! /usr/bin/env python3
3 import json
4 import sys
5 import os
7 from tools import replace_variables_in_string
10 def update_all_url_entries(data, **kwargs):
11 data['complete']['url'] = replace_variables_in_string(data['complete']['url'], **kwargs)
13 if sys.platform != "cygwin":
14 for language in data['languages']:
15 language['complete']['url'] = replace_variables_in_string(language['complete']['url'], **kwargs)
17 if 'partials' in data:
18 for partial in data['partials']:
19 partial['file']['url'] = replace_variables_in_string(partial['file']['url'], **kwargs)
21 if sys.platform == "cygwin":
22 continue
24 for lang, lang_file in partial['languages'].items():
25 lang_file['url'] = replace_variables_in_string(lang_file['url'], **kwargs)
28 def main(argv):
29 if len(argv) < 7:
30 print("Usage: create_build_config.py $PRODUCTNAME $VERSION $BUILDID $PLATFORM $TARGETDIR $CHANNEL")
31 sys.exit(1)
33 data = {'productName': argv[1],
34 'version': argv[2],
35 'buildNumber': argv[3],
36 'updateChannel': argv[6],
37 'platform': argv[4]
40 extra_data_files = ['complete_info.json', 'partial_update_info.json']
41 if sys.platform != "cygwin":
42 extra_data_files.append('complete_lang_info.json')
44 for extra_file in extra_data_files:
45 extra_file_path = os.path.join(argv[5], extra_file)
46 if not os.path.exists(extra_file_path):
47 continue
48 with open(extra_file_path, "r") as f:
49 extra_data = json.load(f)
50 data.update(extra_data)
52 update_all_url_entries(data, channel=argv[6], platform=argv[4], buildid=argv[3], version=argv[2])
54 with open(os.path.join(argv[5], "build_config.json"), "w") as f:
55 json.dump(data, f, indent=4)
58 if __name__ == "__main__":
59 main(sys.argv)