2020-11-03 21:42:44 +00:00
|
|
|
#!/bin/bash
|
2020-09-04 20:54:23 +00:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
if [ "${DEBUG}" = 1 ]; then
|
|
|
|
set -x
|
|
|
|
fi
|
|
|
|
|
2020-11-17 20:21:12 +00:00
|
|
|
. ./scripts/version.sh
|
|
|
|
|
2021-12-02 20:51:57 +00:00
|
|
|
# Try to keep the K3s binary under 64 megabytes.
|
|
|
|
# "64M ought to be enough for anybody"
|
|
|
|
MAX_BINARY_MB=64
|
|
|
|
MAX_BINARY_SIZE=$((MAX_BINARY_MB * 1024 * 1024))
|
2020-11-03 21:42:44 +00:00
|
|
|
BIN_SUFFIX="-${ARCH}"
|
|
|
|
if [ ${ARCH} = amd64 ]; then
|
|
|
|
BIN_SUFFIX=""
|
|
|
|
elif [ ${ARCH} = arm ]; then
|
|
|
|
BIN_SUFFIX="-armhf"
|
2022-04-15 16:41:40 +00:00
|
|
|
elif [ ${ARCH} = s390x ]; then
|
|
|
|
BIN_SUFFIX="-s390x"
|
2020-11-03 21:42:44 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
CMD_NAME="dist/artifacts/k3s${BIN_SUFFIX}"
|
|
|
|
SIZE=$(stat -c '%s' ${CMD_NAME})
|
2020-09-04 20:54:23 +00:00
|
|
|
|
|
|
|
if [ ${SIZE} -gt ${MAX_BINARY_SIZE} ]; then
|
2021-12-02 20:51:57 +00:00
|
|
|
echo "k3s binary ${CMD_NAME} size ${SIZE} exceeds max acceptable size of ${MAX_BINARY_SIZE} bytes (${MAX_BINARY_MB} MiB)"
|
|
|
|
exit 1
|
2020-09-04 20:54:23 +00:00
|
|
|
fi
|
|
|
|
|
2021-12-02 20:51:57 +00:00
|
|
|
echo "k3s binary ${CMD_NAME} size ${SIZE} is less than max acceptable size of ${MAX_BINARY_SIZE} bytes (${MAX_BINARY_MB} MiB)"
|
2020-09-04 20:54:23 +00:00
|
|
|
exit 0
|