forked from babashka/babashka
/
setup-musl
executable file
·43 lines (31 loc) · 1.13 KB
/
setup-musl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/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.11"
ZLIB_SHA256="c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1"
# stable archive path
curl -O -sL --fail --show-error "https://zlib.net/fossils/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