From 8f3d7c38da21f391d41b6139d720a042c22ff53d Mon Sep 17 00:00:00 2001 From: Ben Vincent Date: Sat, 12 Jul 2025 18:14:48 +1000 Subject: [PATCH] feat: add custom ipxe bootloader - add rpm to manage tftpboot ipxe images for cobbler --- rpms/unkin-undionly-kpxe/20250712/release | 1 + rpms/unkin-undionly-kpxe/Dockerfile | 18 ++++++++ rpms/unkin-undionly-kpxe/resources/build.sh | 20 +++++++++ rpms/unkin-undionly-kpxe/resources/main.ipxe | 2 + rpms/unkin-undionly-kpxe/resources/nfpm.yaml | 44 +++++++++++++++++++ .../resources/preinstall.sh | 2 + 6 files changed, 87 insertions(+) create mode 100644 rpms/unkin-undionly-kpxe/20250712/release create mode 100644 rpms/unkin-undionly-kpxe/Dockerfile create mode 100755 rpms/unkin-undionly-kpxe/resources/build.sh create mode 100644 rpms/unkin-undionly-kpxe/resources/main.ipxe create mode 100644 rpms/unkin-undionly-kpxe/resources/nfpm.yaml create mode 100755 rpms/unkin-undionly-kpxe/resources/preinstall.sh diff --git a/rpms/unkin-undionly-kpxe/20250712/release b/rpms/unkin-undionly-kpxe/20250712/release new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/rpms/unkin-undionly-kpxe/20250712/release @@ -0,0 +1 @@ +1 diff --git a/rpms/unkin-undionly-kpxe/Dockerfile b/rpms/unkin-undionly-kpxe/Dockerfile new file mode 100644 index 0000000..f8cf216 --- /dev/null +++ b/rpms/unkin-undionly-kpxe/Dockerfile @@ -0,0 +1,18 @@ +FROM git.unkin.net/unkin/almalinux9-rpmbuilder:latest + +# Create output directory for RPMs +RUN mkdir -p /app/dist + +# Set working directory +WORKDIR /app + +ARG PACKAGE_RELEASE +ENV PACKAGE_RELEASE=${PACKAGE_RELEASE} +ARG PACKAGE_VERSION +ENV PACKAGE_VERSION=${PACKAGE_VERSION} + +# Copy nfpm.yaml from the context into the container +COPY resources /app/resources + +# Default command to build RPMs +CMD /app/resources/build.sh diff --git a/rpms/unkin-undionly-kpxe/resources/build.sh b/rpms/unkin-undionly-kpxe/resources/build.sh new file mode 100755 index 0000000..f447718 --- /dev/null +++ b/rpms/unkin-undionly-kpxe/resources/build.sh @@ -0,0 +1,20 @@ +#!/usr/bin/bash +# clone the repo +git clone https://github.com/ipxe/ipxe.git + +# change into it +cd ipxe/src + +# copy the main.pxi to embed +cp /app/resources/main.ipxe ./ + +# build images +make bin/undionly.kpxe EMBED=main.ipxe +make bin-x86_64-efi/ipxe.efi EMBED=main.ipxe + +# copy to /app +cp bin/undionly.kpxe /app/ +cp bin-x86_64-efi/ipxe.efi /app/ + +# build rpm +nfpm pkg --config /app/resources/nfpm.yaml --target /app/dist --packager rpm diff --git a/rpms/unkin-undionly-kpxe/resources/main.ipxe b/rpms/unkin-undionly-kpxe/resources/main.ipxe new file mode 100644 index 0000000..ac8b522 --- /dev/null +++ b/rpms/unkin-undionly-kpxe/resources/main.ipxe @@ -0,0 +1,2 @@ +#!ipxe +chain tftp://198.18.19.19/main.ipxe diff --git a/rpms/unkin-undionly-kpxe/resources/nfpm.yaml b/rpms/unkin-undionly-kpxe/resources/nfpm.yaml new file mode 100644 index 0000000..100ef73 --- /dev/null +++ b/rpms/unkin-undionly-kpxe/resources/nfpm.yaml @@ -0,0 +1,44 @@ +# nfpm.yaml + +name: unkin-undionly-kpxe +version: ${PACKAGE_VERSION} +release: ${PACKAGE_RELEASE} +arch: amd64 +platform: linux +section: default +priority: extra +description: "iPXE network bootloader" +maintainer: iPXE +homepage: https://github.com/ipxe/ipxe +license: GPL-2.0 license + +disable_globbing: false + +replaces: + - unkin-undionly-kpxe + +provides: + - undionly.kpxe + - ipxe.efi + +# Files to include in the package +contents: + - src: /app/ipxe.efi + dst: /var/lib/tftpboot/ipxe.efi + file_info: + mode: 0644 + owner: root + group: root + - src: /app/undionly.kpxe + dst: /var/lib/tftpboot/undionly.kpxe + file_info: + mode: 0644 + owner: root + group: root + +# Scripts to run during installation/removal (optional) +scripts: + preinstall: ./resources/preinstall.sh +# postinstall: ./scripts/postinstall.sh +# preremove: ./scripts/preremove.sh +# postremove: ./scripts/postremove.sh diff --git a/rpms/unkin-undionly-kpxe/resources/preinstall.sh b/rpms/unkin-undionly-kpxe/resources/preinstall.sh new file mode 100755 index 0000000..c7f0663 --- /dev/null +++ b/rpms/unkin-undionly-kpxe/resources/preinstall.sh @@ -0,0 +1,2 @@ +#!/usr/bin/bash +mkdir -p /var/lib/tftpboot