Files
fruix/tests/guix/run-phase5-checkout-runtime.sh

99 lines
3.1 KiB
Bash
Executable File

#!/bin/sh
set -eu
repo_root=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd)
metadata_target=${METADATA_OUT:-}
cleanup=0
if [ -n "${WORKDIR:-}" ]; then
workdir=$WORKDIR
mkdir -p "$workdir"
else
workdir=$(mktemp -d /tmp/fruix-phase5-runtime.XXXXXX)
cleanup=1
fi
if [ "${KEEP_WORKDIR:-0}" -eq 1 ]; then
cleanup=0
fi
cleanup_workdir() {
if [ "$cleanup" -eq 1 ]; then
rm -rf "$workdir"
fi
}
trap cleanup_workdir EXIT INT TERM
setup_metadata=$workdir/setup-metadata.txt
setup_env=$workdir/setup-env.sh
runtime_log=$workdir/runtime-command.log
metadata_file=$workdir/phase5-runtime-metadata.txt
WORKDIR=$workdir/setup KEEP_WORKDIR=1 \
METADATA_OUT=$setup_metadata ENV_OUT=$setup_env \
"$repo_root/tests/guix/setup-phase5-checkout.sh" >"$workdir/setup.log" 2>&1
# shellcheck disable=SC1090
. "$setup_env"
cd "$PHASE5_BUILDDIR"
export LD_LIBRARY_PATH GUILE_LOAD_PATH GUILE_LOAD_COMPILED_PATH GUILE_EXTENSIONS_PATH
export GUILE_AUTO_COMPILE=0
./pre-inst-env guix --version >"$workdir/guix-version.log" 2>&1
./pre-inst-env guix repl --help >"$workdir/guix-repl-help.log" 2>&1
./pre-inst-env guix build --help >"$workdir/guix-build-help.log" 2>&1
./pre-inst-env fruix --version >"$workdir/fruix-version.log" 2>&1
first_guix_version_line=$(sed -n '1p' "$workdir/guix-version.log")
first_fruix_version_line=$(sed -n '1p' "$workdir/fruix-version.log")
repl_usage_line=$(grep -m1 '^Usage:' "$workdir/guix-repl-help.log" || true)
build_usage_line=$(grep -m1 '^Usage:' "$workdir/guix-build-help.log" || true)
printf '%s\n' "$first_guix_version_line" | grep -q '^guix (GNU Guix) ' || {
echo "unexpected guix version output: $first_guix_version_line" >&2
exit 1
}
printf '%s\n' "$first_fruix_version_line" | grep -q '^fruix (GNU Guix) ' || {
echo "unexpected fruix version output: $first_fruix_version_line" >&2
exit 1
}
printf '%s\n' "$repl_usage_line" | grep -q '^Usage: guix repl ' || {
echo "unexpected guix repl help output: $repl_usage_line" >&2
exit 1
}
printf '%s\n' "$build_usage_line" | grep -q '^Usage: guix build' || {
echo "unexpected guix build help output: $build_usage_line" >&2
exit 1
}
cat >"$metadata_file" <<EOF
workdir=$workdir
setup_metadata=$setup_metadata
setup_env=$setup_env
phase5_builddir=$PHASE5_BUILDDIR
phase5_pre_inst_env=$PHASE5_PRE_INST_ENV
guix_version_log=$workdir/guix-version.log
fruix_version_log=$workdir/fruix-version.log
guix_repl_help_log=$workdir/guix-repl-help.log
guix_build_help_log=$workdir/guix-build-help.log
first_guix_version_line=$first_guix_version_line
first_fruix_version_line=$first_fruix_version_line
repl_usage_line=$repl_usage_line
build_usage_line=$build_usage_line
fruix_frontend_policy=symlinked scripts/fruix frontend over upstream-derived guix internals
EOF
if [ -n "$metadata_target" ]; then
mkdir -p "$(dirname "$metadata_target")"
cp "$metadata_file" "$metadata_target"
fi
printf 'PASS phase5-checkout-runtime\n'
printf 'Work directory: %s\n' "$workdir"
printf 'Metadata file: %s\n' "$metadata_file"
if [ -n "$metadata_target" ]; then
printf 'Copied metadata to: %s\n' "$metadata_target"
fi
printf '%s\n' '--- metadata ---'
cat "$metadata_file"