From 0c44b933c8dad58bbe2054c0b3c3e9dc6b8feb21 Mon Sep 17 00:00:00 2001 From: Josh Klar Date: Wed, 7 Dec 2022 23:25:46 -0800 Subject: [PATCH] provision: Replace transifex-client with new transifex-cli. transifex-client went EOL on November 30, 2022, replaced by transifex/cli [^1]. Swap this in-place, since per the upstream README [^2]: > The current version of the client maintains backwards compatibility > for the tx push and tx pull commands. So, if you have a CI setup that > uses them, you should not have to change anything. As the mobile team found out, this is a partial truth if one previously used some of the more advanced CLI flags, but all workflows referenced in tools/ and docs/ use forwards-compatible flags to the new version. [^1]: https://github.com/transifex/transifex-client/ [^2]: https://github.com/transifex/cli/blob/a0f28a1cf3765edeec854e0825a269667dc03d83/README.md --- .tx/config | 27 +++++++++++++-------- tools/lib/provision.py | 4 +++- tools/setup/install-transifex-cli | 40 +++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 11 deletions(-) create mode 100755 tools/setup/install-transifex-cli diff --git a/.tx/config b/.tx/config index 6fd94503ce..db432f095f 100644 --- a/.tx/config +++ b/.tx/config @@ -1,32 +1,39 @@ +# Migrated from transifex-client format with `tx migrate` +# +# See https://developers.transifex.com/docs/using-the-client which hints at +# this format, but in general, the headings are in the format of: +# +# [o::p::r:] + [main] host = https://www.transifex.com lang_map = zh-Hans: zh_Hans, zh-Hant: zh_Hant -[zulip.djangopo] +[o:zulip:p:zulip:r:djangopo] file_filter = locale//LC_MESSAGES/django.po source_file = locale/en/LC_MESSAGES/django.po source_lang = en type = PO -[zulip.translationsjson] -file_filter = locale//translations.json -source_file = locale/en/translations.json -source_lang = en -type = KEYVALUEJSON - -[zulip.mobile] +[o:zulip:p:zulip:r:mobile] file_filter = locale//mobile.json source_file = locale/en/mobile.json source_lang = en type = KEYVALUEJSON -[zulip-test.djangopo] +[o:zulip:p:zulip:r:translationsjson] +file_filter = locale//translations.json +source_file = locale/en/translations.json +source_lang = en +type = KEYVALUEJSON + +[o:zulip:p:zulip-test:r:djangopo] file_filter = locale//LC_MESSAGES/django.po source_file = locale/en/LC_MESSAGES/django.po source_lang = en type = PO -[zulip-test.translationsjson] +[o:zulip:p:zulip-test:r:translationsjson] file_filter = locale//translations.json source_file = locale/en/translations.json source_lang = en diff --git a/tools/lib/provision.py b/tools/lib/provision.py index 2a911be3ed..5994bf8e29 100755 --- a/tools/lib/provision.py +++ b/tools/lib/provision.py @@ -109,7 +109,6 @@ COMMON_DEPENDENCIES = [ "ca-certificates", # Explicit dependency in case e.g. curl is already installed "puppet", # Used by lint (`puppet parser validate`) "gettext", # Used by makemessages i18n - "transifex-client", # Needed to sync translations from transifex "curl", # Used for testing our API documentation "moreutils", # Used for sponge command "unzip", # Needed for Slack import @@ -429,6 +428,9 @@ def main(options: argparse.Namespace) -> NoReturn: # Install shfmt. run_as_root(["tools/setup/install-shfmt"]) + # Install transifex-cli. + run_as_root([*proxy_env, "tools/setup/install-transifex-cli"]) + setup_venvs.main() run_as_root(["cp", REPO_STOPWORDS_PATH, TSEARCH_STOPWORDS_PATH]) diff --git a/tools/setup/install-transifex-cli b/tools/setup/install-transifex-cli new file mode 100755 index 0000000000..ed08914046 --- /dev/null +++ b/tools/setup/install-transifex-cli @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +# +# As of 07 December 2022, per https://pkgs.org/download/transifex-cli, only +# Void Linux and KaOS package the new Go-based Transifex CLI officially, so our +# safest bet is to pull the binaries from GitHub Releases directly for now. +# +# These binaries do not dynamically link to anything, and thus should work on +# glibc and musl (Alpine, Void, etc.) systems equally well. +set -euo pipefail + +version=1.6.4 +arch="$(uname -m)" + +case $arch in + x86_64) + tarball="tx-linux-amd64.tar.gz" + sha256=954207aba3da6139886922c8927c67098a51602c3d78558864f164a791c39e77 + ;; + + aarch64) + tarball="tx-linux-arm64.tar.gz" + sha256=2d0a115edef8e2fda6c1a431d28fe3541de073c35dc1ec677ffff0e6d1dd7a08 + ;; +esac + +check_version() { + out="$(tx --version)" && [ "$out" = "TX Client, version=${version}" ] +} + +if ! check_version 2>/dev/null; then + tmpdir="$(mktemp -d)" + trap 'rm -r "$tmpdir"' EXIT + cd "$tmpdir" + curl_opts=(-fLO --retry 3) + curl "${curl_opts[@]}" "https://github.com/transifex/cli/releases/download/v${version}/${tarball}" + sha256sum -c <<<"$sha256 $tarball" + tar -xzf "$tarball" --no-same-owner tx + install -Dm755 tx /usr/local/bin/tx + check_version +fi