#!/usr/bin/env bash # extract-archive.sh — mine code from an archived prior platform version. # # Tarballs live in /.archive/platform.{0,1,2}.tar.zst (LFS-tracked). # Extracts to /tmp/atlilith-archive// so the working tree stays clean. # # Usage: ./scripts/extract-archive.sh set -euo pipefail usage() { echo "Usage: $0 " >&2 echo "" >&2 echo " platform.0 — egirl-platform (viky-era)" >&2 echo " platform.1 — lilith-platform (V1, 54-feature SaaS)" >&2 echo " platform.2 — lilith-platform.live (V2, Quinn-personal, currently in prod)" >&2 exit 2 } if [[ $# -ne 1 ]]; then usage fi name="$1" case "$name" in platform.0|platform.1|platform.2) ;; *) usage ;; esac # Resolve repo root (parent of @platform/, which contains this script). script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" repo_root="$(cd "$script_dir/../.." && pwd)" archive="$repo_root/.archive/${name}.tar.zst" dest="/tmp/atlilith-archive/${name}" if [[ ! -f "$archive" ]]; then echo "error: $archive not found." >&2 echo "Tarballs not yet built. On apricot, run:" >&2 echo " ./scripts/build-archives.sh # for platform.1 + platform.2" >&2 echo " ./scripts/cache-v0.sh # for platform.0 (from NFS)" >&2 exit 1 fi if ! command -v unzstd >/dev/null 2>&1; then echo "error: unzstd not found. Install zstd (brew install zstd / apt install zstd)." >&2 exit 1 fi mkdir -p "$dest" echo "Extracting $archive -> $dest ..." tar --use-compress-program=unzstd -xf "$archive" -C "$dest" echo "Done. Mined source at: $dest" echo "Cleanup when finished: rm -rf $dest"