mirror of https://github.com/linkerd/linkerd2.git
42 lines
1.2 KiB
Bash
Executable File
42 lines
1.2 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# If the first argument to this script is "latest" or unset, it fetches the
|
|
# latest proxy binary from the linkerd2-proxy github releases. If it's set to
|
|
# a linkerd2-proxy version number (such as v2.76.0), it will fetch the binary
|
|
# matching that version number instead.
|
|
|
|
set -eu
|
|
|
|
bindir=$( cd "${0%/*}" && pwd )
|
|
rootdir=$( cd "$bindir"/.. && pwd )
|
|
builddir="$rootdir/target/proxy"
|
|
|
|
version=${1:-latest}
|
|
if [ "$version" = latest ]; then
|
|
version=$(curl -sL https://api.github.com/repos/linkerd/linkerd2-proxy/releases/latest |jq -r .tag_name | sed 's,^release/,,')
|
|
fi
|
|
|
|
assetbase="https://github.com/linkerd/linkerd2-proxy/releases/download/release%2F${version}"
|
|
pkgname="linkerd2-proxy-${version}"
|
|
pkgfile="${pkgname}.tar.gz"
|
|
shafile="${pkgname}.txt"
|
|
|
|
mkdir -p "$builddir"
|
|
cd "$builddir"
|
|
curl -sLO "$assetbase/$pkgfile"
|
|
curl -sLO "$assetbase/$shafile"
|
|
|
|
tar -zxvf "$pkgfile" >&2
|
|
expected=$(awk '{print $1}' "$shafile")
|
|
computed=$(sha256sum "$pkgfile" | awk '{print $1}')
|
|
if [ "$computed" != "$expected" ]; then
|
|
echo 'sha mismatch' >&2
|
|
exit 1
|
|
fi
|
|
|
|
mv "$pkgname/LICENSE" .
|
|
mv "$pkgname/bin/linkerd2-proxy" .
|
|
rm -r "$pkgfile" "$pkgname"
|
|
mv linkerd2-proxy "$pkgname"
|
|
echo "$builddir/$pkgname"
|