mirror of
https://github.com/kairos-io/ipxe-dhcp.git
synced 2025-09-25 11:39:19 +00:00
Add Earthfile to build the iso
Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
build/
|
33
Earthfile
Normal file
33
Earthfile
Normal file
@@ -0,0 +1,33 @@
|
||||
VERSION 0.6
|
||||
|
||||
version:
|
||||
FROM alpine
|
||||
RUN apk add git
|
||||
|
||||
COPY . ./
|
||||
|
||||
RUN echo $(git describe --exact-match --tags || echo "v0.0.0-$(git log --oneline -n 1 | cut -d" " -f1)") > VERSION
|
||||
|
||||
SAVE ARTIFACT VERSION VERSION
|
||||
|
||||
iso:
|
||||
FROM ubuntu
|
||||
COPY . /build
|
||||
ARG ISO_NAME=ipxe-dhcp
|
||||
|
||||
RUN apt update
|
||||
RUN apt install -y -o Acquire::Retries=50 \
|
||||
mtools syslinux isolinux gcc-arm-none-eabi git make gcc liblzma-dev mkisofs xorriso
|
||||
# jq docker
|
||||
WORKDIR /build
|
||||
ARG ISO_NAME=${OS_ID}
|
||||
COPY +version/VERSION ./
|
||||
ARG VERSION=$(cat VERSION)
|
||||
|
||||
RUN git clone https://github.com/ipxe/ipxe
|
||||
|
||||
RUN cd ipxe/src && \
|
||||
sed -i 's/#undef\tDOWNLOAD_PROTO_HTTPS/#define\tDOWNLOAD_PROTO_HTTPS/' config/general.h && \
|
||||
make EMBED=/build/boot.ipxe
|
||||
SAVE ARTIFACT /build/ipxe/src/bin/ipxe.iso iso AS LOCAL build/${ISO_NAME}.iso
|
||||
SAVE ARTIFACT /build/ipxe/src/bin/ipxe.usb usb AS LOCAL build/${ISO_NAME}-usb.img
|
67
boot.ipxe
Normal file
67
boot.ipxe
Normal file
@@ -0,0 +1,67 @@
|
||||
#!ipxe
|
||||
#
|
||||
# This is the iPXE boot script that we embed into the iPXE binary.
|
||||
#
|
||||
# The entire reason for the existence of this script is that iPXE very
|
||||
# eagerly configures DHCP as soon as it gets a DHCP response, and
|
||||
# because of this it might miss the ProxyDHCP response that tells it
|
||||
# how to boot. In this situation, `autoboot` (the default command)
|
||||
# just fails and falls out of the PXE boot codepath, so we end up with
|
||||
# machines that sometimes fail to "catch" the network boot.
|
||||
#
|
||||
# This script implements what the ipxe documentation recommends, which
|
||||
# is to just retry the `dhcp` command a bunch until ipxe does see a
|
||||
# ProxyDHCP response. It's quite ugly, and a proper fix should really
|
||||
# get upstreamed to ipxe, but for right now, this works.
|
||||
|
||||
set attempts:int32 10
|
||||
set x:int32 0
|
||||
|
||||
set user-class pixiecore
|
||||
|
||||
# Try to get a filename from ProxyDHCP, retrying a couple of times if
|
||||
# we fail.
|
||||
:loop
|
||||
dhcp || goto nodhcp
|
||||
isset ${filename} || goto nobootconfig
|
||||
goto boot
|
||||
|
||||
:nodhcp
|
||||
echo No DHCP response, retrying (attempt ${x}/${attempts})
|
||||
goto retry
|
||||
|
||||
:nobootconfig
|
||||
echo No ProxyDHCP response, retrying (attempt ${x}/${attempts})
|
||||
goto retry
|
||||
|
||||
:retry
|
||||
iseq ${x} ${attempts} && goto fail ||
|
||||
inc x
|
||||
goto loop
|
||||
|
||||
# Got a filename from ProxyDHCP, that's the actual boot script,
|
||||
# off we go!
|
||||
:boot
|
||||
chain ${filename}
|
||||
|
||||
# Failure at this point probably means Pixiecore changed its mind
|
||||
# about whether this machine should be booted in the middle of the
|
||||
# boot cycle, so we had already handed off to iPXE, but now we're
|
||||
# no longer serving a boot script for it.
|
||||
#
|
||||
# Reboot the machine to restart the whole cycle (and presumably skip
|
||||
# PXE completely this time).
|
||||
#
|
||||
# It's also possible we just got horribly unlucky and the network
|
||||
# environment is such that we're consistently missing the ProxyDHCP
|
||||
# reply. That really sucks, so give people pointers to bug filing
|
||||
# here.
|
||||
:fail
|
||||
echo Failed to get a ProxyDHCP response after ${attempts} attempts
|
||||
echo
|
||||
echo If you are sure that Pixiecore is still trying to boot this machine,
|
||||
echo please file a bug at https://github.com/google/netboot .
|
||||
echo
|
||||
echo Rebooting in 5 seconds...
|
||||
sleep 5
|
||||
reboot
|
Reference in New Issue
Block a user