archrelease: copy trunk to community-x86_64
[ArchLinux/community.git] / ipxe / trunk / run_ipxe
blob7ee44fdd18cfe24dc04983cfe4ed600ea8855742
1 #!/usr/bin/env bash
3 set -euo pipefail
5 ovmf_code=/usr/share/edk2-ovmf/x64/OVMF_CODE.fd
6 ovmf_vars=/usr/share/edk2-ovmf/x64/OVMF_VARS.fd
7 ipxe_image="${1}"
9 if [[ ! -f "${ovmf_code}" ]]; then
10 printf "ERROR: %s is missing, install the edk2-ovmf package." "${ovmf_code}" >&2
11 exit 1
13 if [[ ! -f "${ovmf_vars}" ]]; then
14 printf "ERROR: %s is missing, install the edk2-ovmf package." "${ovmf_vars}" >&2
15 exit 1
17 if [[ ! -f "${ipxe_image}" ]]; then
18 echo "ERROR: No IPXE image to run provided as first argument." >&2
19 exit 1
22 workdir=$(mktemp -d --tmpdir run_ipxe.XXXXXX)
23 trap 'rm -rf $workdir' EXIT INT TERM QUIT
25 cd "${workdir}"
26 cp "${ovmf_vars}" efivars
27 mkdir -p ./fat/EFI/Boot/
28 cp "${ipxe_image}" ./fat/EFI/Boot/bootx64.efi
30 exec qemu-system-x86_64 \
31 -boot order=d,menu=on,reboot-timeout=5000 \
32 -m "size=3072,slots=0,maxmem=$((3072*1024*1024))" \
33 -k en-us \
34 -name ipxe,process=ipxe_0 \
35 -device virtio-net-pci,romfile=,netdev=net0 \
36 -netdev user,ipv4=on,id=net0 \
37 -drive if=pflash,format=raw,unit=0,readonly=on,file="${ovmf_code}" \
38 -drive if=pflash,format=raw,unit=1,file=efivars \
39 -usb \
40 -enable-kvm \
41 -serial stdio \
42 -drive if=none,id=usb-fat,format=raw,file=fat:rw:./fat \
43 -device usb-storage,drive=usb-fat \
44 -vga virtio