zulip/tools/setup/install-transifex-cli

42 lines
1.2 KiB
Bash
Executable File

#!/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.13
arch="$(uname -m)"
case $arch in
x86_64)
tarball="tx-linux-amd64.tar.gz"
sha256=edb411ccd23eff6d4966cac77a1a2f5f863092e723b226de3a5f230bc9cc06e1
;;
aarch64)
tarball="tx-linux-arm64.tar.gz"
sha256=1b1efaeb2b664666e80fb605b32b4e5e7bcdde4b3a15b7bccd7e1ba33da64484
;;
esac
check_version() {
out="$(tx --version)" && [ "$out" = "TX Client, version=${version}" ]
}
if ! check_version 2>/dev/null; then
set -x
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