From 2a0866581c6c909061baca3d3252a2137719defb Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Sat, 11 Jul 2026 11:03:43 +0200 Subject: Add setup_repo (rm+rsync+clone+shadow, exit mode) Co-Authored-By: Claude Opus 4.8 --- sbo-batch-test | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/sbo-batch-test b/sbo-batch-test index 9a4b2a9..b33bb65 100755 --- a/sbo-batch-test +++ b/sbo-batch-test @@ -398,6 +398,36 @@ shadow_scan() { done } +# --setup-repo: first-time full build of the SBo tree. rm -rf the tree root, +# rsync it fresh, clone the personal subtrees in, shadow upstream dups. Runs its +# own checks (the tree may not exist yet). Standalone: exits, never builds. +setup_repo() { + [[ $EUID -eq 0 ]] || { echo "--setup-repo must run as root (rsync/rm to the tree)." >&2; exit 1; } + require_config + [[ -n "$SBO_RSYNC_URL" ]] || { echo "SBO_RSYNC_URL is unset; set it in $SBO_BATCH_CONFIG." >&2; exit 1; } + local root="${SBO_TREE_ROOTS[0]}" + [[ -n "$root" ]] || { echo "SBO_TREE_ROOTS[0] is empty." >&2; exit 1; } + + echo "This will REMOVE $root and rsync it fresh from $SBO_RSYNC_URL." + read -rp "Proceed? [y/N] " confirm + [[ "$confirm" =~ ^[Yy]$ ]] || { echo "Aborted."; exit 0; } + + rm -rf "${root:?}" + echo "Rsyncing tree..." + rsync_tree "$root" || { echo "rsync failed." >&2; exit 1; } + + local dir + for dir in "${!SBO_PERSONAL_TREES[@]}"; do + echo "Cloning $dir..." + git clone "${SBO_PERSONAL_TREES[$dir]}" "$root/$dir" \ + || { echo "clone of $dir failed." >&2; exit 1; } + done + + shadow_scan "$root" + echo "Repository ready at $root" + exit 0 +} + # ============================================================================= # Package cache. Persistent, on-disk store of built packages so unchanged deps # are installed from cache instead of rebuilt. Layout mirrors the SBo tree: -- cgit v1.2.3