forked from istio/istio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.sh
executable file
·75 lines (61 loc) · 2.34 KB
/
init.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
# Init script downloads or updates envoy and the go dependencies. Called from Makefile, which sets
# the needed environment variables.
ROOT=$(cd $(dirname $0)/..; pwd)
ISTIO_GO=$ROOT
set -o errexit
set -o nounset
set -o pipefail
# Set GOPATH to match the expected layout
GO_TOP=$(cd $(dirname $0)/../../../..; pwd)
OUT=${GO_TOP}/out
export GOPATH=${GOPATH:-$GO_TOP}
# Normally set by Makefile
export ISTIO_BIN=${ISTIO_BIN:-${GOPATH}/bin}
# Ensure expected GOPATH setup
if [ ${ROOT} != "${GO_TOP:-$HOME/go}/src/istio.io/istio" ]; then
echo "Istio not found in GOPATH/src/istio.io/"
exit 1
fi
DEP=${DEP:-$(which dep || echo "${ISTIO_BIN}/dep" )}
# Just in case init.sh is called directly, not from Makefile which has a dependency to dep
if [ ! -f ${DEP} ]; then
DEP=${ISTIO_BIN}/dep
unset GOOS && go get -u github.com/golang/dep/cmd/dep
fi
# Download dependencies if needed
if [ ! -d vendor/github.com ]; then
${DEP} ensure -vendor-only
cp Gopkg.lock vendor/Gopkg.lock
elif [ ! -f vendor/Gopkg.lock ]; then
${DEP} ensure -vendor-only
cp Gopkg.lock vendor/Gopkg.lock
else
diff Gopkg.lock vendor/Gopkg.lock > /dev/null || \
( ${DEP} ensure -vendor-only ; \
cp Gopkg.lock vendor/Gopkg.lock)
fi
# Original circleci - replaced with the version in the dockerfile, as we deprecate bazel
#ISTIO_PROXY_BUCKET=$(sed 's/ = /=/' <<< $( awk '/ISTIO_PROXY_BUCKET =/' WORKSPACE))
#PROXYVERSION=$(sed 's/[^"]*"\([^"]*\)".*/\1/' <<< $ISTIO_PROXY_BUCKET)
PROXYVERSION=$(grep envoy-debug pilot/docker/Dockerfile.proxy_debug |cut -d: -f2)
PROXY=debug-$PROXYVERSION
# Save envoy in vendor, which is cached
if [ ! -f vendor/envoy-$PROXYVERSION ] ; then
mkdir -p $OUT
pushd $OUT
# New version of envoy downloaded. Save it to cache, and clean any old version.
curl -Lo - https://storage.googleapis.com/istio-build/proxy/envoy-$PROXY.tar.gz | tar xz
cp usr/local/bin/envoy $ISTIO_GO/vendor/envoy-$PROXYVERSION
rm -f ${ISTIO_BIN}/envoy ${ROOT}/pilot/proxy/envoy/envoy
popd
fi
if [ ! -f $GO_TOP/bin/envoy ] ; then
mkdir -p $GO_TOP/bin
# Make sure the envoy binary exists.
cp $ISTIO_GO/vendor/envoy-$PROXYVERSION ${ISTIO_BIN}/envoy
fi
# Deprecated, may still be used in some tests
if [ ! -f ${ROOT}/pilot/proxy/envoy/envoy ] ; then
ln -sf ${ISTIO_BIN}/envoy ${ROOT}/pilot/proxy/envoy
fi