367 lines
14 KiB
Bash
Executable File
367 lines
14 KiB
Bash
Executable File
#!/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}
|
|
make_bin=${MAKE_BIN:-gmake}
|
|
|
|
if [ ! -x "$guile_bin" ]; then
|
|
echo "Guile binary is not executable: $guile_bin" >&2
|
|
exit 1
|
|
fi
|
|
if ! command -v "$make_bin" >/dev/null 2>&1; then
|
|
echo "Required make tool not found: $make_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
|
|
make_scripts_log=$workdir/make-scripts-guix.log
|
|
guix_version_log=$workdir/pre-inst-env-guix-version.log
|
|
derivation_log=$workdir/pre-inst-env-guix-build-hello-derivation.log
|
|
metadata_file=$workdir/derivation-generation-investigation.txt
|
|
|
|
printf 'Working directory: %s\n' "$workdir"
|
|
printf 'Cloning source from: %s\n' "$source_repo"
|
|
rm -rf "$srcclone"
|
|
git clone --shared "$source_repo" "$srcclone" >/dev/null 2>&1
|
|
|
|
(
|
|
cd "$srcclone"
|
|
./bootstrap
|
|
) >"$bootstrap_log" 2>&1
|
|
|
|
rm -rf "$build_unsupported" "$build_courage"
|
|
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' \
|
|
MAKE="$make_bin" \
|
|
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' \
|
|
MAKE="$make_bin" \
|
|
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-Git|Guile-JSON|Guile-Sqlite3|Guile-Gcrypt|Guile-zlib|Guile-lzlib|Guile-semver|configure: error|configure: WARNING|checking whether Guile" "$courage_log" | tail -n 16 || true)
|
|
courage_error=$(grep -E '^configure: error:' "$courage_log" | tail -n 1 | sed 's/^configure: error: //' || true)
|
|
|
|
module_probe() {
|
|
name=$1
|
|
code=$2
|
|
out=$3
|
|
err=$4
|
|
set +e
|
|
"$guile_bin" -c "$code" >"$out" 2>"$err"
|
|
rc=$?
|
|
set -e
|
|
if [ "$rc" -eq 0 ] && [ "$(tr -d '\n' < "$out")" = ok ]; then
|
|
printf 'present'
|
|
else
|
|
printf 'missing'
|
|
fi
|
|
}
|
|
|
|
local_gnutls_check=$(module_probe gnutls '(use-modules (gnutls)) (display "ok") (newline)' "$workdir/guile-gnutls-check.out" "$workdir/guile-gnutls-check.err")
|
|
local_git_check=$(module_probe git '(use-modules (git)) (display (if (procedure? graph-descendant?) "ok" "missing-export")) (newline)' "$workdir/guile-git-check.out" "$workdir/guile-git-check.err")
|
|
local_json_check=$(module_probe json '(use-modules (json)) (define-json-mapping <frob> 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)' "$workdir/guile-json-check.out" "$workdir/guile-json-check.err")
|
|
local_sqlite3_check=$(module_probe sqlite3 '(use-modules (sqlite3)) (display (if (procedure? sqlite-bind-arguments) "ok" "missing-export")) (newline)' "$workdir/guile-sqlite3-check.out" "$workdir/guile-sqlite3-check.err")
|
|
local_gcrypt_check=$(module_probe gcrypt '(use-modules (gcrypt hash)) (display (if (equal? (hash-algorithm sha256) (lookup-hash-algorithm (quote sha256))) "ok" "mismatch")) (newline)' "$workdir/guile-gcrypt-check.out" "$workdir/guile-gcrypt-check.err")
|
|
local_zlib_check=$(module_probe zlib '(use-modules (zlib)) (display (if (procedure? make-zlib-input-port) "ok" "missing-export")) (newline)' "$workdir/guile-zlib-check.out" "$workdir/guile-zlib-check.err")
|
|
local_lzlib_check=$(module_probe lzlib '(use-modules (lzlib)) (display "ok") (newline)' "$workdir/guile-lzlib-check.out" "$workdir/guile-lzlib-check.err")
|
|
local_semver_check=$(module_probe semver '(use-modules (semver)) (display (if (procedure? string->semver) "ok" "missing-export")) (newline)' "$workdir/guile-semver-check.out" "$workdir/guile-semver-check.err")
|
|
|
|
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
|
|
|
|
scripts_rc=not-run
|
|
guix_version_rc=not-run
|
|
derivation_rc=not-run
|
|
make_scripts_summary=
|
|
guix_version_summary=
|
|
derivation_summary=
|
|
investigation_stage=configure-failed
|
|
|
|
if [ "$courage_rc" -ne 0 ]; then
|
|
if [ "$local_gnutls_check" = missing ]; then
|
|
grep -q "Guile bindings of GnuTLS are missing" "$courage_log" || {
|
|
echo "configure with --with-courage failed, but not for the expected missing-GnuTLS-bindings reason" >&2
|
|
exit 1
|
|
}
|
|
elif [ "$local_git_check" = missing ]; then
|
|
grep -q "Guile-Git is missing" "$courage_log" || {
|
|
echo "configure with --with-courage failed, but not for the expected missing-Guile-Git reason" >&2
|
|
exit 1
|
|
}
|
|
elif [ "$local_json_check" = missing ]; then
|
|
grep -q "Guile-JSON is missing" "$courage_log" || {
|
|
echo "configure with --with-courage failed, but not for the expected missing-Guile-JSON reason" >&2
|
|
exit 1
|
|
}
|
|
elif [ "$local_sqlite3_check" = missing ]; then
|
|
grep -q "Guile-SQLite3 could not be found" "$courage_log" || {
|
|
echo "configure with --with-courage failed, but not for the expected missing-Guile-SQLite3 reason" >&2
|
|
exit 1
|
|
}
|
|
elif [ "$local_gcrypt_check" = missing ]; then
|
|
grep -q "Guile-Gcrypt could not be found" "$courage_log" || {
|
|
echo "configure with --with-courage failed, but not for the expected missing-Guile-Gcrypt reason" >&2
|
|
exit 1
|
|
}
|
|
elif [ "$local_zlib_check" = missing ]; then
|
|
grep -q "Guile-zlib could not be found" "$courage_log" || {
|
|
echo "configure with --with-courage failed, but not for the expected missing-Guile-zlib reason" >&2
|
|
exit 1
|
|
}
|
|
elif [ "$local_lzlib_check" = missing ]; then
|
|
grep -q "Guile-lzlib is missing" "$courage_log" || {
|
|
echo "configure with --with-courage failed, but not for the expected missing-Guile-lzlib reason" >&2
|
|
exit 1
|
|
}
|
|
elif [ "$local_semver_check" = missing ]; then
|
|
grep -q "Guile-semver is missing" "$courage_log" || {
|
|
echo "configure with --with-courage failed, but not for the expected missing-Guile-semver reason" >&2
|
|
exit 1
|
|
}
|
|
fi
|
|
else
|
|
investigation_stage=configured
|
|
set +e
|
|
(
|
|
cd "$build_courage"
|
|
"$make_bin" -j1 scripts/guix
|
|
) >"$make_scripts_log" 2>&1
|
|
scripts_rc=$?
|
|
set -e
|
|
make_scripts_summary=$(tail -n 20 "$make_scripts_log" 2>/dev/null || true)
|
|
|
|
if [ "$scripts_rc" -eq 0 ]; then
|
|
investigation_stage=scripts-guix-built
|
|
set +e
|
|
(
|
|
cd "$build_courage"
|
|
./pre-inst-env guix --version
|
|
) >"$guix_version_log" 2>&1
|
|
guix_version_rc=$?
|
|
set -e
|
|
guix_version_summary=$(tail -n 30 "$guix_version_log" 2>/dev/null || true)
|
|
|
|
if [ "$guix_version_rc" -eq 0 ]; then
|
|
investigation_stage=guix-version-ok
|
|
set +e
|
|
(
|
|
cd "$build_courage"
|
|
./pre-inst-env guix build -d hello
|
|
) >"$derivation_log" 2>&1
|
|
derivation_rc=$?
|
|
set -e
|
|
derivation_summary=$(tail -n 40 "$derivation_log" 2>/dev/null || true)
|
|
if [ "$derivation_rc" -eq 0 ]; then
|
|
investigation_stage=derivation-generated
|
|
else
|
|
investigation_stage=derivation-failed
|
|
fi
|
|
else
|
|
investigation_stage=guix-version-failed
|
|
fi
|
|
else
|
|
investigation_stage=scripts-guix-build-failed
|
|
fi
|
|
fi
|
|
|
|
cat >"$metadata_file" <<EOF
|
|
source_repo=$source_repo
|
|
srcclone=$srcclone
|
|
guile_bin=$guile_bin
|
|
guile_version=$guile_version
|
|
guile_extra_prefix=${GUILE_EXTRA_PREFIX:-<unset>}
|
|
make_bin=$make_bin
|
|
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:-<none>}
|
|
make_scripts_guix_log=$make_scripts_log
|
|
make_scripts_guix_rc=$scripts_rc
|
|
pre_inst_env_guix_version_log=$guix_version_log
|
|
pre_inst_env_guix_version_rc=$guix_version_rc
|
|
pre_inst_env_guix_build_derivation_log=$derivation_log
|
|
pre_inst_env_guix_build_derivation_rc=$derivation_rc
|
|
investigation_stage=$investigation_stage
|
|
local_guile_gnutls_module=$local_gnutls_check
|
|
local_guile_git_module=$local_git_check
|
|
local_guile_json_module=$local_json_check
|
|
local_guile_sqlite3_module=$local_sqlite3_check
|
|
local_guile_gcrypt_module=$local_gcrypt_check
|
|
local_guile_zlib_module=$local_zlib_check
|
|
local_guile_lzlib_module=$local_lzlib_check
|
|
local_guile_semver_module=$local_semver_check
|
|
unsupported_summary_begin
|
|
$unsupported_summary
|
|
unsupported_summary_end
|
|
courage_summary_begin
|
|
$courage_summary
|
|
courage_summary_end
|
|
make_scripts_summary_begin
|
|
$make_scripts_summary
|
|
make_scripts_summary_end
|
|
guix_version_summary_begin
|
|
$guix_version_summary
|
|
guix_version_summary_end
|
|
derivation_summary_begin
|
|
$derivation_summary
|
|
derivation_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'
|
|
case "$investigation_stage" in
|
|
configure-failed)
|
|
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'
|
|
elif [ "$local_sqlite3_check" = missing ]; then
|
|
printf 'Finding 2: configure now advances to missing recent Guile-SQLite3.\n'
|
|
elif [ "$local_gcrypt_check" = missing ]; then
|
|
printf 'Finding 2: configure now advances to missing recent Guile-Gcrypt.\n'
|
|
elif [ "$local_zlib_check" = missing ]; then
|
|
printf 'Finding 2: configure now advances to missing recent Guile-zlib.\n'
|
|
elif [ "$local_lzlib_check" = missing ]; then
|
|
printf 'Finding 2: configure now advances to missing Guile-lzlib.\n'
|
|
elif [ "$local_semver_check" = missing ]; then
|
|
printf 'Finding 2: configure now advances to missing Guile-semver.\n'
|
|
else
|
|
printf 'Finding 2: configure reached a non-module blocker: %s\n' "${courage_error:-unknown configure failure}"
|
|
fi
|
|
;;
|
|
scripts-guix-build-failed)
|
|
printf 'Finding 2: configure succeeds with MAKE=%s, but building scripts/guix is the next blocker.\n' "$make_bin"
|
|
;;
|
|
guix-version-failed)
|
|
printf 'Finding 2: configure succeeds and scripts/guix builds, but ./pre-inst-env guix --version is the next blocker.\n'
|
|
;;
|
|
derivation-failed)
|
|
printf 'Finding 2: ./pre-inst-env guix --version works, but guix build -d hello is the next blocker.\n'
|
|
;;
|
|
derivation-generated)
|
|
printf 'Finding 2: derivation generation for hello succeeded.\n'
|
|
;;
|
|
*)
|
|
printf 'Finding 2: investigation stage %s.\n' "$investigation_stage"
|
|
;;
|
|
esac
|
|
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"
|