Cierra el lazo ISO live -> disco instalado -> bootea solo. iso-image.sh INSTALLER=1 bundlea kernel + GRUB MBR (boot/core.img + modulos) en el initramfs bajo /usr/lib/hammer/install/ + inyecta /usr/bin/hammer-install. hammer-install corre dentro del live como root real (busybox fdisk/mke2fs/mount/dd + uutils cp): particiona MBR (/,/store,/var/lib/hammer), formatea, copia la propia raiz del live (autoinstalador), escribe /boot+wrapper, instala GRUB con 2 dd (boot->MBR, core->hueco post-MBR; punteros default 1/2 ya valen en MBR contiguo, sin parcheo). AUTO_INSTALL=<dev> = /init desatendido (install+poweroff). iso-install-test.sh valida E2E: ISO+disco blanco -> HAMMER-INSTALL-OK -> boot del disco solo -> GRUB->kernel->arje-zero->sshd, particiones dedicadas montadas. GOTCHAS: busybox fdisk CHS-alinea a 63 (hueco 62 < core 281 sectores) -> pisa el FS de p1 -> grub>; fix sectores explicitos (p1@2048). Copiar top-level de / enumerado, no lista fija, o se escapa /ente/seed.card.json. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
64 lines
3.5 KiB
Bash
Executable File
64 lines
3.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# iso-install-test.sh — valida el lazo COMPLETO de instalación desde el medio live (refinamiento #1):
|
|
# (1) arma un ISO instalador (iso-image.sh INSTALLER=1 AUTO_INSTALL=/dev/vda) con el payload de disco
|
|
# (kernel + GRUB MBR + /usr/bin/hammer-install) bundleado;
|
|
# (2) lo bootea con un disco EN BLANCO ⇒ el /init desatendido corre hammer-install y apaga;
|
|
# (3) bootea ESE disco SOLO (sin ISO, sin -kernel) ⇒ el producto instalado arranca y sirve SSH.
|
|
# Cierra el lazo "ISO live → disco instalado → bootea solo", lo que hace la distro distribuible.
|
|
#
|
|
# Uso: PRODUCT=<hash-o-prefijo> ./scripts/iso-install-test.sh
|
|
# Vars: KERNEL MEM (def 4096) KVM (def 1) DISK_MB (def 4096) INSTALL_DEADLINE (def 180) BOOT_DEADLINE (def 90)
|
|
set -euo pipefail
|
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"; cd "$ROOT"
|
|
KERNEL="${KERNEL:-$(ls store/*-linux/boot/bzImage 2>/dev/null | head -1)}"
|
|
MEM="${MEM:-4096}"; KVM="${KVM:-1}"; DISK_MB="${DISK_MB:-4096}"
|
|
INSTALL_DEADLINE="${INSTALL_DEADLINE:-180}"; BOOT_DEADLINE="${BOOT_DEADLINE:-90}"
|
|
WORK="$ROOT/work/iso-install-test"; ISO="$WORK/installer.iso"; TGT="$WORK/target.img"
|
|
ILOG="$WORK/install.log"; BLOG="$WORK/diskboot.log"
|
|
mkdir -p "$WORK"
|
|
|
|
if [ -n "${PRODUCT:-}" ]; then
|
|
PDIR=$(ls -d store/"${PRODUCT#b3:}"*-product-rootfs 2>/dev/null | head -1)
|
|
else
|
|
PDIR=$(ls -dt store/*-product-rootfs 2>/dev/null | head -1)
|
|
fi
|
|
[ -n "$PDIR" ] && [ -d "$PDIR" ] || { echo "no encuentro product-rootfs"; exit 1; }
|
|
[ -n "$KERNEL" ] && [ -e "$KERNEL" ] || { echo "no encuentro kernel"; exit 1; }
|
|
echo "==> product-rootfs: $PDIR"
|
|
|
|
accel=(); if [ "$KVM" = 1 ] && [ -w /dev/kvm ]; then accel=(-enable-kvm -cpu host); fi
|
|
|
|
echo "==> (1) armando ISO instalador (INSTALLER=1, AUTO_INSTALL=/dev/vda)"
|
|
ROOTFS="$PDIR" ISO="$ISO" KERNEL="$KERNEL" INSTALLER=1 AUTO_INSTALL=/dev/vda ./scripts/iso-image.sh >/dev/null
|
|
echo " ISO: $(du -h "$ISO" | cut -f1)"
|
|
|
|
echo "==> (2) boot del instalador con disco EN BLANCO ${DISK_MB}M (auto-instala y apaga)"
|
|
rm -f "$TGT"; truncate -s "${DISK_MB}M" "$TGT"
|
|
timeout "$INSTALL_DEADLINE" qemu-system-x86_64 -m "$MEM" -no-reboot -nographic "${accel[@]}" \
|
|
-drive file="$TGT",format=raw,if=virtio -cdrom "$ISO" -boot d > "$ILOG" 2>&1 || true
|
|
if ! grep -q "HAMMER-INSTALL-OK" "$ILOG"; then
|
|
echo "✗ la instalación NO terminó OK — ver $ILOG" >&2
|
|
grep -iE "HAMMER-INSTALL-FAIL|hammer-install:|no apareció|error" "$ILOG" | head; exit 1
|
|
fi
|
|
echo " ✓ HAMMER-INSTALL-OK"
|
|
|
|
echo "==> (3) boot del DISCO instalado (sin ISO, sin -kernel)"
|
|
timeout "$BOOT_DEADLINE" qemu-system-x86_64 -m "$MEM" -no-reboot -nographic "${accel[@]}" \
|
|
-drive file="$TGT",format=raw,if=virtio > "$BLOG" 2>&1 || true
|
|
|
|
fail=0
|
|
check() { if grep -qiE "$1" "$BLOG"; then echo " ✓ $2"; else echo " ✗ $2" >&2; fail=1; fi; }
|
|
reject() { if grep -qiE "$1" "$BLOG"; then echo " ✗ $2 (apareció)" >&2; fail=1; else echo " ✓ $2"; fi; }
|
|
echo "==> asserts sobre el arranque del disco:"
|
|
check "GNU GRUB" "GRUB del disco (MBR→core.img del hueco post-MBR)"
|
|
check "Linux version 6\.16" "kernel cargado del disco"
|
|
check "Server listening on .* port 22" "sshd escuchando (producto instalado en servicio)"
|
|
reject "ARRANQUE FALLIDO|seed.card no encontrada" "arje-zero arrancó sin fallo de seed"
|
|
reject "no pude montar" "particiones dedicadas /store y /var/lib/hammer montadas"
|
|
|
|
if [ "$fail" = 0 ]; then
|
|
echo; echo "✓✓ INSTALL-FROM-LIVE VERDE: ISO live → hammer-install → disco que bootea solo y sirve SSH"
|
|
else
|
|
echo; echo "✗ install-from-live FALLÓ — ver $ILOG / $BLOG" >&2; exit 1
|
|
fi
|