#!/usr/bin/env bash # Runs a command in this app's arm64 opam switch (.cache/opam-arm64) inside # the emulated Debian arm64 root, creating the switch on first use. The # compiler is the root's Debian OCaml 5.3.0, used as ocaml-system; every # library, SQLite included, is compiled from source into .cache, from the # versions in todo_ocaml.opam.locked and tools/sqlite.sh. # tools/arm64.sh [args...] set -euo pipefail app=$(cd "$(dirname "$0")/.." && pwd) if [ -z "${IN_ARM64_ROOT:-}" ]; then "$app/tools/sqlite.sh" fetch exec "$app/../../scripts/arm64.sh" /usr/bin/env IN_ARM64_ROOT=1 \ APP_VERSION="${APP_VERSION:-dev}" LINK_FLAGS="${LINK_FLAGS:-}" "$app/tools/arm64.sh" "$@" fi # The root is shared: keep dune's cache off so nothing lands in its /root. export OPAMROOT=$app/.cache/opam-arm64 OPAMYES=1 OPAMCOLOR=never DUNE_CACHE=disabled # SQLite is compiled here too, not taken from the root's libsqlite3-dev. "$app/tools/sqlite.sh" build "$app/.cache/sqlite-arm64" export PKG_CONFIG_PATH=$app/.cache/sqlite-arm64/lib/pkgconfig if [ ! -d "$OPAMROOT/default" ]; then [ -f "$OPAMROOT/config" ] || opam init -q --bare -n --disable-sandboxing default https://opam.ocaml.org opam switch remove -q default >/dev/null 2>&1 || true # forget one make clean-deps deleted opam switch create -q default ocaml-system.5.3.0 fi if [ ! -f "$OPAMROOT/default/.deps-installed" ] || [ "$app/todo_ocaml.opam.locked" -nt "$OPAMROOT/default/.deps-installed" ]; then (cd "$app" && opam install -q --switch default --deps-only --locked .) touch "$OPAMROOT/default/.deps-installed" fi exec opam exec --switch default -- "$@"