Files
lite-win/Makefile
jacob.b.nelson2 e4741ccc96 Initial commit: Packer + QEMU/KVM Windows 11 minimal VM
Fully unattended Windows 11 Pro build using Autounattend.xml, swtpm
for TPM 2.0 emulation, and VirtIO drivers. Five PowerShell provisioners
strip bloatware, telemetry, unused services, and apply performance tuning
for a resource-constrained host. Output is a compressed QCOW2 image.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17 19:31:18 -05:00

49 lines
1.5 KiB
Makefile

VIRTIO_VERSION := 0.1.266
VIRTIO_ISO_URL := https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-$(VIRTIO_VERSION)-1/virtio-win-$(VIRTIO_VERSION).iso
VIRTIO_ISO := virtio-win.iso
VAR_FILE := variables.pkrvars.hcl
.PHONY: all build init validate clean distclean help
all: build
## Install Packer QEMU plugin
init:
packer init .
## Download VirtIO drivers ISO (~500 MB, one-time)
$(VIRTIO_ISO):
curl -L --progress-bar -o $(VIRTIO_ISO) $(VIRTIO_ISO_URL)
virtio-iso: $(VIRTIO_ISO)
## Validate the Packer template (does not run the build)
validate: $(VIRTIO_ISO)
SWTPM_SOCK=/tmp/dummy-validate \
packer validate -var "swtpm_sock=/tmp/dummy" -var-file=$(VAR_FILE) .
## Build the VM image (starts swtpm, runs Packer, cleans up)
build: init $(VIRTIO_ISO)
@test -f $(VAR_FILE) || { \
echo "ERROR: $(VAR_FILE) not found."; \
echo " cp variables.pkrvars.hcl.example $(VAR_FILE) and fill it in."; \
exit 1; }
bash build.sh $(VAR_FILE)
## Remove build output (keeps downloaded ISOs)
clean:
rm -rf output/
## Remove build output and downloaded ISOs
distclean: clean
rm -f $(VIRTIO_ISO)
help:
@echo "Targets:"
@echo " build Build the VM image (default)"
@echo " validate Validate Packer config without building"
@echo " init Install Packer plugins"
@echo " virtio-iso Download the VirtIO drivers ISO"
@echo " clean Remove build output"
@echo " distclean Remove build output + downloaded ISOs"