From 868d6d1c1389bc4212fd707413eb2fb15fe4c186 Mon Sep 17 00:00:00 2001 From: Softer Date: Tue, 28 Apr 2026 13:33:50 +0300 Subject: [PATCH] Share /var/log/archinstall via 9p in dev VM and clear it per run Replace the plain `archinstall` alias with a function that wipes the log directory contents before each run, and add a third 9p share so the guest log directory is backed by .dev-logs/ on the host. The host can now tail install.log live without re-entering the VM, and successive iterations start with an empty log without rebooting. The wipe uses find -mindepth 1 -delete because /var/log/archinstall is a 9p mountpoint - removing the directory itself would unmount the share. Cleanup: dev_vm.sh clean now also removes .dev-logs/. --- .gitignore | 1 + scripts/dev_vm.sh | 37 +++++++++++++++++++++++++++---------- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 940f41eb..38ad5e29 100644 --- a/.gitignore +++ b/.gitignore @@ -42,5 +42,6 @@ requirements.txt /cmd_output.txt /.dev-iso/ /.dev-configs/ +/.dev-logs/ node_modules/ uv.lock diff --git a/scripts/dev_vm.sh b/scripts/dev_vm.sh index 70ad5b26..6347e110 100755 --- a/scripts/dev_vm.sh +++ b/scripts/dev_vm.sh @@ -1,19 +1,22 @@ #!/bin/bash # Dev test VM for archinstall. # Builds a minimal dev ISO on first run (runtime deps pre-installed, 9p shares -# auto-mounted, `archinstall` aliased to `python -m archinstall`), then launches -# QEMU. Source lives on the host, guest mounts it read-only - no rebuild loop. +# auto-mounted, `archinstall` wrapped to clear logs and run `python -m archinstall`), +# then launches QEMU. Source lives on the host, guest mounts it read-only - no rebuild loop. # # Host artifacts (created in repo root, all git-ignored): # .dev-iso/ generated dev ISO (mkarchiso output) # .dev-disk.qcow2 VM disk image (qemu-img) # .dev-ovmf-vars.fd persistent UEFI NVRAM (copied from OVMF_VARS) # .dev-configs/ optional, user-created - shared rw to guest as /root/cfg +# .dev-logs/ auto-created - shared rw to guest as /var/log/archinstall # # Inside the guest after boot: # /root/archinstall-dev project source (9p ro, host edits appear live) # /root/cfg .dev-configs share (9p rw, mounted only if folder exists) -# archinstall alias for `python -m archinstall` +# /var/log/archinstall .dev-logs share (9p rw, host can tail install.log live) +# archinstall wrapper around `python -m archinstall`; clears the +# log directory on every invocation # # Run from the project root or from inside scripts/ - both work, the script # resolves the project root from its own location. @@ -23,7 +26,7 @@ # ./scripts/dev_vm.sh rebuild | r - force rebuild ISO, fresh disk, boot # ./scripts/dev_vm.sh keep | k - reuse disk, boot ISO # ./scripts/dev_vm.sh boot | b - boot from installed disk (no ISO) -# ./scripts/dev_vm.sh clean | c - remove disk, NVRAM, ISO +# ./scripts/dev_vm.sh clean | c - remove disk, NVRAM, ISO, logs # ./scripts/dev_vm.sh -h - show this help # # Env overrides: @@ -37,6 +40,7 @@ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" CONFIGS_DIR="$PROJECT_DIR/.dev-configs" +LOGS_DIR="$PROJECT_DIR/.dev-logs" ISO_DIR="$PROJECT_DIR/.dev-iso" DISK="$PROJECT_DIR/.dev-disk.qcow2" OVMF_VARS="$PROJECT_DIR/.dev-ovmf-vars.fd" @@ -155,24 +159,32 @@ cat > "$BUILD_DIR/airootfs/etc/gitconfig" <<'GIT' directory = /root/archinstall-dev GIT -# Auto-mount project, alias archinstall, print info on login +# Auto-mount project, define archinstall wrapper, print info on login mkdir -p "$BUILD_DIR/airootfs/root" cat > "$BUILD_DIR/airootfs/root/.zprofile" <<'ZP' -mkdir -p /root/archinstall-dev /root/cfg +mkdir -p /root/archinstall-dev /root/cfg /var/log/archinstall if ! mount -t 9p -o trans=virtio,ro dev /root/archinstall-dev 2>/dev/null; then - echo "ERROR: failed to mount 9p 'dev' share. The archinstall alias will not work." + echo "ERROR: failed to mount 9p 'dev' share. The archinstall wrapper will not work." echo "Check host qemu virtfs support and that the guest kernel has the 9p module." fi mount -t 9p -o trans=virtio cfg /root/cfg 2>/dev/null || true +mount -t 9p -o trans=virtio logs /var/log/archinstall 2>/dev/null || true cd /root/archinstall-dev export PYTHONDONTWRITEBYTECODE=1 -alias archinstall='python -m archinstall' +# Wrapper instead of a plain alias so each invocation starts with a clean log +# directory. The directory is a 9p mount from the host, so the contents are +# wiped (find -delete) instead of removing the mountpoint itself. +archinstall() { + find /var/log/archinstall -mindepth 1 -delete 2>/dev/null + python -m archinstall "$@" +} cat <