2019-01-01 08:23:01 +00:00
|
|
|
#!/bin/bash
|
2019-01-09 16:54:15 +00:00
|
|
|
set -e -x
|
2019-01-01 08:23:01 +00:00
|
|
|
|
2019-01-24 17:51:14 +00:00
|
|
|
source $(dirname $0)/version.sh
|
2019-01-01 08:23:01 +00:00
|
|
|
|
|
|
|
cd $(dirname $0)/..
|
2019-07-10 03:54:13 +00:00
|
|
|
PKG="github.com/rancher/k3s"
|
|
|
|
PKG_CONTAINERD="github.com/containerd/containerd"
|
|
|
|
PKG_RANCHER_CONTAINERD="github.com/rancher/containerd"
|
|
|
|
PKG_CRICTL="github.com/kubernetes-sigs/cri-tools"
|
|
|
|
|
|
|
|
LDFLAGS="
|
|
|
|
-X $PKG/pkg/version.Version=$VERSION
|
|
|
|
-X $PKG/pkg/version.GitCommit=${COMMIT:0:8}
|
|
|
|
-X $PKG/vendor/$PKG_CONTAINERD/version.Version=$VERSION_CONTAINERD
|
|
|
|
-X $PKG/vendor/$PKG_CONTAINERD/version.Package=$PKG_RANCHER_CONTAINERD
|
|
|
|
-X $PKG/vendor/$PKG_CRICTL/pkg/version.Version=$VERSION_CRICTL
|
|
|
|
-w -s
|
|
|
|
"
|
2019-01-01 08:23:01 +00:00
|
|
|
|
2019-01-09 16:54:15 +00:00
|
|
|
STATIC="-extldflags '-static'"
|
2019-01-01 08:23:01 +00:00
|
|
|
STATIC_SQLITE="-extldflags '-static -lm -ldl -lz -lpthread'"
|
2019-01-09 16:54:15 +00:00
|
|
|
TAGS="ctrd apparmor seccomp no_btrfs netgo osusergo"
|
2019-01-01 08:23:01 +00:00
|
|
|
|
2019-01-09 16:54:15 +00:00
|
|
|
if [ "$STATIC_BUILD" != "true" ]; then
|
|
|
|
STATIC=""
|
|
|
|
STATIC_SQLITE=""
|
|
|
|
else
|
|
|
|
TAGS="static_build libsqlite3 $TAGS"
|
2019-01-01 08:23:01 +00:00
|
|
|
fi
|
|
|
|
|
2019-01-09 16:54:15 +00:00
|
|
|
mkdir -p bin
|
2019-01-01 08:23:01 +00:00
|
|
|
|
2019-02-08 04:08:10 +00:00
|
|
|
if [ -z "$GOARM" ] && [ "arm" = "$(go env GOARCH)" ]; then
|
|
|
|
GOARM=7
|
|
|
|
fi
|
|
|
|
|
2019-07-10 03:54:13 +00:00
|
|
|
rm -f \
|
|
|
|
bin/k3s-agent \
|
|
|
|
bin/hyperkube \
|
|
|
|
bin/containerd \
|
|
|
|
bin/cni \
|
|
|
|
bin/runc \
|
|
|
|
bin/containerd-shim \
|
|
|
|
bin/k3s-server \
|
|
|
|
bin/kubectl \
|
|
|
|
bin/crictl \
|
|
|
|
bin/ctr
|
|
|
|
|
2019-01-09 16:54:15 +00:00
|
|
|
# echo Building agent
|
|
|
|
# CGO_ENABLED=1 go build -tags "$TAGS" -ldflags "$LDFLAGS $STATIC" -o bin/k3s-agent ./cmd/agent/main.go
|
|
|
|
echo Building server
|
|
|
|
CGO_ENABLED=1 go build -tags "$TAGS" -ldflags "$LDFLAGS $STATIC_SQLITE" -o bin/containerd ./cmd/server/main.go
|
|
|
|
ln -s containerd ./bin/k3s-agent
|
|
|
|
ln -s containerd ./bin/k3s-server
|
|
|
|
ln -s containerd ./bin/kubectl
|
2019-02-08 04:08:10 +00:00
|
|
|
ln -s containerd ./bin/crictl
|
2019-06-30 16:30:25 +00:00
|
|
|
ln -s containerd ./bin/ctr
|
2019-01-09 16:54:15 +00:00
|
|
|
echo Building hyperkube
|
|
|
|
CGO_ENABLED=1 go build -tags "$TAGS" -ldflags "$LDFLAGS $STATIC_SQLITE" -o bin/hyperkube ./vendor/k8s.io/kubernetes/cmd/hyperkube/
|
2019-02-08 04:08:10 +00:00
|
|
|
#echo Building ctr
|
|
|
|
#CGO_ENABLED=1 go build -tags "$TAGS" -ldflags "$LDFLAGS $STATIC_SQLITE" -o bin/ctr ./cmd/ctr/main.go
|
2019-01-09 16:54:15 +00:00
|
|
|
# echo Building containerd
|
|
|
|
# CGO_ENABLED=0 go build -tags "$TAGS" -ldflags "$LDFLAGS $STATIC" -o bin/containerd ./cmd/containerd/
|
|
|
|
echo Building cni
|
|
|
|
CGO_ENABLED=0 go build -tags "$TAGS" -ldflags "$LDFLAGS $STATIC" -o bin/cni ./cmd/cni/main.go
|
|
|
|
echo Building runc
|
|
|
|
make EXTRA_LDFLAGS="-w -s" BUILDTAGS="apparmor seccomp" -C ./vendor/github.com/opencontainers/runc static
|
|
|
|
cp -f ./vendor/github.com/opencontainers/runc/runc ./bin/runc
|
|
|
|
echo Building containerd-shim
|
|
|
|
make -C ./vendor/github.com/containerd/containerd bin/containerd-shim
|
|
|
|
cp -f ./vendor/github.com/containerd/containerd/bin/containerd-shim ./bin/containerd-shim
|