diff --git a/Earthfile b/Earthfile index f24f648..3b30dce 100644 --- a/Earthfile +++ b/Earthfile @@ -10,6 +10,9 @@ ARG ISO_NAME=$FLAVOR-immucore ARG GO_VERSION=1.18 ARG GOLINT_VERSION=v1.47.3 +# (DEBUGGING) Remove the cos immutable rootfs dracut module +ARG REMOVE_COS_MODULE + version: FROM alpine RUN apk add git @@ -55,7 +58,10 @@ build-immucore: COPY +version/VERSION ./ ARG VERSION=$(cat VERSION) WORKDIR /work - COPY . /work + COPY go.mod go.sum /work + COPY main.go /work + COPY --dir internal /work + COPY --dir pkg /work RUN CGO_ENABLED=0 go build -o immucore -ldflags "-X main.Version=$VERSION" SAVE ARTIFACT /work/immucore AS LOCAL build/immucore-$VERSION @@ -63,17 +69,24 @@ build-dracut: FROM $BASE_IMAGE COPY +version/VERSION ./ ARG VERSION=$(cat VERSION) - COPY . /work + ARG REMOVE_COS_MODULE COPY +build-immucore/immucore /usr/bin/immucore - WORKDIR /work - RUN cp -r dracut/28immucore /usr/lib/dracut/modules.d - RUN cp dracut/dracut.conf /etc/dracut.conf.d/10-immucore.conf + COPY --dir dracut/28immucore /usr/lib/dracut/modules.d/ + COPY dracut/dracut.conf /etc/dracut.conf.d/10-immucore.conf + IF [ "$REMOVE_COS_MODULE" != "" ] + RUN rm -Rf /usr/lib/dracut/modules.d/30cos-immutable-rootfs/ + RUN rm /etc/dracut.conf.d/02-cos-immutable-rootfs.conf + END RUN kernel=$(ls /lib/modules | head -n1) && \ dracut -f "/boot/initrd-${kernel}" "${kernel}" && \ ln -sf "initrd-${kernel}" /boot/initrd ARG INITRD=$(readlink -f /boot/initrd) SAVE ARTIFACT $INITRD Initrd AS LOCAL build/initrd-$VERSION +elemental: + FROM $OSBUILDER_IMAGE + SAVE ARTIFACT --keep-own /usr/bin/elemental elemental + image: FROM $BASE_IMAGE COPY +version/VERSION ./ @@ -82,6 +95,7 @@ image: COPY +build-dracut/Initrd $INITRD # For initrd use COPY +build-immucore/immucore /usr/bin/immucore + COPY +elemental/elemental /usr/bin/elemental RUN ln -s /usr/lib/systemd/systemd /init SAVE IMAGE $FLAVOR-immucore:$VERSION diff --git a/dracut/28immucore/module-setup.sh b/dracut/28immucore/module-setup.sh index a1c2531..e5e6bb5 100755 --- a/dracut/28immucore/module-setup.sh +++ b/dracut/28immucore/module-setup.sh @@ -24,8 +24,9 @@ install() { declare systemdutildir=${systemdutildir} declare systemdsystemunitdir=${systemdsystemunitdir} + # Add missing elemental binary, drop once we get yip lib inside immucore as its only needed to run the stages inst_multiple \ - immucore + immucore elemental inst_script "${moddir}/generator.sh" \ "${systemdutildir}/system-generators/immucore-generator" diff --git a/dracut/dracut.conf b/dracut/dracut.conf index 76ec9de..6f1a85b 100644 --- a/dracut/dracut.conf +++ b/dracut/dracut.conf @@ -1,3 +1,6 @@ -install_items+=" /usr/lib/systemd/system/cos-setup-initramfs.service /etc/systemd/system/initrd.target.requires/cos-setup-initramfs.service " -install_items+=" /usr/lib/systemd/system/cos-setup-rootfs.service /etc/systemd/system/initrd-fs.target.requires/cos-setup-rootfs.service " +# This services should be run from immucore directly, rootfs at start of immucore and initramfs once we mount everything, +# so at the end, just before we let init do the switch_root +# Note that initramfs run with RootDirectory=/sysroot +install_items+=" /etc/systemd/system/cos-setup-initramfs.service /etc/systemd/system/initrd.target.requires/cos-setup-initramfs.service " +install_items+=" /etc/systemd/system/cos-setup-rootfs.service /etc/systemd/system/initrd-fs.target.requires/cos-setup-rootfs.service " add_dracutmodules+=" immucore " \ No newline at end of file