2021-06-26 02:26:27 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
|
2021-08-23 21:30:28 +02:00
|
|
|
version=1.22.11
|
|
|
|
sha256=2c320de14a6014f62d29c34fec78fdbb0bc71c9ccba48ed0668de452c1f5fe6c
|
2021-06-26 02:26:27 +02:00
|
|
|
tarball="yarn-$version.tgz"
|
|
|
|
|
|
|
|
check_version() {
|
|
|
|
# Reading the version of Yarn from its package.json is much faster
|
|
|
|
# than running yarn --version.
|
|
|
|
link="$(command -v yarn)" \
|
|
|
|
&& bin="$(readlink -f "$link")" \
|
|
|
|
&& current_version="$(jq -r '.version' "${bin%/*/*}/package.json")" \
|
|
|
|
&& [ "$current_version" = "$version" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
if ! check_version; then
|
|
|
|
tmpdir="$(mktemp -d)"
|
|
|
|
trap 'rm -r "$tmpdir"' EXIT
|
|
|
|
cd "$tmpdir"
|
2021-07-13 21:00:50 +02:00
|
|
|
curl -fLO "https://registry.npmjs.org/yarn/-/$tarball"
|
2021-06-26 02:26:27 +02:00
|
|
|
sha256sum -c <<<"$sha256 $tarball"
|
|
|
|
rm -rf /srv/zulip-yarn
|
|
|
|
mkdir /srv/zulip-yarn
|
|
|
|
tar -xzf "$tarball" --no-same-owner --strip-components=1 -C /srv/zulip-yarn
|
|
|
|
ln -nsf /srv/zulip-yarn/bin/yarn /usr/bin/yarn
|
|
|
|
check_version
|
|
|
|
fi
|