From d1e51ebc0628aa530c4d85f6d0fa395893d85a21 Mon Sep 17 00:00:00 2001 From: David Cassany Date: Tue, 24 Sep 2024 14:50:21 +0200 Subject: [PATCH] Include arm-firwmare feature This commit introduces an arm-firmware feature adding the required after-* hooks to ensure the RPi firmware is copied to the EFI partition. It could be, eventually, extended to support other boards and it does not harm systems which are not including RPi firmware. Signed-off-by: David Cassany --- examples/green-rpi/01_rpi-firmware.yaml | 7 ------- examples/green-rpi/Dockerfile | 7 +------ .../system/oem/00_armfirmware.yaml | 20 +++++++++++++++++++ pkg/features/features.go | 5 +++++ 4 files changed, 26 insertions(+), 13 deletions(-) delete mode 100644 examples/green-rpi/01_rpi-firmware.yaml create mode 100644 pkg/features/embedded/arm-firmware/system/oem/00_armfirmware.yaml diff --git a/examples/green-rpi/01_rpi-firmware.yaml b/examples/green-rpi/01_rpi-firmware.yaml deleted file mode 100644 index 7c05dae0f0b..00000000000 --- a/examples/green-rpi/01_rpi-firmware.yaml +++ /dev/null @@ -1,7 +0,0 @@ -name: "Raspberry Pi post disk hook" -stages: - after-disk: - - ©firmware - name: "Copy firmware to EFI partition" - commands: - - cp -r /build/build/recovery.img.root/boot/vc/* /build/build/efi/ diff --git a/examples/green-rpi/Dockerfile b/examples/green-rpi/Dockerfile index 0aa4d16fcf7..4a731b38350 100644 --- a/examples/green-rpi/Dockerfile +++ b/examples/green-rpi/Dockerfile @@ -55,12 +55,7 @@ COPY --from=TOOLKIT /usr/bin/elemental /usr/bin/elemental RUN systemctl enable NetworkManager.service # Generate initrd with required elemental services -RUN elemental init -f && \ - kernel=$(ls /boot/Image-* | head -n1) && \ - if [ -e "$kernel" ]; then ln -sf "${kernel#/boot/}" /boot/vmlinuz; fi && \ - rm -rf /var/log/update* && \ - >/var/log/lastlog && \ - rm -rf /boot/vmlinux* +RUN elemental --debug init --force # Update os-release file with some metadata RUN echo IMAGE_REPO=\"${REPO}\" >> /etc/os-release && \ diff --git a/pkg/features/embedded/arm-firmware/system/oem/00_armfirmware.yaml b/pkg/features/embedded/arm-firmware/system/oem/00_armfirmware.yaml new file mode 100644 index 00000000000..419b35a64de --- /dev/null +++ b/pkg/features/embedded/arm-firmware/system/oem/00_armfirmware.yaml @@ -0,0 +1,20 @@ +name: "Set ARM Firmware" +stages: + after-install-chroot: + - &pifirmware + name: Raspberry PI post hook + if: '[ -d "/boot/vc" ]' + commands: + - cp -rf /boot/vc/* /run/elemental/efi/ + + after-upgrade-chroot: + - <<: *pifirmware + + after-reset-chroot: + - <<: *pifirmware + + after-disk: + - name: Raspberry PI post hook + if: '[ -d "/run/elemental-build/workingtree/boot/vc" ]' + commands: + - cp -rf /run/elemental-build/workingtree/boot/vc/* /run/elemental-build/efi/ \ No newline at end of file diff --git a/pkg/features/features.go b/pkg/features/features.go index ffebca0251a..3619e7c3c13 100644 --- a/pkg/features/features.go +++ b/pkg/features/features.go @@ -54,6 +54,7 @@ const ( FeatureCloudConfigEssentials = "cloud-config-essentials" FeatureBootAssessment = "boot-assessment" FeatureAutologin = "autologin" + FeatureArmFirmware = "arm-firmware" ) var ( @@ -67,6 +68,7 @@ var ( FeatureCloudConfigDefaults, FeatureCloudConfigEssentials, FeatureBootAssessment, + FeatureArmFirmware, } Default = []string{ @@ -79,6 +81,7 @@ var ( FeatureCloudConfigDefaults, FeatureCloudConfigEssentials, FeatureBootAssessment, + FeatureArmFirmware, } ) @@ -171,6 +174,8 @@ func Get(names []string) ([]*Feature, error) { features = append(features, New(name, units)) case FeatureAutologin: features = append(features, New(name, nil)) + case FeatureArmFirmware: + features = append(features, New(name, nil)) default: notFound = append(notFound, name) }