#!ipxe

# TODO: Automatically pick the latest version of boot2container
set b2c_version v0.10.0

set b2c_hostname mupuf-gateway

# Cache device selection: Add full-disk to the list if you are OK with the drive getting re-formated
set b2c_cache_device auto,use=existing|free-space

# How much swap storage to allocate
set b2c_swap 32G

# Extra kernel cmdline parameters to set: Something like `console=ttyS0,115200`
set kernel_extra_cmdline

# CI-tron image you want to boot, defaults to the latest one
set gateway_img_path registry.freedesktop.org/gfx-ci/ci-tron/gateway:latest


# Compute the kernel and initramfs base URLs
set linux_arch {{ client.cpu_arch.linux }}
set go_arch {{ client.cpu_arch.go }}
set b2c_url_path gfx-ci/boot2container/-/releases/${b2c_version}/downloads/initramfs.linux_${go_arch}.cpio.xz
set kernel_url_path gfx-ci/boot2container/-/releases/${b2c_version}/downloads/linux-${linux_arch}

# Safe URLs, but probably much slower than the Freedesktop.org-CDN-provided ones defined below
set b2c_url https://demo.ci-tron.dev/glfdo/${b2c_url_path}
set kernel_url https://demo.ci-tron.dev/glfdo/${kernel_url_path}

# Comment the following lines if your gateway fails to boot due to SSL issues so that the above URLs are used
set b2c_url https://gitlab.freedesktop.org/${b2c_url_path}
set kernel_url https://gitlab.freedesktop.org/${kernel_url_path}

kernel ${kernel_url} initrd=initrd.magic b2c.hostname=${b2c_hostname} b2c.ntp_peer=auto b2c.cache_device="${b2c_cache_device}" b2c.swap=${b2c_swap} {% if secrets_url %}b2c.extra_args_url="{{ secrets_url }}"{% endif %} b2c.pipefail b2c.run="-ti --pull=always -v ci-tron-cache:/cache -v ci-tron-config-a8cda59226450219841ff12bba8bc99c3765edda:/config -v /dev:/dev -v /lib/modules:/lib/modules -v /lib/firmware:/lib/firmware docker://${gateway_img_path}" b2c.shutdown_cmd="reboot -f" net.ifnames=0 panic=10 ${kernel_extra_cmdline}

initrd ${b2c_url}

initrd ${kernel_url}.depmod.cpio.xz
{% if client.cpu_arch.linux == "x86_64" -%}
initrd ${kernel_url}.ucode.cpio  # For Intel platforms, remove for AMD for faster boot
initrd ${kernel_url}.gpu.cpio    # For accelerated rendering on AMD, Intel, and NVIDIA
{%- endif %}
initrd ${kernel_url}.wifi.cpio

boot