You've already forked fruix-bootstrap
104 lines
4.1 KiB
Bash
Executable File
104 lines
4.1 KiB
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
|
|
bootstrap_root=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)
|
|
default_channel_dir=$bootstrap_root/../fruix
|
|
if [ -d "$default_channel_dir" ]; then
|
|
default_channel_dir=$(CDPATH= cd -- "$default_channel_dir" && pwd)
|
|
fi
|
|
|
|
fruix_channel_dir=${FRUIX_CHANNEL_DIR:-$default_channel_dir}
|
|
fruix_channel_url=${FRUIX_CHANNEL_URL:-https://git.teralink.net/self/fruix.git}
|
|
builder_root=${FRUIX_BUILDER_ROOT:-$HOME/.local/opt/fruix-builder}
|
|
legacy_guile_bin=/tmp/guile-freebsd-validate-install/bin/guile
|
|
legacy_guile_extra_prefix=/tmp/guile-gnutls-freebsd-validate-install
|
|
legacy_shepherd_prefix=/tmp/shepherd-freebsd-validate-install
|
|
legacy_guix_source_dir=$HOME/repos/guix
|
|
|
|
if [ -x "$builder_root/guile/bin/guile" ]; then
|
|
default_guile_bin=$builder_root/guile/bin/guile
|
|
else
|
|
default_guile_bin=$legacy_guile_bin
|
|
fi
|
|
if [ -d "$builder_root/guile-extra" ]; then
|
|
default_guile_extra_prefix=$builder_root/guile-extra
|
|
else
|
|
default_guile_extra_prefix=$legacy_guile_extra_prefix
|
|
fi
|
|
if [ -d "$builder_root/shepherd" ]; then
|
|
default_shepherd_prefix=$builder_root/shepherd
|
|
else
|
|
default_shepherd_prefix=$legacy_shepherd_prefix
|
|
fi
|
|
if [ -d "$builder_root/src/guix/guix" ]; then
|
|
default_guix_source_dir=$builder_root/src/guix
|
|
else
|
|
default_guix_source_dir=$legacy_guix_source_dir
|
|
fi
|
|
|
|
guix_source_dir=${GUIX_SOURCE_DIR:-$default_guix_source_dir}
|
|
guile_bin=${GUILE_BIN:-$default_guile_bin}
|
|
guile_extra_prefix=${GUILE_EXTRA_PREFIX:-$default_guile_extra_prefix}
|
|
shepherd_prefix=${SHEPHERD_PREFIX:-$default_shepherd_prefix}
|
|
script=$fruix_channel_dir/scripts/fruix.scm
|
|
modules_dir=$fruix_channel_dir/modules
|
|
|
|
if [ ! -d "$fruix_channel_dir" ]; then
|
|
echo "Fruix channel checkout not found: $fruix_channel_dir" >&2
|
|
echo "Set FRUIX_CHANNEL_DIR or clone $fruix_channel_url" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [ ! -f "$script" ] || [ ! -d "$modules_dir" ]; then
|
|
echo "Fruix channel checkout is missing scripts/ or modules/: $fruix_channel_dir" >&2
|
|
echo "Expected canonical Fruix content from $fruix_channel_url" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [ ! -x "$guile_bin" ]; then
|
|
echo "Guile binary is not executable: $guile_bin" >&2
|
|
echo "Run $bootstrap_root/bootstrap/prepare-builder.sh first, or set GUILE_BIN explicitly." >&2
|
|
exit 1
|
|
fi
|
|
|
|
guile_prefix=$(CDPATH= cd -- "$(dirname "$guile_bin")/.." && pwd)
|
|
|
|
ensure_built() {
|
|
if [ ! -d "$guile_extra_prefix/share/guile/site" ] || \
|
|
! GUILE_LOAD_PATH="$guile_extra_prefix/share/guile/site/3.0${GUILE_LOAD_PATH:+:$GUILE_LOAD_PATH}" \
|
|
GUILE_LOAD_COMPILED_PATH="$guile_extra_prefix/lib/guile/3.0/site-ccache${GUILE_LOAD_COMPILED_PATH:+:$GUILE_LOAD_COMPILED_PATH}" \
|
|
GUILE_EXTENSIONS_PATH="$guile_extra_prefix/lib/guile/3.0/extensions${GUILE_EXTENSIONS_PATH:+:$GUILE_EXTENSIONS_PATH}" \
|
|
LD_LIBRARY_PATH="$guile_extra_prefix/lib:$guile_prefix/lib:/usr/local/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" \
|
|
"$guile_bin" -c '(catch #t (lambda () (use-modules (fibers)) (display "ok") (newline)) (lambda _ (display "missing") (newline)))' | grep -qx ok; then
|
|
METADATA_OUT= ENV_OUT= GUILE_BIN="$guile_bin" INSTALL_PREFIX="$guile_extra_prefix" "$bootstrap_root/tests/shepherd/build-local-guile-fibers.sh"
|
|
fi
|
|
|
|
if [ ! -x "$shepherd_prefix/bin/shepherd" ] || [ ! -x "$shepherd_prefix/bin/herd" ]; then
|
|
METADATA_OUT= ENV_OUT= GUILE_BIN="$guile_bin" GUILE_EXTRA_PREFIX="$guile_extra_prefix" INSTALL_PREFIX="$shepherd_prefix" GUIX_SOURCE_DIR="$guix_source_dir" "$bootstrap_root/tests/shepherd/build-local-shepherd.sh"
|
|
fi
|
|
}
|
|
|
|
ensure_built
|
|
|
|
guile_lib_dir=$guile_prefix/lib
|
|
|
|
if [ -n "${GUILE_LOAD_PATH:-}" ]; then
|
|
guile_load_path="$modules_dir:$guix_source_dir:$GUILE_LOAD_PATH"
|
|
else
|
|
guile_load_path="$modules_dir:$guix_source_dir"
|
|
fi
|
|
|
|
exec env \
|
|
GUILE_AUTO_COMPILE=0 \
|
|
GUILE_LOAD_PATH="$guile_load_path" \
|
|
LD_LIBRARY_PATH="$guile_lib_dir${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" \
|
|
GUILE_PREFIX="$guile_prefix" \
|
|
GUILE_EXTRA_PREFIX="$guile_extra_prefix" \
|
|
SHEPHERD_PREFIX="$shepherd_prefix" \
|
|
GUIX_SOURCE_DIR="$guix_source_dir" \
|
|
FRUIX_PROJECT_ROOT="$fruix_channel_dir" \
|
|
FRUIX_BOOTSTRAP_ROOT="$bootstrap_root" \
|
|
FRUIX_CHANNEL_DIR="$fruix_channel_dir" \
|
|
FRUIX_CHANNEL_URL="$fruix_channel_url" \
|
|
"$guile_bin" --no-auto-compile -s "$script" "$@"
|