Refactor 03-reset-bls-entries into an element

This script is common across centos and rhel, so should really be in its
own element.

Change-Id: If8cbb38bd739169afcbe8e99325249f86f453bc5
Signed-off-by: Steve Baker <sbaker@redhat.com>
Assisted-By: Opencode - Claude Sonnet 4.6
This commit is contained in:
Steve Baker committed 2026-09-29 10:58:04 +13:00
1 parent 1af83478ce
commit d2e9aad18d
5 files changed
+27 -35

No files matched your search

@@ -1,5 +1,6 @@
cache-url
redhat-common
redhat-reset-bls-entries
rpm-distro
source-repositories
systemd-machine-id
@@ -0,0 +1,22 @@
========================
redhat-reset-bls-entries
========================
Renames Boot Loader Specification (BLS) entries in
``/boot/loader/entries/`` to use the machine-id set during the build,
as a workaround for https://bugzilla.redhat.com/show_bug.cgi?id=2032680.
Upstream qcow2 images for CentOS 9-stream and RHEL 9 ship with
pre-existing BLS entries named after the image's original machine-id.
When diskimage-builder sets a new machine-id via ``systemd-machine-id-setup``
(see the ``systemd-machine-id`` element), these entries are stale and
``grub2-mkconfig`` will not update them correctly. This element renames
each ``*.conf`` entry under ``/boot/loader/entries/`` to match the
build-time machine-id so that subsequent bootloader configuration steps
work as expected.
This element is a no-op on releases other than ``9-stream`` (CentOS)
and ``9`` (RHEL).
This element is pulled in automatically by the ``centos`` and ``rhel``
elements.
@@ -6,7 +6,9 @@ fi
set -eu
set -o pipefail
if [[ ! '9-stream' =~ ${DIB_RELEASE} ]]; then
# This workaround is only needed for releases that ship a qcow2 image
# with pre-existing BLS entries: centos 9-stream and rhel 9.
if [[ ! ${DIB_RELEASE} =~ ^(9-stream|9)$ ]]; then
exit 0
fi
@@ -1,5 +1,6 @@
cache-url
redhat-common
redhat-reset-bls-entries
rhel-common
rpm-distro
source-repositories
@@ -1,34 +0,0 @@
#!/bin/bash
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
if [[ ! '9' =~ ${DIB_RELEASE} ]]; then
exit 0
fi
# This is a workaround for the grub issue reported upstream with
# https://bugzilla.redhat.com/show_bug.cgi?id=2032680
# This renames the BLS entries from the upstream .qcow2 image in
# /boot/loader/entries with the current machine-id. This means that in the
# bootloader setup, grub2-mkconfig will update config options as required.
pushd /boot/loader/entries
machine_id=$(</etc/machine-id)
for entry in *.conf; do
new_entry=$(echo $entry | sed "s/^[a-f0-9]*/$machine_id/")
echo "renaming $entry to $new_entry for new machine-id"
if [[ $entry != $new_entry ]]; then
mv $entry $new_entry
fi
done
popd
echo "--- Show kernels ---"
grubby --info=ALL