🎨 Build alpine initrd during image building (#1924)

This commit is contained in:
Itxaka 2023-10-19 16:10:23 +02:00 committed by GitHub
parent 541dea6114
commit 60b59dadee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 19 deletions

View File

@ -431,11 +431,17 @@ base-image:
END
IF [ -e "/usr/bin/dracut" ]
RUN --no-cache kernel=$(ls /lib/modules | head -n1) && depmod -a "${kernel}"
IF [ -f "/usr/bin/dracut" ]
# Regenerate initrd if necessary
RUN --no-cache kernel=$(ls /lib/modules | head -n1) && depmod -a "${kernel}"
RUN --no-cache kernel=$(ls /lib/modules | head -n1) && dracut -f "/boot/initrd-${kernel}" "${kernel}" && ln -sf "initrd-${kernel}" /boot/initrd
END
IF [ -f "/sbin/mkinitfs" ]
# Proper config files with immucore and custom initrd should already be in there installled by framework
RUN --no-cache kernel=$(ls /lib/modules | head -n1) && mkinitfs -o /boot/initrd $kernel
END
END
# Set /boot/vmlinuz pointing to our kernel so kairos-agent can use it
@ -444,12 +450,6 @@ base-image:
RUN rm -rf /boot/initramfs-*
END
# Cleanup for alpine as this gets installed as a side-effect
# we already provide a /boot/initrd with the luet package
IF [ -e "/boot/initramfs-lts" ]
RUN rm /boot/initramfs-lts
END
IF [ ! -e "/boot/vmlinuz" ]
IF [ -e "/boot/vmlinuz-lts" ]
# Alpine provides the kernel under this name

View File

@ -80,22 +80,14 @@ flavors:
- common-packages
- kairos-toolchain
- openrc
- alpine-init
alpine-arm-rpi:
- common-packages
- kairos-toolchain
- openrc
- alpine-init-rpi
# See https://github.com/kairos-io/packages/pull/67 for rationale
alpine-init:
packages:
- distro-kernel/alpine
alpine-init-rpi:
packages:
- distro-kernel/alpine-rpi
openrc:
packages:
- init-svc/openrc
- initrd/alpine
systemd-base:
packages:
- init-svc/systemd
@ -147,9 +139,9 @@ repositories:
priority: 2
urls:
- "quay.io/kairos/packages"
reference: 20231018075943-repository.yaml
reference: 20231019093159-repository.yaml
- !!merge <<: *kairos
arch: arm64
urls:
- "quay.io/kairos/packages-arm64"
reference: 20231018075844-repository.yaml
reference: 20231019092540-repository.yaml

View File

@ -22,6 +22,7 @@ RUN apk --no-cache add \
coreutils \
cryptsetup \
curl \
device-mapper-udev \
dbus \
dmidecode \
dosfstools \
@ -29,8 +30,10 @@ RUN apk --no-cache add \
e2fsprogs-extra \
efibootmgr \
eudev \
eudev-hwids \
fail2ban \
findutils \
findmnt \
gawk \
gcompat \
gettext \
@ -76,6 +79,7 @@ RUN apk --no-cache add \
rbd-nbd \
rng-tools \
rsync \
sgdisk \
smartmontools \
squashfs-tools \
strace \
@ -88,6 +92,7 @@ RUN apk --no-cache add \
wireguard-tools \
wpa_supplicant \
xfsprogs \
xfsprogs-extra \
xz
###############################################################
@ -100,12 +105,15 @@ RUN apk --no-cache add \
bonding \
bridge \
rbd-nbd
RUN apk --no-cache add linux-lts --no-scripts
FROM common as rpicommon
COPY rpi/config.txt /boot/config.txt
FROM rpicommon AS rpi3
RUN apk --no-cache add linux-rpi --no-scripts # use --no-scripts to avoid building initramfs
FROM rpicommon AS rpi4
RUN apk --no-cache add linux-rpi4 --no-scripts # use --no-scripts to avoid building initramfs
###############################################################