#!/bin/sh set -eu source_repo=${GUIX_SOURCE_REPO:-"$HOME/repos/guix"} store_dir=${STORE_DIR:-/frx/store} localstatedir=${LOCALSTATEDIR:-/frx/var} sysconfdir=${SYSCONFDIR:-/frx/etc} guile_bin=${GUILE_BIN:-/tmp/guile-freebsd-validate-install/bin/guile} if [ ! -x "$guile_bin" ]; then echo "Guile binary is not executable: $guile_bin" >&2 exit 1 fi guile_bindir=$(CDPATH= cd -- "$(dirname "$guile_bin")" && pwd) guile_prefix=$(CDPATH= cd -- "$guile_bindir/.." && pwd) guile_lib_dir=$guile_prefix/lib guile_version=$(LD_LIBRARY_PATH="$guile_lib_dir${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" "$guile_bin" -c '(display (effective-version))') export PATH="$guile_bindir:/usr/local/bin:$PATH" export ACLOCAL_PATH=/usr/local/share/aclocal${ACLOCAL_PATH:+:$ACLOCAL_PATH} if [ -n "${GUILE_EXTRA_PREFIX:-}" ]; then extra_site_dir=$GUILE_EXTRA_PREFIX/share/guile/site/$guile_version extra_ccache_dir=$GUILE_EXTRA_PREFIX/lib/guile/$guile_version/site-ccache extra_extensions_dir=$GUILE_EXTRA_PREFIX/lib/guile/$guile_version/extensions if [ -d "$extra_site_dir" ]; then export GUILE_LOAD_PATH="$extra_site_dir${GUILE_LOAD_PATH:+:$GUILE_LOAD_PATH}" fi if [ -d "$extra_ccache_dir" ]; then export GUILE_LOAD_COMPILED_PATH="$extra_ccache_dir${GUILE_LOAD_COMPILED_PATH:+:$GUILE_LOAD_COMPILED_PATH}" fi if [ -d "$extra_extensions_dir" ]; then export GUILE_EXTENSIONS_PATH="$extra_extensions_dir${GUILE_EXTENSIONS_PATH:+:$GUILE_EXTENSIONS_PATH}" fi if [ -n "${LD_LIBRARY_PATH:-}" ]; then export LD_LIBRARY_PATH="$GUILE_EXTRA_PREFIX/lib:$guile_lib_dir:/usr/local/lib:$LD_LIBRARY_PATH" else export LD_LIBRARY_PATH="$GUILE_EXTRA_PREFIX/lib:$guile_lib_dir:/usr/local/lib" fi else if [ -n "${LD_LIBRARY_PATH:-}" ]; then export LD_LIBRARY_PATH="$guile_lib_dir:/usr/local/lib:$LD_LIBRARY_PATH" else export LD_LIBRARY_PATH="$guile_lib_dir:/usr/local/lib" fi fi cleanup=0 if [ -n "${WORKDIR:-}" ]; then workdir=$WORKDIR mkdir -p "$workdir" else workdir=$(mktemp -d /tmp/fruix-guix-derivation-investigation.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 srcclone=$workdir/guix-src build_unsupported=$workdir/build-unsupported build_courage=$workdir/build-with-courage bootstrap_log=$workdir/bootstrap.log unsupported_log=$workdir/configure-unsupported.log courage_log=$workdir/configure-with-courage.log metadata_file=$workdir/derivation-generation-investigation.txt gnutls_check_out=$workdir/guile-gnutls-check.out gnutls_check_err=$workdir/guile-gnutls-check.err printf 'Working directory: %s\n' "$workdir" printf 'Cloning source from: %s\n' "$source_repo" git clone --shared "$source_repo" "$srcclone" >/dev/null 2>&1 ( cd "$srcclone" ./bootstrap ) >"$bootstrap_log" 2>&1 mkdir -p "$build_unsupported" "$build_courage" set +e ( cd "$build_unsupported" PKG_CONFIG_PATH=/usr/local/libdata/pkgconfig:/usr/local/lib/pkgconfig \ CPPFLAGS='-I/usr/local/include' \ LDFLAGS='-L/usr/local/lib -Wl,-rpath,/usr/local/lib' \ GUILE="$guile_bin" \ GUILE_EFFECTIVE_VERSION=3.0 \ "$srcclone/configure" \ --with-store-dir="$store_dir" \ --localstatedir="$localstatedir" \ --sysconfdir="$sysconfdir" ) >"$unsupported_log" 2>&1 unsupported_rc=$? ( cd "$build_courage" PKG_CONFIG_PATH=/usr/local/libdata/pkgconfig:/usr/local/lib/pkgconfig \ CPPFLAGS='-I/usr/local/include' \ LDFLAGS='-L/usr/local/lib -Wl,-rpath,/usr/local/lib' \ GUILE="$guile_bin" \ GUILE_EFFECTIVE_VERSION=3.0 \ "$srcclone/configure" \ --with-courage \ --with-store-dir="$store_dir" \ --localstatedir="$localstatedir" \ --sysconfdir="$sysconfdir" ) >"$courage_log" 2>&1 courage_rc=$? set -e unsupported_summary=$(grep -E "supported platform|Guix system type|configure: error" "$unsupported_log" | tail -n 5 || true) courage_summary=$(grep -E "supported platform|GnuTLS|guile 3.0|Guile-Git|Guile-JSON|Guile-SQLite3|Guile-Gcrypt|Guile-zlib|Guile-lzlib|Guile-semver|configure: error|configure: WARNING" "$courage_log" | tail -n 10 || true) courage_error=$(grep -E "^configure: error:" "$courage_log" | tail -n 1 | sed 's/^configure: error: //' || true) local_gnutls_check=missing set +e "$guile_bin" -c '(use-modules (gnutls)) (display "ok") (newline)' >"$gnutls_check_out" 2>"$gnutls_check_err" check_rc=$? set -e if [ "$check_rc" -eq 0 ]; then local_gnutls_check=present fi git_check_out=$workdir/guile-git-check.out git_check_err=$workdir/guile-git-check.err local_git_check=missing set +e "$guile_bin" -c '(use-modules (git)) (display (if (procedure? graph-descendant?) "ok" "missing-export")) (newline)' >"$git_check_out" 2>"$git_check_err" check_rc=$? set -e if [ "$check_rc" -eq 0 ] && [ "$(tr -d '\n' < "$git_check_out")" = ok ]; then local_git_check=present fi json_check_out=$workdir/guile-json-check.out json_check_err=$workdir/guile-json-check.err local_json_check=missing set +e "$guile_bin" -c '(use-modules (json)) (define-json-mapping make-frob frob? json->frob (a frob-a) (b frob-b "bee")) (display (if (equal? (json->frob (open-input-string "{ \"a\": 1, \"bee\": 2 }")) (make-frob 1 2)) "ok" "mismatch")) (newline)' >"$json_check_out" 2>"$json_check_err" check_rc=$? set -e if [ "$check_rc" -eq 0 ] && [ "$(tr -d '\n' < "$json_check_out")" = ok ]; then local_json_check=present fi if [ "$unsupported_rc" -eq 0 ]; then echo "configure without --with-courage unexpectedly succeeded" >&2 exit 1 fi if ! grep -q "not a supported platform" "$unsupported_log"; then echo "configure without --with-courage failed, but not for the expected unsupported-platform reason" >&2 exit 1 fi if [ "$courage_rc" -eq 0 ]; then echo "configure with --with-courage unexpectedly succeeded; investigation expectations need updating" >&2 exit 1 fi if [ "$local_gnutls_check" = missing ]; then if ! grep -q "Guile bindings of GnuTLS are missing" "$courage_log"; then echo "configure with --with-courage failed, but not for the expected missing-GnuTLS-bindings reason" >&2 exit 1 fi else if grep -q "Guile bindings of GnuTLS are missing" "$courage_log"; then echo "configure with --with-courage still reports missing GnuTLS bindings even though (gnutls) loads" >&2 exit 1 fi fi if [ "$local_gnutls_check" = present ] && [ "$local_git_check" = missing ]; then if ! grep -q "Guile-Git is missing" "$courage_log"; then echo "configure with --with-courage failed, but not for the expected missing-Guile-Git reason" >&2 exit 1 fi fi if [ "$local_gnutls_check" = present ] && [ "$local_git_check" = present ] && [ "$local_json_check" = missing ]; then if ! grep -q "Guile-JSON is missing" "$courage_log"; then echo "configure with --with-courage failed, but not for the expected missing-Guile-JSON reason" >&2 exit 1 fi elif [ "$local_json_check" = present ]; then if grep -q "Guile-JSON is missing" "$courage_log"; then echo "configure with --with-courage still reports missing Guile-JSON even though (json) works" >&2 exit 1 fi fi cat >"$metadata_file" <} store_dir=$store_dir localstatedir=$localstatedir sysconfdir=$sysconfdir bootstrap_log=$bootstrap_log configure_unsupported_log=$unsupported_log configure_with_courage_log=$courage_log configure_without_courage_rc=$unsupported_rc configure_with_courage_rc=$courage_rc configure_with_courage_error=${courage_error:-} local_guile_gnutls_module=$local_gnutls_check local_guile_git_module=$local_git_check local_guile_json_module=$local_json_check unsupported_summary_begin $unsupported_summary unsupported_summary_end courage_summary_begin $courage_summary courage_summary_end EOF if [ -n "${METADATA_OUT:-}" ]; then mkdir -p "$(dirname "$METADATA_OUT")" cp "$metadata_file" "$METADATA_OUT" fi printf 'PASS guix-derivation-generation-investigation\n' printf 'Store dir under test: %s\n' "$store_dir" printf 'Finding 1: configure without --with-courage is blocked by unsupported platform gating.\n' if [ "$local_gnutls_check" = missing ]; then printf 'Finding 2: configure with --with-courage is currently blocked by missing Guile (gnutls) bindings.\n' elif [ "$local_git_check" = missing ]; then printf 'Finding 2: Guile (gnutls) is available, but configure is now blocked by missing Guile-Git.\n' elif [ "$local_json_check" = missing ]; then printf 'Finding 2: Guile (gnutls) and Guile-Git are available, but configure is now blocked by missing Guile-JSON.\n' else printf 'Finding 2: Guile (gnutls), Guile-Git, and Guile-JSON are available; next blocker: %s\n' "${courage_error:-unknown configure failure}" fi if [ "$cleanup" -eq 0 ]; then printf 'Metadata file: %s\n' "$metadata_file" else printf '%s\n' 'Work directory will be removed on exit (set KEEP_WORKDIR=1 to preserve it).' fi if [ -n "${METADATA_OUT:-}" ]; then printf 'Copied metadata to: %s\n' "$METADATA_OUT" fi printf '%s\n' '--- metadata ---' cat "$metadata_file"