babashka/script/setup-musl
Thiago Kenji Okada 9ca3a3bd31
Use Debian bullseye on CI/CD/Dockerfile (#1005)
* Migrate `Dockerfile` to use a bullseye-based image

Also, some QoL changes on the `Dockerfile`:
- Parametrize GRAALVM_VERSION to make it easier to update
- Remove installing programs already included on base image
- Remove `deps.edn` from `.dockerignore` since it is necessary to build

* Migrate CircleCI to use a bullseye-based image

Also some modifications necessary to make it work:
- Migrate from `circleci` images to `clojure` since they're out-of-date
  and also seem to be considered legacy:
  https://circleci.com/docs/2.0/circleci-images/#legacy-language-images
- Remove unnecessary usage of `sudo`, since all commands runs as root
- Sync packages with `Dockerfile`. This will make easier to test locally
  if everything will work (of course, it is not 100% guarantee)

* Remove lsof

* Remove "Install {Clojure,Leiningen}" steps

Already included on the base image.

* Do not change directory when downloading GraalVM

* Move "Download GraalVM" to script/download-graalvm

* Set GRAALVM_HOME correctly

* Unbreak mac build

* Revert "Set GRAALVM_HOME correctly"

This reverts commit 5e2a6158dc.

* Set GRAALVM_HOME correctly, take 2

* Improve download-graalvm script

* Re-added "Install Clojure" steps

* Set amd64 as default GRAALVM_ARCH

* Unbreak linux-aarch64

* Ubreak jvm

* Do not change directory

* Fix yaml

* Fix mac/linux-aarch64

* Add missing Clojure

* Fix cache

* Move GraalVM installation to /tmp

* Use script/install-clojure

* Use /opt instead of /tmp to install GraalVM

* Revert "Use /opt instead of /tmp to install GraalVM"

This reverts commit 3cfad03c8e.

* Use CircleCI's Clojure images again

* Go back to installing GraalVM on $HOME
2021-09-13 23:28:13 +02:00

35 lines
881 B
Bash
Executable file

#!/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
apt-get update -y && apt-get install musl-tools -y
ZLIB_VERSION="1.2.11"
curl -O -sL "https://zlib.net/zlib-${ZLIB_VERSION}.tar.gz"
echo "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1 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"