From 511cf960d6c52827b3de6d7ad0d904711e69b144 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 7 Nov 2025 12:53:12 +0000 Subject: [PATCH] feat: Pre-create containers in build.zsh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changed container creation from install-time to build-time: Before: - build.zsh: create only aios - install.sh: machinectl clone aios → aiosback, workspace After: - build.zsh: create aios + aiosback + workspace (cp -a) - install.sh: just extract and move to /var/lib/machines/ Benefits: - Simpler install.sh (no machinectl clone operations) - Faster installation (no clone overhead) - All containers included in tarball - Consistent initial state --- build.zsh | 8 +++++++- cfg/install.sh | 34 +++++----------------------------- 2 files changed, 12 insertions(+), 30 deletions(-) diff --git a/build.zsh b/build.zsh index a2c017f..3ace9d2 100755 --- a/build.zsh +++ b/build.zsh @@ -98,11 +98,17 @@ echo "=== Finalizing ===" # Copy aios-ctl.zsh for host machine control cp -rf ./cfg/aios-ctl.zsh root.x86_64/var/lib/machines/arch/opt/aios-ctl.zsh +# Create backup and workspace containers +echo "Creating aiosback and workspace containers..." +cp -a root.x86_64/var/lib/machines/arch root.x86_64/var/lib/machines/aiosback +cp -a root.x86_64/var/lib/machines/arch root.x86_64/var/lib/machines/workspace + # Copy install script cp -rf ./cfg/install.sh ./install.sh chmod +x ./install.sh -# Create tarball +# Create tarball with all containers +echo "Creating tarball..." tar -zcvf aios-bootstrap.tar.gz root.x86_64/ install.sh echo "" diff --git a/cfg/install.sh b/cfg/install.sh index 54285c7..f912950 100644 --- a/cfg/install.sh +++ b/cfg/install.sh @@ -27,11 +27,13 @@ fi echo "1. Extracting $TARBALL..." tar xf "$TARBALL" -# Move to /var/lib/machines/ -echo "2. Installing to /var/lib/machines/$NAME..." -rm -rf /var/lib/machines/$NAME +# Move all containers to /var/lib/machines/ +echo "2. Installing containers to /var/lib/machines/..." +rm -rf /var/lib/machines/$NAME /var/lib/machines/$BACKUP /var/lib/machines/workspace mkdir -p /var/lib/machines mv root.x86_64/var/lib/machines/arch /var/lib/machines/$NAME +mv root.x86_64/var/lib/machines/aiosback /var/lib/machines/$BACKUP +mv root.x86_64/var/lib/machines/workspace /var/lib/machines/workspace # Copy nspawn configuration echo "3. Installing systemd-nspawn configuration..." @@ -86,32 +88,6 @@ mkdir -p /root/.config/syui/ai echo "4. Enabling systemd-machined..." systemctl enable --now systemd-machined -# Remove existing images if they exist -echo "5. Checking for existing images..." -for img in $BACKUP workspace; do - if machinectl list-images | grep -q "^$img"; then - echo " Removing existing image: $img" - machinectl poweroff $img 2>/dev/null || true - sleep 2 - machinectl terminate $img 2>/dev/null || true - sleep 2 - # Force kill if still running - if machinectl status $img &>/dev/null; then - machinectl kill $img --signal=SIGKILL 2>/dev/null || true - sleep 2 - fi - machinectl remove $img 2>/dev/null || echo " Warning: Could not remove $img (will skip)" - fi -done - -# Create initial backup -echo "6. Creating initial backup image..." -machinectl clone $NAME $BACKUP - -# Create workspace container for AI operations -echo "7. Creating workspace container..." -machinectl clone $NAME workspace - echo "" echo "=== Installation complete ===" echo ""