Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / bin / update / create_full_mar_for_languages.py
blob610bbc061003593e2b2e3f5baca6b00b0278ce42
1 #!/usr/bin/env python3
3 import sys
4 import os
5 import subprocess
6 import json
8 from tools import uncompress_file_to_dir, get_file_info
10 from config import parse_config
11 from path import UpdaterPath
12 from signing import sign_mar_file
14 current_dir_path = os.path.dirname(os.path.realpath(__file__))
17 def make_complete_mar_name(target_dir, filename_prefix, language):
18 filename = filename_prefix + "_" + language + "_complete_langpack.mar"
19 return os.path.join(target_dir, filename)
22 def create_lang_infos(mar_file_name, language, url):
23 data = {'lang': language,
24 'complete': get_file_info(mar_file_name, url)
26 return data
29 def main():
30 if len(sys.argv) < 5:
31 print(
32 "Usage: create_full_mar_for_languages.py $PRODUCTNAME $WORKDIR $TARGETDIR $TEMPDIR $FILENAMEPREFIX $UPDATE_CONFIG")
33 sys.exit(1)
35 update_config = sys.argv[4]
36 filename_prefix = sys.argv[3]
37 workdir = sys.argv[2]
38 product_name = sys.argv[1]
40 updater_path = UpdaterPath(workdir)
41 target_dir = updater_path.get_update_dir()
42 temp_dir = updater_path.get_language_dir()
44 config = parse_config(update_config)
46 language_pack_dir = os.path.join(workdir, "installation", product_name + "_languagepack", "archive", "install")
47 language_packs = os.listdir(language_pack_dir)
48 lang_infos = []
49 for language in language_packs:
50 if language == 'log':
51 continue
53 language_dir = os.path.join(language_pack_dir, language)
54 language_file = os.path.join(language_dir, os.listdir(language_dir)[0])
56 directory = uncompress_file_to_dir(language_file, os.path.join(temp_dir, language))
58 mar_file_name = make_complete_mar_name(target_dir, filename_prefix, language)
60 subprocess.call([os.path.join(current_dir_path, 'make_full_update.sh'), mar_file_name, directory])
62 sign_mar_file(target_dir, config, mar_file_name, filename_prefix)
64 lang_infos.append(create_lang_infos(mar_file_name, language, config.base_url))
66 with open(os.path.join(target_dir, "complete_lang_info.json"), "w") as language_info_file:
67 json.dump({'languages': lang_infos}, language_info_file, indent=4)
70 if __name__ == '__main__':
71 main()