54 lines
2.3 KiB
Bash
Executable File
54 lines
2.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Builds the answer-file ISOs into build/:
|
|
# virtio-vms.iso latest virtio-win drivers + unattend/vms-WIPE-DISK.xml (as autounattend.xml) + oobe-vms.ps1
|
|
# desktop.iso unattend/desktop-PROMPT-DISK.xml (as autounattend.xml) + oobe-desktop.ps1
|
|
# The virtio-win ISO is only downloaded again when a new release is published.
|
|
# Requires: curl, xorriso
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")"
|
|
|
|
VIRTIO_LATEST=https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/latest-virtio/virtio-win.iso
|
|
BUILD=build
|
|
STAGE=$BUILD/stage
|
|
# Joliet names so Windows sees oobe-*.ps1 and autounattend.xml unmangled (volume labels max 16 chars)
|
|
JOLIET=(-joliet on -compliance joliet_long_names)
|
|
|
|
# Root of the ISO as Windows reads it (Joliet, not Rock Ridge)
|
|
show_root() {
|
|
echo "== $1"
|
|
xorriso -report_about WARNING -read_fs norock -indev "$1" -lsl / 2>/dev/null | grep -E -i 'autounattend|oobe-|guest-tools' | awk '{print " ", $NF}'
|
|
}
|
|
|
|
mkdir -p "$BUILD"
|
|
|
|
# Resolve "latest" to the versioned file; Fedora's redirects drop to plain http, so force https
|
|
VIRTIO_URL=$(curl -fsSIL -o /dev/null -w '%{url_effective}' "$VIRTIO_LATEST" | sed 's#^http://#https://#')
|
|
VIRTIO_ISO=$BUILD/$(basename "$VIRTIO_URL")
|
|
if [[ -f $VIRTIO_ISO ]]; then
|
|
echo "Using cached $VIRTIO_ISO"
|
|
else
|
|
echo "Downloading $VIRTIO_URL"
|
|
curl -fL --retry 3 -o "$VIRTIO_ISO.part" "$VIRTIO_URL"
|
|
mv "$VIRTIO_ISO.part" "$VIRTIO_ISO"
|
|
fi
|
|
|
|
# a. VMs: virtio-win + VM answer file + oobe-vms.ps1
|
|
# Files are added to a copy of the original image rather than extracting and repacking it:
|
|
# virtio-win stores identical drivers once, and repacking would nearly double its size.
|
|
rm -f "$BUILD/virtio-vms.iso"
|
|
xorriso -report_about WARNING -indev "$VIRTIO_ISO" -outdev "$BUILD/virtio-vms.iso" "${JOLIET[@]}" -volid VIRTIO_VMS \
|
|
-map unattend/vms-WIPE-DISK.xml /autounattend.xml \
|
|
-map oobe-vms.ps1 /oobe-vms.ps1 \
|
|
-commit
|
|
|
|
# b. Desktops: desktop answer file + oobe-desktop.ps1, no virtio
|
|
rm -rf "$STAGE" "$BUILD/desktop.iso"
|
|
mkdir -p "$STAGE"
|
|
cp unattend/desktop-PROMPT-DISK.xml "$STAGE/autounattend.xml"
|
|
cp oobe-desktop.ps1 "$STAGE/"
|
|
xorriso -report_about WARNING -outdev "$BUILD/desktop.iso" "${JOLIET[@]}" -volid OOBE_DESKTOP -map "$STAGE" / -commit
|
|
rm -rf "$STAGE"
|
|
show_root "$BUILD/virtio-vms.iso"
|
|
show_root "$BUILD/desktop.iso"
|
|
ls -lh "$BUILD"/*.iso
|