k3s/scripts/package-cli
2019-01-25 22:09:46 -07:00

45 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
set -e -x
source $(dirname $0)/version.sh
cd $(dirname $0)/..
./scripts/download
rm -rf bin/kubectl bin/k3s-agent bin/k3s-server bin/kubectl bin/k3s build/data
ln -s containerd bin/k3s-agent
ln -s containerd bin/k3s-server
ln -s containerd bin/kubectl
for i in bridge flannel host-local loopback portmap; do
if [ -e ./bin/$i ]; then
rm -f ./bin/$i
fi
ln -s cni ./bin/$i
done
rm -rf build/data
mkdir -p build/data
mkdir -p dist
tar cvzf ./build/data.tar.gz --exclude ./bin/hyperkube ./bin
HASH=$(sha256sum ./build/data.tar.gz | awk '{print $1}')
cp ./build/data.tar.gz ./build/data/${HASH}.tgz
BIN_SUFFIX="-${ARCH}"
if [ ${ARCH} = amd64 ]; then
BIN_SUFFIX=""
elif [ ${ARCH} = arm ]; then
BIN_SUFFIX="-armhf"
fi
cp -f ./bin/hyperkube dist/hyperkube${BIN_SUFFIX}
CMD_NAME=dist/k3s${BIN_SUFFIX}
go generate
LDFLAGS="-X github.com/rancher/k3s/version.Version=$VERSION -w -s"
STATIC="-extldflags '-static'"
CGO_ENABLED=0 go build -ldflags "$LDFLAGS $STATIC" -o ${CMD_NAME} ./cmd/k3s/main.go