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}
|
|
|
|
|
2023-05-02 23:14:35 +00:00
|
|
|
for i in containerd crictl kubectl k3s-agent k3s-server k3s-token k3s-etcd-snapshot k3s-secrets-encrypt k3s-certificate k3s-completion; do
|
2023-10-16 18:53:09 +00:00
|
|
|
rm -f bin/$i${BINARY_POSTFIX}
|
|
|
|
ln -s k3s${BINARY_POSTFIX} bin/$i${BINARY_POSTFIX}
|
2020-03-06 12:34:56 +00:00
|
|
|
done
|
|
|
|
|
2023-10-16 18:53:09 +00:00
|
|
|
cni_binaries=(
|
|
|
|
"bandwidth"
|
|
|
|
"bridge"
|
|
|
|
"firewall"
|
|
|
|
"flannel"
|
|
|
|
"host-local"
|
|
|
|
"loopback"
|
|
|
|
"portmap"
|
|
|
|
)
|
|
|
|
|
|
|
|
if [ ${OS} = windows ]; then
|
|
|
|
cni_binaries=(
|
|
|
|
"win-overlay"
|
|
|
|
"flannel"
|
|
|
|
"host-local"
|
|
|
|
)
|
|
|
|
fi
|
|
|
|
|
|
|
|
for i in "${cni_binaries[@]}"; do
|
|
|
|
rm -f bin/$i${BINARY_POSTFIX}
|
|
|
|
ln -s cni${BINARY_POSTFIX} bin/$i${BINARY_POSTFIX}
|
2019-01-09 16:54:15 +00:00
|
|
|
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
|
2023-10-16 18:53:09 +00:00
|
|
|
mkdir -p ./etc
|
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
|
|
|
|
)
|
|
|
|
|
2021-12-16 00:14:27 +00:00
|
|
|
tar cvf ./build/out/data.tar ./bin ./etc
|
2021-05-10 22:58:41 +00:00
|
|
|
zstd --no-progress -T0 -16 -f --long=25 --rm ./build/out/data.tar -o ./build/out/data.tar.zst
|
2021-02-06 07:16:58 +00:00
|
|
|
HASH=$(sha256sum ./build/out/data.tar.zst | awk '{print $1}')
|
2019-01-09 16:54:15 +00:00
|
|
|
|
2021-02-06 07:16:58 +00:00
|
|
|
cp ./build/out/data.tar.zst ./build/data/${HASH}.tar.zst
|
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"
|
2022-04-15 16:41:40 +00:00
|
|
|
elif [ ${ARCH} = s390x ]; then
|
|
|
|
BIN_SUFFIX="-s390x"
|
2019-01-09 16:54:15 +00:00
|
|
|
fi
|
2019-01-01 08:23:01 +00:00
|
|
|
|
2023-10-16 18:53:09 +00:00
|
|
|
CMD_NAME=dist/artifacts/k3s${BIN_SUFFIX}${BINARY_POSTFIX}
|
2019-01-24 17:51:14 +00:00
|
|
|
|
2023-10-16 18:53:09 +00:00
|
|
|
GOOS=linux CC=gcc CXX=g++ "${GO}" generate
|
2019-07-10 03:54:13 +00:00
|
|
|
LDFLAGS="
|
2022-03-02 23:47:27 +00:00
|
|
|
-X github.com/k3s-io/k3s/pkg/version.Version=$VERSION
|
|
|
|
-X github.com/k3s-io/k3s/pkg/version.GitCommit=${COMMIT:0:8}
|
2019-07-10 03:54:13 +00:00
|
|
|
-w -s
|
|
|
|
"
|
2022-05-13 20:09:57 +00:00
|
|
|
TAGS="urfave_cli_no_docs"
|
2019-01-09 16:54:15 +00:00
|
|
|
STATIC="-extldflags '-static'"
|
2023-10-16 18:53:09 +00:00
|
|
|
CGO_ENABLED=0 "${GO}" build -tags "$TAGS" -buildvcs=false -ldflags "$LDFLAGS $STATIC" -o ${CMD_NAME} ./cmd/k3s
|
2019-12-23 19:07:34 +00:00
|
|
|
|
2020-07-13 17:06:23 +00:00
|
|
|
stat ${CMD_NAME}
|
|
|
|
|
2019-12-23 19:07:34 +00:00
|
|
|
./scripts/build-upload ${CMD_NAME} ${COMMIT}
|