mirror of
https://github.com/recklessop/zroc.git
synced 2026-07-06 14:23:14 -04:00
ova: fix packer validate errors; add KVM qcow2 artifact output
- Update ISO to ubuntu-24.04.4, hardcode SHA256 checksum (24.04.2 removed from mirrors) - Remove headless variable (not declared in QEMU-only HCL, QEMU is always headless) - Add qcow2-to-kvm.sh post-processor for KVM/libvirt/Proxmox deployments - Add qcow2-to-ova.sh (converts qcow2 → stream-optimized VMDK → OVA without ovftool) - packer validate now passes cleanly Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Executable
+50
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env bash
|
||||
# qcow2-to-kvm.sh — Package a QEMU qcow2 image as a KVM/libvirt/Proxmox artifact.
|
||||
#
|
||||
# Usage: qcow2-to-kvm.sh <qemu_output_dir/vm_name> <output.qcow2>
|
||||
#
|
||||
# Example:
|
||||
# qcow2-to-kvm.sh ../output/qemu/zroc-appliance-1.0.0 \
|
||||
# ../output/zroc-appliance-1.0.0-ubuntu-24.04-amd64.qcow2
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
QEMU_VM_PATH="$1" # path to qcow2 (without extension) or directory
|
||||
QCOW2_OUT="$2" # destination .qcow2 file
|
||||
|
||||
# ── Locate the source qcow2 ───────────────────────────────────────────────────
|
||||
if [[ -f "${QEMU_VM_PATH}.qcow2" ]]; then
|
||||
QCOW2_SRC="${QEMU_VM_PATH}.qcow2"
|
||||
elif [[ -d "$QEMU_VM_PATH" ]]; then
|
||||
QCOW2_SRC=$(find "$QEMU_VM_PATH" -name "*.qcow2" | head -1)
|
||||
else
|
||||
QCOW2_SRC="$QEMU_VM_PATH"
|
||||
fi
|
||||
|
||||
if [[ -z "$QCOW2_SRC" || ! -f "$QCOW2_SRC" ]]; then
|
||||
echo "ERROR: could not find qcow2 image at ${QEMU_VM_PATH}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "==> [qcow2-to-kvm] Source qcow2: $QCOW2_SRC"
|
||||
echo "==> [qcow2-to-kvm] Output qcow2: $QCOW2_OUT"
|
||||
|
||||
mkdir -p "$(dirname "$QCOW2_OUT")"
|
||||
|
||||
# Re-encode with qemu-img to compact/sparsify and ensure compatibility.
|
||||
# subformat=compressed produces a space-efficient image suitable for distribution.
|
||||
echo "==> [qcow2-to-kvm] Compacting qcow2 for distribution…"
|
||||
qemu-img convert \
|
||||
-f qcow2 \
|
||||
-O qcow2 \
|
||||
-o compression_type=zlib,preallocation=off \
|
||||
"$QCOW2_SRC" \
|
||||
"$QCOW2_OUT"
|
||||
|
||||
SIZE=$(du -sh "$QCOW2_OUT" | cut -f1)
|
||||
SHA=$(sha256sum "$QCOW2_OUT" | awk '{print $1}')
|
||||
|
||||
echo "==> [qcow2-to-kvm] qcow2 complete: $QCOW2_OUT ($SIZE)"
|
||||
echo "==> [qcow2-to-kvm] SHA256: $SHA"
|
||||
echo "$SHA $(basename "$QCOW2_OUT")" > "${QCOW2_OUT}.sha256"
|
||||
echo "==> [qcow2-to-kvm] Done"
|
||||
Reference in New Issue
Block a user