From 987ce076b008f5992c12defb32fb1fad35f63bc1 Mon Sep 17 00:00:00 2001 From: jbtrystram Date: Thu, 27 Jun 2024 11:20:04 +0200 Subject: [PATCH] overlay/15fcos: strip extraneous `version` field from aleph file This causes bootupctl to fails while parsing the file. The extra field was introduced in https://github.com/coreos/coreos-assembler/commit/c2d37f4005e0e7c98d24c5f561c149ab7fd4dfce then quickly reverted in https://github.com/coreos/coreos-assembler/pull/3686 Still, a couple of builds (39.20231204.1.0 and 39.20231204.2.1) went out with the change. Fixing this will allow bootupctl to function properly on nodes deployed with this version. This jq filter is idempotent so it's safe to run on all nodes. This should be removed after the next barrier release. Fixes https://github.com/coreos/fedora-coreos-tracker/issues/1724 --- .../lib/systemd/system-preset/45-fcos.preset | 4 ++++ .../system/coreos-fix-aleph-file.service | 14 +++++++++++ .../15fcos/usr/libexec/coreos-fix-aleph-file | 24 +++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 overlay.d/15fcos/usr/lib/systemd/system/coreos-fix-aleph-file.service create mode 100755 overlay.d/15fcos/usr/libexec/coreos-fix-aleph-file diff --git a/overlay.d/15fcos/usr/lib/systemd/system-preset/45-fcos.preset b/overlay.d/15fcos/usr/lib/systemd/system-preset/45-fcos.preset index 95d8087d2b..50ccc9dd1b 100644 --- a/overlay.d/15fcos/usr/lib/systemd/system-preset/45-fcos.preset +++ b/overlay.d/15fcos/usr/lib/systemd/system-preset/45-fcos.preset @@ -6,3 +6,7 @@ enable fwupd-refresh.timer # Check if wifi firmwares are missing when NetworkManager-wifi is installed # https://github.com/coreos/fedora-coreos-tracker/issues/1575 enable coreos-check-wireless-firmwares.service +# Strip extraneous field in aleph files to avoid bootupctl failing +# https://github.com/coreos/fedora-coreos-tracker/issues/1724 +enable coreos-fix-aleph-file.service + diff --git a/overlay.d/15fcos/usr/lib/systemd/system/coreos-fix-aleph-file.service b/overlay.d/15fcos/usr/lib/systemd/system/coreos-fix-aleph-file.service new file mode 100644 index 0000000000..3c1423b9c1 --- /dev/null +++ b/overlay.d/15fcos/usr/lib/systemd/system/coreos-fix-aleph-file.service @@ -0,0 +1,14 @@ +# Remove after the next barrier release +# https://github.com/coreos/fedora-coreos-tracker/issues/1724 + +[Unit] +Description=Remove extra attribute from aleph file + +[Service] +Type=oneshot +ExecStart=/usr/libexec/coreos-fix-aleph-file +RemainAfterExit=yes +MountFlags=slave + +[Install] +WantedBy=multi-user.target diff --git a/overlay.d/15fcos/usr/libexec/coreos-fix-aleph-file b/overlay.d/15fcos/usr/libexec/coreos-fix-aleph-file new file mode 100755 index 0000000000..f0ffe28526 --- /dev/null +++ b/overlay.d/15fcos/usr/libexec/coreos-fix-aleph-file @@ -0,0 +1,24 @@ +#!/usr/bin/bash + +# This script removes the extra `version` field +# which was shipped in a couple of builds +# To be removed after the next barrier release. +# see https://github.com/coreos/fedora-coreos-tracker/issues/1724 for more details + +set -euo pipefail + +ALEPH_FILE=/sysroot/.coreos-aleph-version.json + +if ! $(jq 'has("build")' ${ALEPH_FILE}); then + # nothing to fix + exit 0 +fi + +# remount /sysroot as writable +mount -o rw,remount /sysroot + +# remove field "build" +fixed_aleph=$(jq 'del(.build)' ${ALEPH_FILE}) + +# write back updated file with jq pretty-print +echo $fixed_aleph | jq > ${ALEPH_FILE}