diff options
author | Stephan Bergmann <stephan.bergmann@allotropia.de> | 2023-12-12 14:25:52 +0100 |
---|---|---|
committer | Stephan Bergmann <stephan.bergmann@allotropia.de> | 2023-12-13 08:24:41 +0100 |
commit | 5af8759dc7bd9219f0cfc01aaa0d83b323a581ae (patch) | |
tree | 41b1d48503661cb838d46e50b2abf5cd08c26271 /bin | |
parent | 038e82c20ce50ca4d9005a1f6bc948bb73222fc0 (diff) |
Split --with-update-config=... into many --with-online-update-mar-...=...
...and allow each of them to be left off, for debug purposes, even if that may
render the resulting --enable-online-update-mar feature non-functional.
This change tracked each item that was potentially read from the
--with-update-config ini file, and turned each of them into a new
--with-online-update-mar-... option. The only exception and remaining TODO is
bin/update/upload_build_config.py (called from Makefile.gbuild).
distro-configs/Jenkins/LibreOfficeLinuxUpdater.conf (which might well be dead)
set --with-update-config=~/updater.ini with an ini file of unknown content. So
that no items are silently missing if we ever resurrect that distro-config, I
set all of the new options to =TODO there for now.
Change-Id: I17a13e0d190a868436bac10c1b0a6675d8c704c0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160622
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
(cherry picked from commit e88bb8f6be937aeb951f1a64b4ff4e8c7e1280cc)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160636
Diffstat (limited to 'bin')
-rw-r--r-- | bin/update/config.py | 29 | ||||
-rwxr-xr-x | bin/update/create_build_config.py | 10 | ||||
-rwxr-xr-x | bin/update/create_full_mar.py | 19 | ||||
-rwxr-xr-x | bin/update/create_full_mar_for_languages.py | 15 | ||||
-rwxr-xr-x | bin/update/create_partial_update.py | 29 | ||||
-rwxr-xr-x | bin/update/get_update_channel.py | 25 | ||||
-rw-r--r-- | bin/update/signing.py | 4 | ||||
-rwxr-xr-x | bin/update/upload_builds.py | 7 |
8 files changed, 38 insertions, 100 deletions
diff --git a/bin/update/config.py b/bin/update/config.py deleted file mode 100644 index 25857bde2e9a..000000000000 --- a/bin/update/config.py +++ /dev/null @@ -1,29 +0,0 @@ -import configparser -import os - - -class Config(object): - - def __init__(self): - self.certificate_path = None - self.certificate_name = None - self.channel = None - self.base_url = None - self.upload_url = None - self.server_url = None - - -def parse_config(config_file): - config = configparser.ConfigParser() - config.read(os.path.expanduser(config_file)) - - data = Config() - updater_data = config['Updater'] - data.base_url = updater_data['base-url'] - data.certificate_name = updater_data['certificate-name'] - data.certificate_path = updater_data['certificate-path'] - data.channel = updater_data['channel'] - data.upload_url = updater_data['upload-url'] - data.server_url = updater_data["ServerURL"] - - return data diff --git a/bin/update/create_build_config.py b/bin/update/create_build_config.py index a8eb605997e6..de39b645ce8e 100755 --- a/bin/update/create_build_config.py +++ b/bin/update/create_build_config.py @@ -4,8 +4,6 @@ import json import sys import os -from config import parse_config - from tools import replace_variables_in_string @@ -29,15 +27,13 @@ def update_all_url_entries(data, **kwargs): def main(argv): if len(argv) < 7: - print("Usage: create_build_config.py $PRODUCTNAME $VERSION $BUILDID $PLATFORM $TARGETDIR $UPDATE_CONFIG") + print("Usage: create_build_config.py $PRODUCTNAME $VERSION $BUILDID $PLATFORM $TARGETDIR $CHANNEL") sys.exit(1) - config = parse_config(argv[6]) - data = {'productName': argv[1], 'version': argv[2], 'buildNumber': argv[3], - 'updateChannel': config.channel, + 'updateChannel': argv[6], 'platform': argv[4] } @@ -53,7 +49,7 @@ def main(argv): extra_data = json.load(f) data.update(extra_data) - update_all_url_entries(data, channel=config.channel, platform=argv[4], buildid=argv[3], version=argv[2]) + update_all_url_entries(data, channel=argv[6], platform=argv[4], buildid=argv[3], version=argv[2]) with open(os.path.join(argv[5], "build_config.json"), "w") as f: json.dump(data, f, indent=4) diff --git a/bin/update/create_full_mar.py b/bin/update/create_full_mar.py index 58fd7fbef170..c0d315920ec7 100755 --- a/bin/update/create_full_mar.py +++ b/bin/update/create_full_mar.py @@ -7,7 +7,6 @@ import json import argparse from tools import uncompress_file_to_dir, get_file_info, make_complete_mar_name -from config import parse_config from signing import sign_mar_file from path import UpdaterPath, convert_to_unix, convert_to_native @@ -19,26 +18,24 @@ def main(): parser.add_argument('product_name') parser.add_argument('workdir') parser.add_argument('filename_prefix') - parser.add_argument('update_config') + parser.add_argument('certificate_path') + parser.add_argument('certificate_name') + parser.add_argument('base_url') args = parser.parse_args() - update_config = args.update_config + certificate_path = args.certificate_path + certificate_name = args.certificate_name + base_url = args.base_url filename_prefix = args.filename_prefix workdir = args.workdir product_name = args.product_name - if len(update_config) == 0: - print("missing update config") - sys.exit(1) - update_path = UpdaterPath(workdir) update_path.ensure_dir_exist() target_dir = update_path.get_update_dir() temp_dir = update_path.get_current_build_dir() - config = parse_config(update_config) - tar_dir = os.path.join(update_path.get_workdir(), "installation", product_name, "archive", "install", "en-US") tar_file = os.path.join(tar_dir, os.listdir(tar_dir)[0]) @@ -48,9 +45,9 @@ def main(): path = os.path.join(current_dir_path, 'make_full_update.sh') subprocess.call([path, convert_to_native(mar_file), convert_to_native(uncompress_dir)]) - sign_mar_file(target_dir, config, mar_file, filename_prefix) + sign_mar_file(target_dir, certificate_path, certificate_name, mar_file, filename_prefix) - file_info = {'complete': get_file_info(mar_file, config.base_url)} + file_info = {'complete': get_file_info(mar_file, base_url)} with open(os.path.join(target_dir, 'complete_info.json'), "w") as complete_info_file: json.dump(file_info, complete_info_file, indent=4) diff --git a/bin/update/create_full_mar_for_languages.py b/bin/update/create_full_mar_for_languages.py index 610bbc061003..37d52e77b3ac 100755 --- a/bin/update/create_full_mar_for_languages.py +++ b/bin/update/create_full_mar_for_languages.py @@ -7,7 +7,6 @@ import json from tools import uncompress_file_to_dir, get_file_info -from config import parse_config from path import UpdaterPath from signing import sign_mar_file @@ -27,12 +26,14 @@ def create_lang_infos(mar_file_name, language, url): def main(): - if len(sys.argv) < 5: + if len(sys.argv) < 7: print( - "Usage: create_full_mar_for_languages.py $PRODUCTNAME $WORKDIR $TARGETDIR $TEMPDIR $FILENAMEPREFIX $UPDATE_CONFIG") + "Usage: create_full_mar_for_languages.py $PRODUCTNAME $WORKDIR $TARGETDIR $TEMPDIR $FILENAMEPREFIX $CERTIFICATEPATH $CERTIFICATENAME $BASEURL") sys.exit(1) - update_config = sys.argv[4] + certificate_path = sys.argv[4] + certificate_name = sys.argv[5] + base_url = sys.argv[6] filename_prefix = sys.argv[3] workdir = sys.argv[2] product_name = sys.argv[1] @@ -41,8 +42,6 @@ def main(): target_dir = updater_path.get_update_dir() temp_dir = updater_path.get_language_dir() - config = parse_config(update_config) - language_pack_dir = os.path.join(workdir, "installation", product_name + "_languagepack", "archive", "install") language_packs = os.listdir(language_pack_dir) lang_infos = [] @@ -59,9 +58,9 @@ def main(): subprocess.call([os.path.join(current_dir_path, 'make_full_update.sh'), mar_file_name, directory]) - sign_mar_file(target_dir, config, mar_file_name, filename_prefix) + sign_mar_file(target_dir, certificate_path, certificate_name, mar_file_name, filename_prefix) - lang_infos.append(create_lang_infos(mar_file_name, language, config.base_url)) + lang_infos.append(create_lang_infos(mar_file_name, language, base_url)) with open(os.path.join(target_dir, "complete_lang_info.json"), "w") as language_info_file: json.dump({'languages': lang_infos}, language_info_file, indent=4) diff --git a/bin/update/create_partial_update.py b/bin/update/create_partial_update.py index 83ac3a35fae5..2730c4765f14 100755 --- a/bin/update/create_partial_update.py +++ b/bin/update/create_partial_update.py @@ -6,7 +6,6 @@ import sys import requests -from config import parse_config from path import UpdaterPath, mkdir_p, convert_to_unix, convert_to_native from signing import sign_mar_file from tools import get_file_info, get_hash @@ -54,9 +53,9 @@ def handle_language(lang_entries, filedir): return langs -def download_mar_for_update_channel_and_platform(config, platform, temp_dir): - base_url = config.server_url + "update/partial-targets/1/" - url = base_url + platform + "/" + config.channel +def download_mar_for_update_channel_and_platform(server_url, channel, platform, temp_dir): + base_url = server_url + "update/partial-targets/1/" + url = base_url + platform + "/" + channel r = requests.get(url) if r.status_code != 200: print(r.content) @@ -110,9 +109,13 @@ def main(): updater_path.ensure_dir_exist() mar_name_prefix = sys.argv[2] - update_config = sys.argv[3] - platform = sys.argv[4] - build_id = sys.argv[5] + server_url = sys.argv[3] + channel = sys.argv[4] + certificate_path = sys.argv[5] + certificate_name = sys.argv[6] + base_url = sys.argv[7] + platform = sys.argv[8] + build_id = sys.argv[9] current_build_path = updater_path.get_current_build_dir() mar_dir = updater_path.get_mar_dir() @@ -123,9 +126,7 @@ def main(): if sys.platform == "cygwin": current_build_path = add_single_dir(current_build_path) - config = parse_config(update_config) - - updates = download_mar_for_update_channel_and_platform(config, platform, temp_dir) + updates = download_mar_for_update_channel_and_platform(server_url, channel, platform, temp_dir) data = {"partials": []} @@ -134,9 +135,9 @@ def main(): mar_file = os.path.join(update_dir, file_name) subprocess.call([os.path.join(current_dir_path, 'make_incremental_update.sh'), convert_to_native(mar_file), convert_to_native(update["complete"]), convert_to_native(current_build_path)]) - sign_mar_file(update_dir, config, mar_file, mar_name_prefix) + sign_mar_file(update_dir, certificate_path, certificate_name, mar_file, mar_name_prefix) - partial_info = {"file": get_file_info(mar_file, config.base_url), "from": build, "to": build_id, + partial_info = {"file": get_file_info(mar_file, base_url), "from": build, "to": build_id, "languages": {}} # on Windows we don't use language packs @@ -153,10 +154,10 @@ def main(): subprocess.call( [os.path.join(current_dir_path, 'make_incremental_update.sh'), convert_to_native(lang_mar_file), convert_to_native(lang_info), convert_to_native(language_dir)]) - sign_mar_file(update_dir, config, lang_mar_file, mar_name_prefix) + sign_mar_file(update_dir, certificate_path, certificate_name, lang_mar_file, mar_name_prefix) # add the partial language info - partial_info["languages"][lang] = get_file_info(lang_mar_file, config.base_url) + partial_info["languages"][lang] = get_file_info(lang_mar_file, base_url) data["partials"].append(partial_info) diff --git a/bin/update/get_update_channel.py b/bin/update/get_update_channel.py deleted file mode 100755 index 4215f8054b10..000000000000 --- a/bin/update/get_update_channel.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/python3 -# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# - -import sys -from config import parse_config - - -def main(): - if len(sys.argv) < 2: - sys.exit(1) - - update_config = sys.argv[1] - config = parse_config(update_config) - print(config.channel) - - -if __name__ == "__main__": - main() - -# vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bin/update/signing.py b/bin/update/signing.py index 65b482fe31aa..e8546dc83b9e 100644 --- a/bin/update/signing.py +++ b/bin/update/signing.py @@ -5,11 +5,11 @@ import subprocess import path -def sign_mar_file(target_dir, config, mar_file, filename_prefix): +def sign_mar_file(target_dir, certificate_path, certificate_name, mar_file, filename_prefix): signed_mar_file = make_complete_mar_name(target_dir, filename_prefix + '_signed') mar_executable = os.environ.get('MAR', 'mar') subprocess.check_call([mar_executable, '-C', path.convert_to_native(target_dir), '-d', - path.convert_to_native(config.certificate_path), '-n', config.certificate_name, '-s', + path.convert_to_native(certificate_path), '-n', certificate_name, '-s', path.convert_to_native(mar_file), path.convert_to_native(signed_mar_file)]) os.rename(signed_mar_file, mar_file) diff --git a/bin/update/upload_builds.py b/bin/update/upload_builds.py index 1be1b2fe837e..97a2f284848a 100755 --- a/bin/update/upload_builds.py +++ b/bin/update/upload_builds.py @@ -4,7 +4,6 @@ import sys import os import subprocess -from config import parse_config from path import convert_to_unix from tools import replace_variables_in_string @@ -15,10 +14,10 @@ def main(): buildid = sys.argv[2] platform = sys.argv[3] update_dir = sys.argv[4] - update_config = sys.argv[5] + upload_url_arg = sys.argv[5] + channel = sys.argv[6] - config = parse_config(update_config) - upload_url = replace_variables_in_string(config.upload_url, channel=config.channel, buildid=buildid, + upload_url = replace_variables_in_string(upload_url_arg, channel=channel, buildid=buildid, platform=platform) target_url, target_dir = upload_url.split(':') |