-
Notifications
You must be signed in to change notification settings - Fork 18.6k
/
install-binaries.sh
executable file
·176 lines (148 loc) · 4.78 KB
/
install-binaries.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#!/usr/bin/env bash
set -e
set -x
. $(dirname "$0")/binaries-commits
RM_GOPATH=0
TMP_GOPATH=${TMP_GOPATH:-""}
if [ -z "$TMP_GOPATH" ]; then
export GOPATH="$(mktemp -d)"
RM_GOPATH=1
else
export GOPATH="$TMP_GOPATH"
fi
# Do not build with ambient capabilities support
RUNC_BUILDTAGS="${RUNC_BUILDTAGS:-"seccomp apparmor selinux"}"
install_runc() {
echo "Install runc version $RUNC_COMMIT"
git clone https://github.com/opencontainers/runc.git "$GOPATH/src/github.com/opencontainers/runc"
cd "$GOPATH/src/github.com/opencontainers/runc"
git checkout -q "$RUNC_COMMIT"
make BUILDTAGS="$RUNC_BUILDTAGS" $1
cp runc /usr/local/bin/docker-runc
}
install_containerd() {
echo "Install containerd version $CONTAINERD_COMMIT"
git clone https://github.com/containerd/containerd.git "$GOPATH/src/github.com/containerd/containerd"
cd "$GOPATH/src/github.com/containerd/containerd"
git checkout -q "$CONTAINERD_COMMIT"
(
export GOPATH
make
)
cp bin/containerd /usr/local/bin/docker-containerd
cp bin/containerd-shim /usr/local/bin/docker-containerd-shim
cp bin/ctr /usr/local/bin/docker-containerd-ctr
}
install_containerd_static() {
echo "Install containerd version $CONTAINERD_COMMIT"
git clone https://github.com/containerd/containerd.git "$GOPATH/src/github.com/containerd/containerd"
cd "$GOPATH/src/github.com/containerd/containerd"
git checkout -q "$CONTAINERD_COMMIT"
(
export GOPATH
make BUILDTAGS='static_build netgo' EXTRA_FLAGS="-buildmode pie" EXTRA_LDFLAGS='-extldflags "-fno-PIC -static"'
)
cp bin/containerd /usr/local/bin/docker-containerd
cp bin/containerd-shim /usr/local/bin/docker-containerd-shim
cp bin/ctr /usr/local/bin/docker-containerd-ctr
}
install_proxy() {
echo "Install docker-proxy version $LIBNETWORK_COMMIT"
git clone https://github.com/docker/libnetwork.git "$GOPATH/src/github.com/docker/libnetwork"
cd "$GOPATH/src/github.com/docker/libnetwork"
git checkout -q "$LIBNETWORK_COMMIT"
go build -buildmode=pie -ldflags="$PROXY_LDFLAGS" -o /usr/local/bin/docker-proxy github.com/docker/libnetwork/cmd/proxy
}
install_dockercli() {
DOCKERCLI_CHANNEL=${DOCKERCLI_CHANNEL:-edge}
DOCKERCLI_VERSION=${DOCKERCLI_VERSION:-17.06.0-ce}
echo "Install docker/cli version $DOCKERCLI_VERSION from $DOCKERCLI_CHANNEL"
arch=$(uname -m)
# No official release of these platforms
if [[ "$arch" != "x86_64" ]] && [[ "$arch" != "s390x" ]]; then
build_dockercli
return
fi
url=https://download.docker.com/linux/static
curl -Ls $url/$DOCKERCLI_CHANNEL/$arch/docker-$DOCKERCLI_VERSION.tgz | \
tar -xz docker/docker
mv docker/docker /usr/local/bin/
rmdir docker
}
build_dockercli() {
DOCKERCLI_VERSION=${DOCKERCLI_VERSION:-17.06.0-ce}
git clone https://github.com/docker/docker-ce "$GOPATH/tmp/docker-ce"
cd "$GOPATH/tmp/docker-ce"
git checkout -q "v$DOCKERCLI_VERSION"
mkdir -p "$GOPATH/src/github.com/docker"
mv components/cli "$GOPATH/src/github.com/docker/cli"
go build -buildmode=pie -o /usr/local/bin/docker github.com/docker/cli/cmd/docker
}
install_gometalinter() {
echo "Installing gometalinter version $GOMETALINTER_COMMIT"
go get -d github.com/alecthomas/gometalinter
cd "$GOPATH/src/github.com/alecthomas/gometalinter"
git checkout -q "$GOMETALINTER_COMMIT"
go build -buildmode=pie -o /usr/local/bin/gometalinter github.com/alecthomas/gometalinter
GOBIN=/usr/local/bin gometalinter --install
}
for prog in "$@"
do
case $prog in
tomlv)
echo "Install tomlv version $TOMLV_COMMIT"
git clone https://github.com/BurntSushi/toml.git "$GOPATH/src/github.com/BurntSushi/toml"
cd "$GOPATH/src/github.com/BurntSushi/toml" && git checkout -q "$TOMLV_COMMIT"
go build -buildmode=pie -v -o /usr/local/bin/tomlv github.com/BurntSushi/toml/cmd/tomlv
;;
runc)
install_runc static
;;
runc-dynamic)
install_runc
;;
containerd)
install_containerd_static
;;
containerd-dynamic)
install_containerd
;;
gometalinter)
install_gometalinter
;;
tini)
echo "Install tini version $TINI_COMMIT"
git clone https://github.com/krallin/tini.git "$GOPATH/tini"
cd "$GOPATH/tini"
git checkout -q "$TINI_COMMIT"
cmake .
make tini-static
cp tini-static /usr/local/bin/docker-init
;;
proxy)
(
export CGO_ENABLED=0
install_proxy
)
;;
proxy-dynamic)
PROXY_LDFLAGS="-linkmode=external" install_proxy
;;
vndr)
echo "Install vndr version $VNDR_COMMIT"
git clone https://github.com/LK4D4/vndr.git "$GOPATH/src/github.com/LK4D4/vndr"
cd "$GOPATH/src/github.com/LK4D4/vndr"
git checkout -q "$VNDR_COMMIT"
go build -buildmode=pie -v -o /usr/local/bin/vndr .
;;
dockercli)
install_dockercli
;;
*)
echo echo "Usage: $0 [tomlv|runc|runc-dynamic|containerd|containerd-dynamic|tini|proxy|proxy-dynamic|vndr|dockercli|gometalinter]"
exit 1
esac
done
if [ $RM_GOPATH -eq 1 ]; then
rm -rf "$GOPATH"
fi