2021-10-12 20:03:20 +00:00
|
|
|
#!/bin/sh -e
|
|
|
|
|
|
|
|
OS=$(uname -s)
|
|
|
|
ARCH=$(uname -m)
|
|
|
|
|
|
|
|
DIR=
|
|
|
|
|
|
|
|
if [ "${OS}" = "Linux" ]
|
|
|
|
then
|
2022-07-17 21:16:54 +00:00
|
|
|
if [ "${ARCH}" = "x86_64" -o "${ARCH}" = "amd64" ]
|
2021-10-12 20:03:20 +00:00
|
|
|
then
|
2022-12-19 19:00:21 +00:00
|
|
|
# Require at least x86-64 + SSE4.2 (introduced in 2006). On older hardware fall back to plain x86-64 (introduced in 1999) which
|
|
|
|
# guarantees at least SSE2. The caveat is that plain x86-64 builds are much less tested than SSE 4.2 builds.
|
2022-12-19 10:36:48 +00:00
|
|
|
HAS_SSE42=$(grep sse4_2 /proc/cpuinfo)
|
|
|
|
if [ "${HAS_SSE42}" ]
|
|
|
|
then
|
|
|
|
DIR="amd64"
|
|
|
|
else
|
2022-12-19 19:00:21 +00:00
|
|
|
DIR="amd64compat"
|
2022-12-19 10:36:48 +00:00
|
|
|
fi
|
2022-07-17 21:16:54 +00:00
|
|
|
elif [ "${ARCH}" = "aarch64" -o "${ARCH}" = "arm64" ]
|
2021-10-12 20:03:20 +00:00
|
|
|
then
|
2023-11-16 10:59:17 +00:00
|
|
|
# Dispatch between standard and compatibility builds, see cmake/cpu_features.cmake for details. Unfortunately, (1) the ARM ISA level
|
|
|
|
# cannot be read directly, we need to guess from the "features" in /proc/cpuinfo, and (2) the flags in /proc/cpuinfo are named
|
|
|
|
# differently than the flags passed to the compiler in cpu_features.cmake.
|
2022-12-19 10:36:48 +00:00
|
|
|
HAS_ARMV82=$(grep -m 1 'Features' /proc/cpuinfo | awk '/asimd/ && /sha1/ && /aes/ && /atomics/ && /lrcpc/')
|
|
|
|
if [ "${HAS_ARMV82}" ]
|
2022-09-26 13:22:53 +00:00
|
|
|
then
|
|
|
|
DIR="aarch64"
|
|
|
|
else
|
|
|
|
DIR="aarch64v80compat"
|
|
|
|
fi
|
2022-07-17 21:16:54 +00:00
|
|
|
elif [ "${ARCH}" = "powerpc64le" -o "${ARCH}" = "ppc64le" ]
|
2021-10-12 20:03:20 +00:00
|
|
|
then
|
|
|
|
DIR="powerpc64le"
|
2023-07-06 20:22:36 +00:00
|
|
|
elif [ "${ARCH}" = "riscv64" ]
|
|
|
|
then
|
|
|
|
DIR="riscv64"
|
2023-08-13 07:35:47 +00:00
|
|
|
elif [ "${ARCH}" = "s390x" ]
|
|
|
|
then
|
|
|
|
DIR="s390x"
|
2021-10-12 20:03:20 +00:00
|
|
|
fi
|
|
|
|
elif [ "${OS}" = "FreeBSD" ]
|
|
|
|
then
|
2022-07-17 21:16:54 +00:00
|
|
|
if [ "${ARCH}" = "x86_64" -o "${ARCH}" = "amd64" ]
|
2021-10-12 20:03:20 +00:00
|
|
|
then
|
|
|
|
DIR="freebsd"
|
|
|
|
fi
|
|
|
|
elif [ "${OS}" = "Darwin" ]
|
|
|
|
then
|
2022-07-17 21:16:54 +00:00
|
|
|
if [ "${ARCH}" = "x86_64" -o "${ARCH}" = "amd64" ]
|
2021-10-12 20:03:20 +00:00
|
|
|
then
|
|
|
|
DIR="macos"
|
2021-11-09 20:14:10 +00:00
|
|
|
elif [ "${ARCH}" = "aarch64" -o "${ARCH}" = "arm64" ]
|
2021-10-12 20:03:20 +00:00
|
|
|
then
|
|
|
|
DIR="macos-aarch64"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "${DIR}" ]
|
|
|
|
then
|
2022-09-26 11:40:09 +00:00
|
|
|
echo "Operating system '${OS}' / architecture '${ARCH}' is unsupported."
|
2021-10-12 20:03:20 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-12-11 05:57:04 +00:00
|
|
|
clickhouse_download_filename_prefix="clickhouse"
|
|
|
|
clickhouse="$clickhouse_download_filename_prefix"
|
2022-12-02 22:11:08 +00:00
|
|
|
|
2023-02-25 16:05:18 +00:00
|
|
|
if [ -f "$clickhouse" ]
|
|
|
|
then
|
|
|
|
read -p "ClickHouse binary ${clickhouse} already exists. Overwrite? [y/N] " answer
|
|
|
|
if [ "$answer" = "y" -o "$answer" = "Y" ]
|
|
|
|
then
|
|
|
|
rm -f "$clickhouse"
|
|
|
|
else
|
|
|
|
i=0
|
|
|
|
while [ -f "$clickhouse" ]
|
|
|
|
do
|
|
|
|
clickhouse="${clickhouse_download_filename_prefix}.${i}"
|
|
|
|
i=$(($i+1))
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
fi
|
2022-12-02 22:11:08 +00:00
|
|
|
|
2021-10-12 20:03:20 +00:00
|
|
|
URL="https://builds.clickhouse.com/master/${DIR}/clickhouse"
|
2021-10-17 02:52:00 +00:00
|
|
|
echo
|
2022-12-02 22:11:08 +00:00
|
|
|
echo "Will download ${URL} into ${clickhouse}"
|
2021-10-17 02:52:00 +00:00
|
|
|
echo
|
2022-12-02 22:11:08 +00:00
|
|
|
curl "${URL}" -o "${clickhouse}" && chmod a+x "${clickhouse}" || exit 1
|
2021-10-17 02:52:00 +00:00
|
|
|
echo
|
2021-10-12 20:03:20 +00:00
|
|
|
echo "Successfully downloaded the ClickHouse binary, you can run it as:
|
2022-12-02 22:11:08 +00:00
|
|
|
./${clickhouse}"
|
2021-10-12 20:03:20 +00:00
|
|
|
|
2023-03-02 22:04:10 +00:00
|
|
|
if [ "${OS}" = "Linux" ]
|
|
|
|
then
|
|
|
|
echo
|
|
|
|
echo "You can also install it:
|
|
|
|
sudo ./${clickhouse} install"
|
|
|
|
fi
|