#!/usr/bin/env bash set -euo pipefail if [[ -z "${BABASHKA_STATIC:-}" ]]; then echo "BABASHKA_STATIC wasn't set, skipping musl installation." exit 0 fi if [[ -z "${BABASHKA_MUSL:-}" ]]; then echo "BABASHKA_MUSL wasn't set, skipping musl installation." exit 0 fi if [[ "${BABASHKA_ARCH:-"x86_64"}" != "x86_64" ]]; then echo "GraalVM only supports building static binaries on x86_64." exit 1 fi apt-get update -y && apt-get install musl-tools -y ZLIB_VERSION="1.2.12" ZLIB_SHA256="91844808532e5ce316b3c010929493c0244f3d37593afd6de04f71821d5136d9" curl -O -sL --fail --show-error "https://zlib.net/zlib-${ZLIB_VERSION}.tar.gz" echo "${ZLIB_SHA256} zlib-${ZLIB_VERSION}.tar.gz" | sha256sum --check tar xf "zlib-${ZLIB_VERSION}.tar.gz" arch=${BABASHKA_ARCH:-"x86_64"} echo "ARCH: $arch" cd "zlib-${ZLIB_VERSION}" CC=musl-gcc ./configure --static --prefix="/usr/local" make CC=musl-gcc make install cd .. # Install libz.a in the correct place so ldd can find it install -Dm644 "/usr/local/lib/libz.a" "/usr/lib/$arch-linux-musl/libz.a" ln -s /usr/bin/musl-gcc /usr/bin/x86_64-linux-musl-gcc