refactor: Simplify child container creation by copying aios itself

Changed from building new containers to simply copying the aios base:
- Backup current aios to /tmp
- Copy backup as workspace
- Copy backup as restore-img
- Much faster and simpler than pacstrap
- Child containers have same config as parent aios
This commit is contained in:
Claude
2025-11-07 15:25:01 +00:00
parent 642ccb28a6
commit fd25a50395

View File

@@ -1,37 +1,29 @@
#!/bin/bash
# Create child containers inside aios for ai user
# This script runs during build.zsh as root
# Simply copy the aios itself as child containers
ROOTFS="root.x86_64/var/lib/machines/aios"
echo "=== Creating child containers ==="
# Create workspace container
echo "Creating workspace container..."
mkdir -p /tmp/workspace-build
pacstrap -c /tmp/workspace-build base
# Backup current aios to temp location
echo "Backing up aios..."
cp -a $ROOTFS /tmp/aios-backup-$$
# Configure workspace
arch-chroot /tmp/workspace-build /bin/sh -c 'pacman -Syu --noconfirm vim git zsh openssh nodejs npm sqlite'
# Add securetty for pts login
cat >> /tmp/workspace-build/etc/securetty <<'EOF'
pts/0
pts/1
pts/2
pts/3
pts/4
pts/5
EOF
# Move to aios
# Create directory for child containers
mkdir -p $ROOTFS/var/lib/machines
mv /tmp/workspace-build $ROOTFS/var/lib/machines/workspace
# Create restore-img as clean backup
echo "Creating restore-img (backup)..."
cp -a $ROOTFS/var/lib/machines/workspace $ROOTFS/var/lib/machines/restore-img
# Copy backup as workspace
echo "Creating workspace container (copy of aios)..."
cp -a /tmp/aios-backup-$$ $ROOTFS/var/lib/machines/workspace
# Copy backup as restore-img (clean backup)
echo "Creating restore-img container (copy of aios)..."
cp -a /tmp/aios-backup-$$ $ROOTFS/var/lib/machines/restore-img
# Cleanup temp backup
rm -rf /tmp/aios-backup-$$
echo "✓ Child containers created"
echo " - workspace"
echo " - restore-img"
echo " - workspace (copy of aios)"
echo " - restore-img (copy of aios)"