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/bash
|
|
|
|
# If the first argument to this script is "latest" or unset, it fetches the
|
|
# latest proxy binary via build.l5d.io/linkerd2-proxy/latest.txt. If it's set to
|
|
# a commit sha from the master branch of the linkerd2-proxy repo, it will fetch
|
|
# the binary matching that sha instead.
|
|
|
|
set -eu
|
|
|
|
bindir="$( cd "$( dirname "${BASH_SOURCE[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"
|