mirror of
https://github.com/kairos-io/immucore.git
synced 2025-05-12 09:54:47 +00:00
Allow removing the cos-immutable-rootfs on dracut build
For easy debugging Also fixes missing stuff on dracut build to be able to still run the cos-setup-rootfs/initramfs services and adds the missing elemental binary to the initramfs. As we remove the cos-immutable-rootfs module for dracut then both the services and binary doesnt get included. Signed-off-by: Itxaka <itxaka@spectrocloud.com>
This commit is contained in:
parent
0580895067
commit
67fdfa8df5
24
Earthfile
24
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
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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 "
|
Loading…
Reference in New Issue
Block a user