seedling: Generic arm64 isos (#1291)

🌱 Generate arm64 generic isos

 - Use latest osbuilder tools image as it contains fixes for arm64 isos
 - Add a small job to build an iso as part of the image arm workflow
 - Rework /boot/vmlinuz linking so it works on x86 and arm64

This also adds an iso-remote target for earthfile that allows to build
an iso from a remote rootfs in the shape of a docker artifact. This
allows for easy reproduce of isos based on existing artifacts instead of
having to rebuild the whole thing. You point to the artifact and it
spits an iso really fast. Also works with arm64 artifacts so we can
easily build a local arm64 iso for testing for pushed artifacts.

This PR makes it so generation of isos for arm64 works.

Signed-off-by: Itxaka <itxakaserrano@gmail.com>
This commit is contained in:
Itxaka 2023-04-15 17:06:22 +02:00
parent 9aa783f633
commit 3aa5ec4899

View File

@ -2,7 +2,8 @@ VERSION 0.6
FROM alpine
ARG VARIANT=core # core, lite, framework
ARG FLAVOR=opensuse-leap
ARG IMAGE=quay.io/kairos/${VARIANT}-${FLAVOR}:latest
ARG BASE_URL=quay.io/kairos
ARG IMAGE=${BASE_URL}/${VARIANT}-${FLAVOR}:latest
ARG ISO_NAME=kairos-${VARIANT}-${FLAVOR}
# renovate: datasource=docker depName=quay.io/luet/base
ARG LUET_VERSION=0.34.0
@ -353,7 +354,6 @@ base-image:
# no dracut on those flavors, do nothing
ELSE
# Regenerate initrd if necessary
RUN --no-cache kernel=$(ls /boot/vmlinuz-* | head -n1) && ln -sf "${kernel#/boot/}" /boot/vmlinuz
RUN --no-cache kernel=$(ls /lib/modules | head -n1) && dracut -f "/boot/initrd-${kernel}" "${kernel}" && ln -sf "initrd-${kernel}" /boot/initrd
RUN --no-cache kernel=$(ls /lib/modules | head -n1) && depmod -a "${kernel}"
END
@ -363,15 +363,23 @@ base-image:
RUN rm -rf /boot/initramfs-*
END
# Set /boot/vmlinuz pointing to our kernel so elemental-cli can use it
# https://github.com/kairos-io/elemental-cli/blob/23ca64435fedb9f521c95e798d2c98d2714c53bd/pkg/elemental/elemental.go#L553
IF [ ! -e "/boot/vmlinuz" ]
# If it's an ARM flavor, we want a symlink here from zImage/Image
IF [ -e "/boot/Image" ]
# Check that its not a symlink already or grub will fail!
IF [ -e "/boot/Image" ] && [ ! -L "/boot/Image" ]
RUN ln -sf Image /boot/vmlinuz
ELSE IF [ -e "/boot/zImage" ]
IF [ ! -L "/boot/zImage" ]
RUN ln -sf zImage /boot/vmlinuz
ELSE
RUN kernel=$(ls /lib/modules | head -n1) && \
ln -sf "${kernel#/boot/}" /boot/vmlinuz
RUN kernel=$(ls /boot/zImage-* | head -n1) && if [ -e "$kernel" ]; then ln -sf "${kernel#/boot/}" /boot/vmlinuz; fi
END
ELSE
# Debian has vmlinuz-VERSION
RUN kernel=$(ls /boot/vmlinuz-* | head -n1) && if [ -e "$kernel" ]; then ln -sf "${kernel#/boot/}" /boot/vmlinuz; fi
RUN kernel=$(ls /boot/Image-* | head -n1) && if [ -e "$kernel" ]; then ln -sf "${kernel#/boot/}" /boot/vmlinuz; fi
END
END
@ -419,6 +427,23 @@ iso:
SAVE ARTIFACT /build/$ISO_NAME.iso kairos.iso AS LOCAL build/$ISO_NAME.iso
SAVE ARTIFACT /build/$ISO_NAME.iso.sha256 kairos.iso.sha256 AS LOCAL build/$ISO_NAME.iso.sha256
# This target builds an iso using a remote docker image as rootfs instead of building the whole rootfs
# This should be really fast as it uses an existing image. This requires a pushed image from the +image target
# defaults to use the $IMAGE name (so ttl.sh/core-opensuse-leap:latest)
# you can override either the full thing by setting --IMG=docker:REPO/IMAGE:TAG
# or by --IMAGE=REPO/IMAGE:TAG
iso-remote:
ARG OSBUILDER_IMAGE
ARG ISO_NAME=${OS_ID}
ARG IMG=docker:$IMAGE
ARG overlay=overlay/files-iso
FROM $OSBUILDER_IMAGE
WORKDIR /build
COPY . ./
RUN /entrypoint.sh --name $ISO_NAME --debug build-iso --squash-no-compression --date=false $IMG --overlay-iso /build/${overlay} --output /build/
SAVE ARTIFACT /build/$ISO_NAME.iso kairos.iso AS LOCAL build/$ISO_NAME.iso
SAVE ARTIFACT /build/$ISO_NAME.iso.sha256 kairos.iso.sha256 AS LOCAL build/$ISO_NAME.iso.sha256
netboot:
ARG OSBUILDER_IMAGE
FROM $OSBUILDER_IMAGE