- Copy the whole webapp/ tree (minus __pycache__) in build-usb.sh and build-proxmox-iso.sh, so config, services/, views/ and blancco_evidence_monthly.py reach the server. - sfdisk --append failure now aborts; the CIDATA partition is the one starting exactly at the computed sector, and nothing that starts before it is ever formatted (the old fallback hit the ISO's EFI partition). - Volume id and El Torito load sizes come from the ISO (xorriso -report_el_torito as_mkisofs); grub.cfg must contain autoinstall after patching. - --image FILE SIZE|auto builds the same layout in a file without root (mkfs.vfat -C + mtools, sfdisk on the file). Plus --payload-root, --skip-enrollment/-bios/-drivers/-boot-tools, --yes. - tests/vm: libvirt harness (pxetest-server, pxetest-client, isolated pxetest-imaging network) with fetch-iso/build-image/create/start/ status/stop/destroy.
58 lines
2.3 KiB
Bash
Executable File
58 lines
2.3 KiB
Bash
Executable File
#!/bin/bash
|
|
# Build the installer USB as a disk image FILE with build-usb.sh image mode,
|
|
# then upload it into the libvirt 'default' pool as volume pxetest-usb.img.
|
|
#
|
|
# Usage: tests/vm/build-image.sh [--with-enrollment] [--with-boot-tools] [--size SIZE]
|
|
# Default skips enrollment/, bios-staging/, drivers-staging/ and boot-tools/
|
|
# to keep the image small; SIZE defaults to "auto".
|
|
# Env: PXETEST_PAYLOAD_ROOT (where offline-packages/, boot-files/... live)
|
|
source "$(dirname "$0")/common.sh"
|
|
|
|
SIZE=auto
|
|
SKIPS=(--skip-enrollment --skip-bios --skip-drivers --skip-boot-tools)
|
|
while [ $# -gt 0 ]; do
|
|
case "$1" in
|
|
--with-enrollment) SKIPS=("${SKIPS[@]/--skip-enrollment}"); shift ;;
|
|
--with-boot-tools) SKIPS=("${SKIPS[@]/--skip-boot-tools}"); shift ;;
|
|
--size) SIZE="$2"; shift 2 ;;
|
|
*) die "unknown option $1" ;;
|
|
esac
|
|
done
|
|
ARGS=()
|
|
for s in "${SKIPS[@]}"; do [ -n "$s" ] && ARGS+=("$s"); done
|
|
|
|
[ -f "$UBUNTU_ISO" ] || die "no ISO at $UBUNTU_ISO; run tests/vm/fetch-iso.sh"
|
|
ensure_image_tools
|
|
|
|
# Report what the payload root has and lacks (do not invent content).
|
|
log "payload root: $PXETEST_PAYLOAD_ROOT"
|
|
for d in offline-packages pip-wheels boot-files boot-tools enrollment bios-staging drivers-staging; do
|
|
if [ -d "$PXETEST_PAYLOAD_ROOT/$d" ]; then
|
|
printf ' %-17s %s\n' "$d" "$(du -shL "$PXETEST_PAYLOAD_ROOT/$d" 2>/dev/null | cut -f1)"
|
|
else
|
|
printf ' %-17s MISSING\n' "$d"
|
|
fi
|
|
done
|
|
for f in ipxe-shimx64.efi ipxeboot.tar.gz wimboot boot.wim BCD boot.sdi bootx64.efi undionly.kpxe; do
|
|
[ -f "$PXETEST_PAYLOAD_ROOT/boot-files/$f" ] || log " boot-files/$f MISSING"
|
|
done
|
|
|
|
if [ -e "$USB_IMAGE" ] && [ ! -f "$USB_IMAGE" ]; then
|
|
die "$USB_IMAGE is not a regular file"
|
|
fi
|
|
|
|
"$REPO_ROOT/scripts/build-usb.sh" --yes --payload-root "$PXETEST_PAYLOAD_ROOT" \
|
|
"${ARGS[@]}" --image "$USB_IMAGE" "$SIZE" "$UBUNTU_ISO"
|
|
|
|
BYTES=$(stat -c%s "$USB_IMAGE")
|
|
if dom_exists "$SERVER_VM" && [ "$(dom_state "$SERVER_VM")" != "shut off" ]; then
|
|
die "$SERVER_VM is running; stop it before replacing its USB volume"
|
|
fi
|
|
if vol_exists "$USB_VOL"; then
|
|
virsh vol-delete --pool "$POOL" "$USB_VOL" >/dev/null
|
|
fi
|
|
log "uploading $USB_IMAGE ($((BYTES / 1048576)) MiB) to pool $POOL as $USB_VOL"
|
|
virsh vol-create-as "$POOL" "$USB_VOL" "$BYTES" --format raw >/dev/null
|
|
virsh vol-upload --pool "$POOL" --sparse "$USB_VOL" "$USB_IMAGE"
|
|
log "done"
|