Remove exec bits on .doc file
[LibreOffice.git] / bin / update / create_build_config.py
bloba8eb605997e65bcd8c982753b5cb14246e2352d2
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
12 def update_all_url_entries(data, **kwargs):
13 data['complete']['url'] = replace_variables_in_string(data['complete']['url'], **kwargs)
15 if sys.platform != "cygwin":
16 for language in data['languages']:
17 language['complete']['url'] = replace_variables_in_string(language['complete']['url'], **kwargs)
19 if 'partials' in data:
20 for partial in data['partials']:
21 partial['file']['url'] = replace_variables_in_string(partial['file']['url'], **kwargs)
23 if sys.platform == "cygwin":
24 continue
26 for lang, lang_file in partial['languages'].items():
27 lang_file['url'] = replace_variables_in_string(lang_file['url'], **kwargs)
30 def main(argv):
31 if len(argv) < 7:
32 print("Usage: create_build_config.py $PRODUCTNAME $VERSION $BUILDID $PLATFORM $TARGETDIR $UPDATE_CONFIG")
33 sys.exit(1)
35 config = parse_config(argv[6])
37 data = {'productName': argv[1],
38 'version': argv[2],
39 'buildNumber': argv[3],
40 'updateChannel': config.channel,
41 'platform': argv[4]
44 extra_data_files = ['complete_info.json', 'partial_update_info.json']
45 if sys.platform != "cygwin":
46 extra_data_files.append('complete_lang_info.json')
48 for extra_file in extra_data_files:
49 extra_file_path = os.path.join(argv[5], extra_file)
50 if not os.path.exists(extra_file_path):
51 continue
52 with open(extra_file_path, "r") as f:
53 extra_data = json.load(f)
54 data.update(extra_data)
56 update_all_url_entries(data, channel=config.channel, platform=argv[4], buildid=argv[3], version=argv[2])
58 with open(os.path.join(argv[5], "build_config.json"), "w") as f:
59 json.dump(data, f, indent=4)
62 if __name__ == "__main__":
63 main(sys.argv)