#!/usr/bin/env bash # build-bundle.sh — produce a self-contained tarball for one platform. # # ./build-bundle.sh both platforms # ./build-bundle.sh proxmox only the Proxmox bundle # ./build-bundle.sh qemu /tmp/out custom output directory # # The bundle carries the shared content, the platform entrypoint, the docs and # the answer key, so it can be copied to a host that cannot reach the git # server: scp norbourg-proxmox.tar.gz root@pve:/root/ && tar xzf ... set -euo pipefail ROOT=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P) TARGET=${1:-all} OUT=${2:-$ROOT/dist} SRC="$ROOT/session1" info() { printf '[*] %s\n' "$*"; } ok() { printf '[ok] %s\n' "$*"; } build() { local platform=$1 local stage="$OUT/norbourg-$platform" local archive="$OUT/norbourg-$platform.tar.gz" [[ -d $SRC/platforms/$platform ]] || { echo "no such platform in session1: $platform" >&2; return 1; } rm -rf "$stage" mkdir -p "$stage" # Shared content + one platform + docs + answers. Generated and transient # paths are excluded: they are rebuilt by the host's own commands. tar -C "$SRC" -cf - \ --exclude='.git' \ --exclude='__pycache__' \ --exclude='*.pyc' \ --exclude='content/web/site' \ --exclude='content/seed/out' \ --exclude='dist' \ content "platforms/$platform" docs answers README.md \ | tar -C "$stage" -xf - # Trim the platform directories we did not ask for. find "$stage/platforms" -mindepth 1 -maxdepth 1 -type d ! -name "$platform" -exec rm -rf {} + tar -C "$OUT" -czf "$archive" "norbourg-$platform" ok "$archive ($(du -h "$archive" | cut -f1))" } mkdir -p "$OUT" case $TARGET in all) build qemu build proxmox ;; qemu|proxmox) build "$TARGET" ;; *) echo "usage: $0 [qemu|proxmox|all] [output-dir]" >&2 exit 2 ;; esac printf '\n' info "copy to the target host, then:" info " tar xzf norbourg-.tar.gz && cd norbourg-" info " ./platforms//lab.sh check"