Dev setup - check if Zig/jemalloc are already installed before downloading (#2899)

* Check if Zig/jemalloc are already installed before downloading

* reformat
pull/2908/head
OBarronCS 8 months ago committed by GitHub
parent a0a626bfdb
commit 18755282e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -92,21 +92,26 @@ download_zig_binary() {
# Install zig to current directory # Install zig to current directory
# We use zig to compile some test binaries as it is much easier than with gcc # We use zig to compile some test binaries as it is much easier than with gcc
ZIG_TAR_URL="https://ziglang.org/download/0.10.1/zig-linux-x86_64-0.10.1.tar.xz" if command -v "${ZIGPATH}"/zig &> /dev/null; then
ZIG_TAR_SHA256="6699f0e7293081b42428f32c9d9c983854094bd15fee5489f12c4cf4518cc380" echo "Zig is already installed. Skipping build and install."
curl --output /tmp/zig.tar.xz "${ZIG_TAR_URL}" else
ACTUAL_SHA256=$(sha256sum /tmp/zig.tar.xz | cut -d' ' -f1) echo "Downloading and installing Zig..."
if [ "${ACTUAL_SHA256}" != "${ZIG_TAR_SHA256}" ]; then ZIG_TAR_URL="https://ziglang.org/download/0.10.1/zig-linux-x86_64-0.10.1.tar.xz"
echo "Zig binary checksum mismatch" ZIG_TAR_SHA256="6699f0e7293081b42428f32c9d9c983854094bd15fee5489f12c4cf4518cc380"
echo "Expected: ${ZIG_TAR_SHA256}" curl --output /tmp/zig.tar.xz "${ZIG_TAR_URL}"
echo "Actual: ${ACTUAL_SHA256}" ACTUAL_SHA256=$(sha256sum /tmp/zig.tar.xz | cut -d' ' -f1)
exit 1 if [ "${ACTUAL_SHA256}" != "${ZIG_TAR_SHA256}" ]; then
fi echo "Zig binary checksum mismatch"
echo "Expected: ${ZIG_TAR_SHA256}"
echo "Actual: ${ACTUAL_SHA256}"
exit 1
fi
tar -C /tmp -xJf /tmp/zig.tar.xz tar -C /tmp -xJf /tmp/zig.tar.xz
mv /tmp/zig-linux-x86_64-* ${ZIGPATH} &> /dev/null || true mv /tmp/zig-linux-x86_64-* ${ZIGPATH} &> /dev/null || true
echo "Zig installed to ${ZIGPATH}" echo "Zig installed to ${ZIGPATH}"
fi
} }
install_apt() { install_apt() {
@ -221,61 +226,62 @@ install_dnf() {
install_jemalloc() { install_jemalloc() {
# Install jemalloc version 5.3.0 # Check if jemalloc is already installed
JEMALLOC_TAR_URL="https://github.com/jemalloc/jemalloc/releases/download/5.3.0/jemalloc-5.3.0.tar.bz2" if command -v jemalloc-config &> /dev/null; then
JEMALLOC_TAR_SHA256="2db82d1e7119df3e71b7640219b6dfe84789bc0537983c3b7ac4f7189aecfeaa" echo "Jemalloc already installed. Skipping build and install."
JEMALLOC_TAR_PATH="/tmp/jemalloc-5.3.0.tar.bz2" else
JEMALLOC_EXTRACT_PATH="/tmp/jemalloc-5.3.0" echo "Jemalloc not found in system. Downloading, configuring, building, and installing..."
# Check if jemalloc tarball already exists and has the correct checksum # Install jemalloc version 5.3.0
if [ -f "${JEMALLOC_TAR_PATH}" ]; then JEMALLOC_TAR_URL="https://github.com/jemalloc/jemalloc/releases/download/5.3.0/jemalloc-5.3.0.tar.bz2"
ACTUAL_SHA256=$(sha256sum "${JEMALLOC_TAR_PATH}" | cut -d' ' -f1) JEMALLOC_TAR_SHA256="2db82d1e7119df3e71b7640219b6dfe84789bc0537983c3b7ac4f7189aecfeaa"
if [ "${ACTUAL_SHA256}" != "${JEMALLOC_TAR_SHA256}" ]; then JEMALLOC_TAR_PATH="/tmp/jemalloc-5.3.0.tar.bz2"
echo "Jemalloc tarball exists but has incorrect checksum. Re-downloading..." JEMALLOC_EXTRACT_PATH="/tmp/jemalloc-5.3.0"
# Check if jemalloc tarball already exists and has the correct checksum
if [ -f "${JEMALLOC_TAR_PATH}" ]; then
ACTUAL_SHA256=$(sha256sum "${JEMALLOC_TAR_PATH}" | cut -d' ' -f1)
if [ "${ACTUAL_SHA256}" != "${JEMALLOC_TAR_SHA256}" ]; then
echo "Jemalloc tarball exists but has incorrect checksum. Re-downloading..."
curl --location --output "${JEMALLOC_TAR_PATH}" "${JEMALLOC_TAR_URL}"
ACTUAL_SHA256=$(sha256sum "${JEMALLOC_TAR_PATH}" | cut -d' ' -f1)
if [ "${ACTUAL_SHA256}" != "${JEMALLOC_TAR_SHA256}" ]; then
echo "Jemalloc binary checksum mismatch after re-download."
echo "Expected: ${JEMALLOC_TAR_SHA256}"
echo "Actual: ${ACTUAL_SHA256}"
exit 1
fi
else
echo "Jemalloc tarball already exists and has correct checksum. Skipping download."
fi
else
echo "Downloading jemalloc..."
curl --location --output "${JEMALLOC_TAR_PATH}" "${JEMALLOC_TAR_URL}" curl --location --output "${JEMALLOC_TAR_PATH}" "${JEMALLOC_TAR_URL}"
ACTUAL_SHA256=$(sha256sum "${JEMALLOC_TAR_PATH}" | cut -d' ' -f1) ACTUAL_SHA256=$(sha256sum "${JEMALLOC_TAR_PATH}" | cut -d' ' -f1)
if [ "${ACTUAL_SHA256}" != "${JEMALLOC_TAR_SHA256}" ]; then if [ "${ACTUAL_SHA256}" != "${JEMALLOC_TAR_SHA256}" ]; then
echo "Jemalloc binary checksum mismatch after re-download." echo "Jemalloc binary checksum mismatch"
echo "Expected: ${JEMALLOC_TAR_SHA256}" echo "Expected: ${JEMALLOC_TAR_SHA256}"
echo "Actual: ${ACTUAL_SHA256}" echo "Actual: ${ACTUAL_SHA256}"
exit 1 exit 1
fi fi
else
echo "Jemalloc tarball already exists and has correct checksum. Skipping download."
fi
else
echo "Downloading jemalloc..."
curl --location --output "${JEMALLOC_TAR_PATH}" "${JEMALLOC_TAR_URL}"
ACTUAL_SHA256=$(sha256sum "${JEMALLOC_TAR_PATH}" | cut -d' ' -f1)
if [ "${ACTUAL_SHA256}" != "${JEMALLOC_TAR_SHA256}" ]; then
echo "Jemalloc binary checksum mismatch"
echo "Expected: ${JEMALLOC_TAR_SHA256}"
echo "Actual: ${ACTUAL_SHA256}"
exit 1
fi fi
fi
# Check if jemalloc source code has already been extracted # Check if jemalloc source code has already been extracted
if [ -d "${JEMALLOC_EXTRACT_PATH}" ]; then if [ -d "${JEMALLOC_EXTRACT_PATH}" ]; then
echo "Jemalloc source code already extracted. Skipping extraction." echo "Jemalloc source code already extracted. Skipping extraction."
else else
echo "Extracting jemalloc..." echo "Extracting jemalloc..."
tar -C /tmp -xf "${JEMALLOC_TAR_PATH}" tar -C /tmp -xf "${JEMALLOC_TAR_PATH}"
fi fi
# Check if jemalloc is already installed
if ! command -v jemalloc-config &> /dev/null; then
echo "Jemalloc not found in system. Configuring, building, and installing..."
pushd "${JEMALLOC_EXTRACT_PATH}" pushd "${JEMALLOC_EXTRACT_PATH}"
./configure ./configure
make make
sudo make install sudo make install
popd popd
else
echo "Jemalloc already installed. Skipping build and install."
fi
echo "Jemalloc installation complete." echo "Jemalloc installation complete."
fi
# TODO: autoconf needs to be installed with script as well? # TODO: autoconf needs to be installed with script as well?
} }
@ -323,7 +329,7 @@ if linux; then
. /etc/os-release . /etc/os-release
echo ${VERSION_ID} version echo ${VERSION_ID} version
) )
install_dnf $fedora_verion install_dnf $fedora_version
;; ;;
*) # we can add more install command for each distros. *) # we can add more install command for each distros.
echo "\"$distro\" is not supported distro. Will search for 'apt' or 'pacman' package managers." echo "\"$distro\" is not supported distro. Will search for 'apt' or 'pacman' package managers."

Loading…
Cancel
Save