aboutsummaryrefslogtreecommitdiffstats
path: root/sbo-batch-test
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-06-24 15:21:51 +0200
committerDanilo M. <danix@danix.xyz>2026-06-24 15:21:51 +0200
commit198499d28f69abd20584a2eb88d9e1dd29e9dbec (patch)
treeaaba332d7285be62ee396896c5e8eb3ca79b961e /sbo-batch-test
parentbe4f69754e104fb753a9c9f9299a3e72821a6946 (diff)
downloadsbo-batch-tester-198499d28f69abd20584a2eb88d9e1dd29e9dbec.tar.gz
sbo-batch-tester-198499d28f69abd20584a2eb88d9e1dd29e9dbec.zip
Externalize config; mirror mountpoint+auto-mount, MIRROR_TREE, --terse
Config now lives outside the script in $SBO_BATCH_CONFIG (default ~/.config/sbo-batch-tester/config), sourced at load. Script ships empty defaults plus config.example as the template; require_config (in validate_env and init_base) hard-fails a real run when the config is missing or has not set SLACKWARE_BASE / LOCAL_MIRROR_15 / SBO_TREE_ROOTS. LOCAL_MIRROR_15 is now the NFS mountpoint, not the tree root. The Slackware tree is derived as MIRROR_TREE=$LOCAL_MIRROR_15/slackware64-$VERSION (holds ChangeLog.txt, slackware64/, patches/); all mirror content reads use it. The mountpoint is checked with mountpoint -q and auto-mounted (mount $LOCAL_MIRROR_15) when the noauto fstab entry is not mounted, left mounted after the run. installpkg/upgradepkg run with --terse for cleaner output. Docs updated. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'sbo-batch-test')
-rwxr-xr-xsbo-batch-test117
1 files changed, 79 insertions, 38 deletions
diff --git a/sbo-batch-test b/sbo-batch-test
index 4683eb3..0c39ed2 100755
--- a/sbo-batch-test
+++ b/sbo-batch-test
@@ -19,35 +19,39 @@
# No em dashes in prose by author convention.
# =============================================================================
-# CONFIG (edit these for your VM)
+# CONFIG
# =============================================================================
-
-# LOCAL (non-NFS) read-only 15.0 base install tree. This is the overlay
-# lowerdir. MUST be a local filesystem (ext4/xfs). NEVER point this at the NFS
-# mirror: overlayfs over NFS lowerdir is fragile and fails intermittently.
-SLACKWARE_BASE="/sbo-base/15.0"
-
-# NFS-mounted 15.0 mirror. Package SOURCE only, used to populate/patch
-# SLACKWARE_BASE. Read-only is fine. Never used as the overlay lowerdir.
-LOCAL_MIRROR_15="/mnt/nfs/slackware64-15.0"
-
-# One or more LOCAL SBo tree roots, resolved in order (first match wins).
-# Standard SBo layout: <root>/<category>/<prog>/{prog.SlackBuild,prog.info,...}.
-# Read in place, never copied or synced.
-SBO_TREE_ROOTS=(
- "/home/danix/SBo-danix"
- "/home/danix/slackbuilds-15.0"
-)
-
-# Where overlays are created. LOCAL. One disposable overlay per target lives here.
+#
+# Do NOT edit values here. Real config lives in an external file, sourced below.
+# Default path: ~/.config/sbo-batch-tester/config (override with $SBO_BATCH_CONFIG).
+# Copy config.example from the repo and edit it. Runs as root, so ~ is root's
+# home (/root/.config/sbo-batch-tester/config).
+#
+# Config file sets these (see config.example for docs on each):
+# SLACKWARE_BASE LOCAL_MIRROR_15 SBO_TREE_ROOTS CHROOT_LOCATION LOG_ROOT VERSION
+
+# Defaults. The config file overrides any it sets. These are placeholders, a run
+# fails fast in validate_env / init_base if the config has not set real paths.
+SLACKWARE_BASE=""
+LOCAL_MIRROR_15=""
+SBO_TREE_ROOTS=()
CHROOT_LOCATION="/tmp"
-
-# Where persistent logs are written (outside the overlay, survives teardown).
LOG_ROOT="/var/log/sbo-batch-test"
-
-# Slackware version, used for the mirror ChangeLog / patches path.
VERSION="15.0"
+# Source the external config if present. Not an error here if missing (keeps the
+# script sourceable by test-logic.sh); validate_env / init_base report it.
+SBO_BATCH_CONFIG="${SBO_BATCH_CONFIG:-$HOME/.config/sbo-batch-tester/config}"
+if [[ -f "$SBO_BATCH_CONFIG" ]]; then
+ # shellcheck disable=SC1090
+ source "$SBO_BATCH_CONFIG"
+fi
+
+# Derived: the actual Slackware tree under the mirror mountpoint. Holds
+# ChangeLog.txt, slackware64/, and patches/. Set after sourcing so it picks up
+# the config's LOCAL_MIRROR_15 and VERSION.
+MIRROR_TREE="$LOCAL_MIRROR_15/slackware64-$VERSION"
+
# =============================================================================
# END CONFIG
# =============================================================================
@@ -151,11 +155,33 @@ parse_args() {
# =============================================================================
# startup validation (fail fast, copy-pasteable hints)
# =============================================================================
+
+# Shared: the config file must exist and set the required paths. Called by both
+# validate_env and init_base.
+require_config() {
+ if [[ ! -f "$SBO_BATCH_CONFIG" ]]; then
+ cat >&2 <<EOF
+No config file: $SBO_BATCH_CONFIG
+Copy the example and edit it (paths run as root, so this is /root/.config/...):
+
+ mkdir -p "\$(dirname "$SBO_BATCH_CONFIG")"
+ cp config.example "$SBO_BATCH_CONFIG"
+ \${EDITOR:-vi} "$SBO_BATCH_CONFIG"
+EOF
+ exit 1
+ fi
+ if [[ -z "$SLACKWARE_BASE" || -z "$LOCAL_MIRROR_15" || ${#SBO_TREE_ROOTS[@]} -eq 0 ]]; then
+ echo "Config $SBO_BATCH_CONFIG is missing SLACKWARE_BASE, LOCAL_MIRROR_15, or SBO_TREE_ROOTS." >&2
+ exit 1
+ fi
+}
+
validate_env() {
if [[ $EUID -ne 0 ]]; then
echo "This tool must run as root (overlay + chroot)." >&2
exit 1
fi
+ require_config
# SLACKWARE_BASE: local, looks like a real Slackware install.
if [[ ! -d "$SLACKWARE_BASE" || ! -d "$SLACKWARE_BASE/var/log/packages" ]]; then
@@ -176,10 +202,18 @@ EOF
exit 1 ;;
esac
- # LOCAL_MIRROR_15: NFS, must be mounted/reachable.
- if [[ ! -d "$LOCAL_MIRROR_15" || ! -f "$LOCAL_MIRROR_15/ChangeLog.txt" ]]; then
- echo "LOCAL_MIRROR_15 not reachable (NFS mount absent?): $LOCAL_MIRROR_15" >&2
- echo "Expected a Slackware 15.0 mirror with ChangeLog.txt at its root." >&2
+ # LOCAL_MIRROR_15: NFS, fstab entry is noauto. Auto-mount if not mounted
+ # (needs the fstab entry for bare `mount <path>`). Left mounted after the run.
+ if ! mountpoint -q "$LOCAL_MIRROR_15"; then
+ echo "LOCAL_MIRROR_15 not mounted, attempting: mount $LOCAL_MIRROR_15" >&2
+ if ! mount "$LOCAL_MIRROR_15"; then
+ echo "Could not mount $LOCAL_MIRROR_15 (no fstab entry? mount it manually)." >&2
+ exit 1
+ fi
+ fi
+ if [[ ! -f "$MIRROR_TREE/ChangeLog.txt" ]]; then
+ echo "Mirror mounted but no ChangeLog.txt under: $MIRROR_TREE" >&2
+ echo "Expected the Slackware 15.0 tree at \$LOCAL_MIRROR_15/slackware64-\$VERSION." >&2
exit 1
fi
@@ -209,12 +243,19 @@ init_base() {
if [[ $EUID -ne 0 ]]; then
echo "--init-base must run as root (installpkg --root)." >&2; exit 1
fi
+ require_config
case "$SLACKWARE_BASE" in
"$LOCAL_MIRROR_15"*)
echo "SLACKWARE_BASE must NOT live under LOCAL_MIRROR_15 (NFS)." >&2; exit 1 ;;
esac
- if [[ ! -d "$LOCAL_MIRROR_15" || ! -f "$LOCAL_MIRROR_15/ChangeLog.txt" ]]; then
- echo "LOCAL_MIRROR_15 not reachable (NFS mount absent?): $LOCAL_MIRROR_15" >&2; exit 1
+ if ! mountpoint -q "$LOCAL_MIRROR_15"; then
+ echo "LOCAL_MIRROR_15 not mounted, attempting: mount $LOCAL_MIRROR_15" >&2
+ if ! mount "$LOCAL_MIRROR_15"; then
+ echo "Could not mount $LOCAL_MIRROR_15 (no fstab entry? mount it manually)." >&2; exit 1
+ fi
+ fi
+ if [[ ! -f "$MIRROR_TREE/ChangeLog.txt" ]]; then
+ echo "Mirror mounted but no ChangeLog.txt under: $MIRROR_TREE" >&2; exit 1
fi
if [[ -d "$SLACKWARE_BASE/var/log/packages" ]]; then
echo "Base already populated: $SLACKWARE_BASE" >&2
@@ -224,34 +265,34 @@ init_base() {
echo "Populating base from mirror into: $SLACKWARE_BASE"
mkdir -p "$SLACKWARE_BASE"
local p n=0
- for p in "$LOCAL_MIRROR_15"/slackware64/*/*.t?z; do
+ for p in "$MIRROR_TREE"/slackware64/*/*.t?z; do
[[ -e "$p" ]] || continue
- installpkg --root "$SLACKWARE_BASE" "$p"
+ installpkg --terse --root "$SLACKWARE_BASE" "$p"
((n++)); ((n % 50 == 0)) && echo " ...$n packages"
done
if [[ $n -eq 0 ]]; then
- echo "No packages found under $LOCAL_MIRROR_15/slackware64/*/. Wrong mirror layout?" >&2
+ echo "No packages found under $MIRROR_TREE/slackware64/*/. Wrong mirror layout?" >&2
exit 1
fi
# Seed the update marker so the next run does not re-patch needlessly.
- head -n1 "$LOCAL_MIRROR_15/ChangeLog.txt" > "$SLACKWARE_BASE/last-base-update"
+ head -n1 "$MIRROR_TREE/ChangeLog.txt" > "$SLACKWARE_BASE/last-base-update"
echo "Base populated: $n packages installed into $SLACKWARE_BASE"
}
update_base() {
local marker="$SLACKWARE_BASE/last-base-update"
touch "$marker"
- local head_now; head_now="$(head -n1 "$LOCAL_MIRROR_15/ChangeLog.txt")"
+ local head_now; head_now="$(head -n1 "$MIRROR_TREE/ChangeLog.txt")"
if [[ "$head_now" == "$(cat "$marker")" ]]; then
echo "Base is up-to-date with the mirror."
return
fi
echo "Patching base from mirror..."
local p
- for p in "$LOCAL_MIRROR_15"/patches/packages/*.t?z; do
+ for p in "$MIRROR_TREE"/patches/packages/*.t?z; do
[[ -e "$p" ]] || continue
if [[ ! -e "$SLACKWARE_BASE/var/lib/pkgtools/packages/$(basename "${p%.*}")" ]]; then
- ROOT="$SLACKWARE_BASE" upgradepkg --install-new "$p"
+ ROOT="$SLACKWARE_BASE" upgradepkg --terse --install-new "$p"
fi
done
echo "$head_now" > "$marker"
@@ -505,7 +546,7 @@ if [ -z "\$pkg" ]; then
echo "No package produced in \$out"
echo BUILD-FAILED > "$workroot/$prog.status"; exit 1
fi
-if ! installpkg "\$pkg"; then
+if ! installpkg --terse "\$pkg"; then
echo INSTALL-FAILED > "$workroot/$prog.status"; exit 1
fi
# Log the installed file list (from the package db) so the overlay is disposable.