phoebus_os/scripts/doctor.sh
Phoebus 83368f774c
Some checks are pending
ci / test (push) Waiting to run
feat(git): add session context, host doctor, ADRs and git hygiene
Adds scripts/context.sh + 'make context' (one-screen session briefing),
scripts/doctor.sh + 'make doctor' (host prerequisites), docs/HANDOFF.md
(rolling cross-session note), docs/adr/ (BLS, desktop profile, keyring, Rust),
.githooks/commit-msg (Conventional Commits), .gitattributes, scripts/backup-git.sh
+ 'make backup', and a Forgejo Actions CI workflow. Updates AGENTS.md reading
order/work loop and DEVELOPMENT.md.
2026-09-20 02:36:32 -07:00

77 lines
3 KiB
Bash
Executable file

#!/usr/bin/env bash
# Check that this machine can build, test and VM-test Phoebus.
#
# Exit status is advisory: 0 if the essentials are present, 1 otherwise.
set -uo pipefail
ok=0; warn=0; fail=0
result() { # result STATUS name detail
case "$1" in
OK) printf ' [ok] %-28s %s\n' "$2" "$3"; ok=$((ok+1)) ;;
WARN) printf ' [warn] %-28s %s\n' "$2" "$3"; warn=$((warn+1)) ;;
FAIL) printf ' [FAIL] %-28s %s\n' "$2" "$3"; fail=$((fail+1)) ;;
esac
}
have() { command -v "$1" >/dev/null 2>&1; }
echo "Phoebus host doctor"
echo "==================="
# Essentials for any work.
for c in git bash make; do
if have "$c"; then result OK "$c" "$(command -v "$c")"; else result FAIL "$c" "not found"; fi
done
# Bash reference tooling.
if have shellcheck; then result OK shellcheck "$(shellcheck --version | awk '/version:/{print $2}')"; else result WARN shellcheck "install for lint"; fi
if have dialog; then result OK dialog present; else result WARN dialog "only whiptail available"; fi
# Rust workspace.
if have cargo; then
result OK cargo "$(cargo --version | awk '{print $2}')"
if cargo fmt --version >/dev/null 2>&1; then result OK rustfmt present; else result FAIL rustfmt "cargo fmt unavailable"; fi
if cargo clippy --version >/dev/null 2>&1; then result OK clippy present; else result FAIL clippy "cargo clippy unavailable"; fi
else
result FAIL cargo "not found"
fi
# VM tooling.
for c in qemu-system-x86_64 qemu-img; do
if have "$c"; then result OK "$c" present; else result FAIL "$c" "install qemu for VM tests"; fi
done
ovmf=""
for f in /usr/share/OVMF/OVMF_CODE_4M.fd /usr/share/OVMF/OVMF_CODE.fd /usr/share/edk2/x64/OVMF_CODE.fd; do
[[ -r "$f" ]] && { ovmf="$f"; break; }
done
if [[ -n "$ovmf" ]]; then result OK OVMF "$ovmf"; else result FAIL OVMF "install ovmf-generic"; fi
if [[ -r /dev/kvm ]]; then result OK /dev/kvm "hardware acceleration"; else result WARN /dev/kvm "KVM unavailable; VM will be slow"; fi
# ISO / image tooling.
for c in xorriso 7z unsquashfs cpio zstd; do
if have "$c"; then result OK "$c" present; else result WARN "$c" "optional"; fi
done
# Python VM driver.
if have python3 && python3 -c 'import pexpect' >/dev/null 2>&1; then
result OK pexpect "python3 pexpect available"
else
result FAIL pexpect "install python3-pexpect"
fi
# Reference ISO (not required for unit tests).
iso="$(find "$(git rev-parse --show-toplevel)" -maxdepth 1 -name 'livegui-*.iso' -print -quit 2>/dev/null || true)"
if [[ -n "$iso" ]]; then result OK reference-iso "$(basename "$iso")"; else result WARN reference-iso "not found in repo root"; fi
# Disk space for qcow2 targets.
avail="$(df -Pk /tmp 2>/dev/null | awk 'NR==2{print $4}')"
if [[ -n "$avail" && "$avail" -gt 20000000 ]]; then
result OK disk-space "$(( avail / 1024 / 1024 )) GiB free in /tmp"
elif [[ -n "$avail" ]]; then
result WARN disk-space "$(( avail / 1024 / 1024 )) GiB free in /tmp (want >=20 GiB)"
fi
echo
printf 'summary: %d ok, %d warnings, %d failures\n' "$ok" "$warn" "$fail"
(( fail == 0 ))