Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / bin / update / create_build_config.py
blob7cc8ac4be15eb1903c99edc783b20f924a1d4690
1 #! /usr/bin/env python3
3 import json
4 import sys
5 import os
7 from config import parse_config
9 from tools import replace_variables_in_string
11 def update_all_url_entries(data, **kwargs):
12 data['complete']['url'] = replace_variables_in_string(data['complete']['url'], **kwargs)
14 if sys.platform != "cygwin":
15 for language in data['languages']:
16 language['complete']['url'] = replace_variables_in_string(language['complete']['url'], **kwargs)
18 if 'partials' in data:
19 for partial in data['partials']:
20 partial['file']['url'] = replace_variables_in_string(partial['file']['url'], **kwargs)
22 if sys.platform == "cygwin":
23 continue
25 for lang, lang_file in partial['languages'].items():
26 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 $UPDATE_CONFIG")
31 sys.exit(1)
33 config = parse_config(argv[6])
35 data = { 'productName' : argv[1],
36 'version' : argv[2],
37 'buildNumber' : argv[3],
38 'updateChannel' : config.channel,
39 'platform' : argv[4]
42 extra_data_files = ['complete_info.json', 'partial_update_info.json']
43 if sys.platform != "cygwin":
44 extra_data_files.append('complete_lang_info.json')
46 for extra_file in extra_data_files:
47 extra_file_path = os.path.join(argv[5], extra_file)
48 if not os.path.exists(extra_file_path):
49 continue
50 with open(extra_file_path, "r") as f:
51 extra_data = json.load(f)
52 data.update(extra_data)
54 update_all_url_entries(data, channel=config.channel, platform=argv[4], buildid=argv[3], version=argv[2])
56 with open(os.path.join(argv[5], "build_config.json"), "w") as f:
57 json.dump(data, f, indent=4)
59 if __name__ == "__main__":
60 main(sys.argv)