2019-01-01 08:23:01 +00:00
|
|
|
#!/bin/bash
|
2019-01-09 16:54:15 +00:00
|
|
|
set -e -x
|
|
|
|
|
|
|
|
cd $(dirname $0)/..
|
|
|
|
|
2019-11-12 23:36:04 +00:00
|
|
|
. ./scripts/version.sh
|
|
|
|
|
2020-03-25 19:35:07 +00:00
|
|
|
GO=${GO-go}
|
|
|
|
|
2020-03-06 12:34:56 +00:00
|
|
|
for i in crictl kubectl k3s-agent k3s-server k3s; do
|
|
|
|
ln -fs containerd bin/$i
|
|
|
|
done
|
|
|
|
|
2019-01-09 16:54:15 +00:00
|
|
|
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
|
|
|
|
|
2019-11-12 14:12:37 +00:00
|
|
|
cp contrib/util/check-config.sh bin/check-config
|
2019-01-09 16:54:15 +00:00
|
|
|
|
2019-01-24 17:51:14 +00:00
|
|
|
rm -rf build/data
|
2019-02-05 04:42:35 +00:00
|
|
|
mkdir -p build/data build/out
|
|
|
|
mkdir -p dist/artifacts
|
2019-01-09 16:54:15 +00:00
|
|
|
|
2019-11-12 14:12:37 +00:00
|
|
|
(
|
|
|
|
set +x
|
|
|
|
cd bin
|
|
|
|
find . -not -path '*/\.*' -type f -exec sha256sum {} \; | sed -e 's| \./| |' | sort -k2 >.sha256sums
|
|
|
|
(
|
|
|
|
for f in $(find . -type l); do
|
|
|
|
echo $f $(readlink $f)
|
|
|
|
done
|
|
|
|
) | sed -e 's|^\./||' | sort >.links
|
|
|
|
set -x
|
|
|
|
)
|
|
|
|
|
2019-09-06 00:39:18 +00:00
|
|
|
tar cvzf ./build/out/data.tar.gz --exclude ./bin/hyperkube ./bin ./etc
|
2019-02-05 04:42:35 +00:00
|
|
|
HASH=$(sha256sum ./build/out/data.tar.gz | awk '{print $1}')
|
2019-01-09 16:54:15 +00:00
|
|
|
|
2019-02-05 04:42:35 +00:00
|
|
|
cp ./build/out/data.tar.gz ./build/data/${HASH}.tgz
|
2019-01-09 16:54:15 +00:00
|
|
|
|
2019-01-24 17:51:14 +00:00
|
|
|
BIN_SUFFIX="-${ARCH}"
|
2019-01-09 16:54:15 +00:00
|
|
|
if [ ${ARCH} = amd64 ]; then
|
2019-01-24 17:51:14 +00:00
|
|
|
BIN_SUFFIX=""
|
|
|
|
elif [ ${ARCH} = arm ]; then
|
|
|
|
BIN_SUFFIX="-armhf"
|
2019-01-09 16:54:15 +00:00
|
|
|
fi
|
2019-01-01 08:23:01 +00:00
|
|
|
|
2019-02-05 04:42:35 +00:00
|
|
|
CMD_NAME=dist/artifacts/k3s${BIN_SUFFIX}
|
2019-01-24 17:51:14 +00:00
|
|
|
|
2020-03-25 19:35:07 +00:00
|
|
|
"${GO}" generate
|
2019-07-10 03:54:13 +00:00
|
|
|
LDFLAGS="
|
|
|
|
-X github.com/rancher/k3s/pkg/version.Version=$VERSION
|
|
|
|
-X github.com/rancher/k3s/pkg/version.GitCommit=${COMMIT:0:8}
|
|
|
|
-w -s
|
|
|
|
"
|
2019-01-09 16:54:15 +00:00
|
|
|
STATIC="-extldflags '-static'"
|
2020-03-06 12:34:56 +00:00
|
|
|
if [ "$DQLITE" = 'true' ]; then
|
|
|
|
DQLITE_TAGS='dqlite'
|
2019-11-12 05:48:43 +00:00
|
|
|
fi
|
2020-03-25 19:35:07 +00:00
|
|
|
CGO_ENABLED=0 "${GO}" build -tags "$DQLITE_TAGS" -ldflags "$LDFLAGS $STATIC" -o ${CMD_NAME} ./cmd/k3s/main.go
|
2019-12-23 19:07:34 +00:00
|
|
|
|
|
|
|
./scripts/build-upload ${CMD_NAME} ${COMMIT}
|