|
|
|
#!/bin/bash
|
|
|
|
set -e -x
|
|
|
|
|
|
|
|
cd $(dirname $0)/..
|
|
|
|
|
|
|
|
. ./scripts/version.sh
|
|
|
|
|
|
|
|
GO=${GO-go}
|
|
|
|
|
|
|
|
for i in crictl kubectl k3s-agent k3s-server k3s-etcd-snapshot k3s; do
|
|
|
|
rm -f bin/$i
|
|
|
|
ln -s containerd bin/$i
|
|
|
|
done
|
|
|
|
|
|
|
|
for i in bridge flannel host-local loopback portmap; do
|
|
|
|
rm -f bin/$i
|
|
|
|
ln -s cni bin/$i
|
|
|
|
done
|
|
|
|
|
|
|
|
cp contrib/util/check-config.sh bin/check-config
|
|
|
|
|
|
|
|
rm -rf build/data
|
|
|
|
mkdir -p build/data build/out
|
|
|
|
mkdir -p dist/artifacts
|
|
|
|
|
|
|
|
(
|
|
|
|
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
|
|
|
|
)
|
|
|
|
|
|
|
|
tar cvf ./build/out/data.tar --exclude ./bin/hyperkube ./bin ./etc
|
|
|
|
zstd -v -T0 -16 -f --long=25 --rm ./build/out/data.tar -o ./build/out/data.tar.zst
|
|
|
|
HASH=$(sha256sum ./build/out/data.tar.zst | awk '{print $1}')
|
|
|
|
|
|
|
|
cp ./build/out/data.tar.zst ./build/data/${HASH}.tar.zst
|
|
|
|
|
|
|
|
BIN_SUFFIX="-${ARCH}"
|
|
|
|
if [ ${ARCH} = amd64 ]; then
|
|
|
|
BIN_SUFFIX=""
|
|
|
|
elif [ ${ARCH} = arm ]; then
|
|
|
|
BIN_SUFFIX="-armhf"
|
|
|
|
fi
|
|
|
|
|
|
|
|
CMD_NAME=dist/artifacts/k3s${BIN_SUFFIX}
|
|
|
|
|
|
|
|
"${GO}" generate
|
|
|
|
LDFLAGS="
|
|
|
|
-X github.com/rancher/k3s/pkg/version.Version=$VERSION
|
|
|
|
-X github.com/rancher/k3s/pkg/version.GitCommit=${COMMIT:0:8}
|
|
|
|
-w -s
|
|
|
|
"
|
|
|
|
STATIC="-extldflags '-static'"
|
|
|
|
CGO_ENABLED=0 "${GO}" build -ldflags "$LDFLAGS $STATIC" -o ${CMD_NAME} ./cmd/k3s/main.go
|
|
|
|
|
|
|
|
stat ${CMD_NAME}
|
|
|
|
|
|
|
|
./scripts/build-upload ${CMD_NAME} ${COMMIT}
|