diff --git a/diskimage_builder/elements/centos/element-deps b/diskimage_builder/elements/centos/element-deps index bea6f34c9..24716bc98 100644 --- a/diskimage_builder/elements/centos/element-deps +++ b/diskimage_builder/elements/centos/element-deps @@ -1,5 +1,6 @@ cache-url redhat-common +redhat-reset-bls-entries rpm-distro source-repositories systemd-machine-id diff --git a/diskimage_builder/elements/redhat-reset-bls-entries/README.rst b/diskimage_builder/elements/redhat-reset-bls-entries/README.rst new file mode 100644 index 000000000..fc9d1e32c --- /dev/null +++ b/diskimage_builder/elements/redhat-reset-bls-entries/README.rst @@ -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. diff --git a/diskimage_builder/elements/centos/post-install.d/03-reset-bls-entries b/diskimage_builder/elements/redhat-reset-bls-entries/post-install.d/03-reset-bls-entries similarity index 81% rename from diskimage_builder/elements/centos/post-install.d/03-reset-bls-entries rename to diskimage_builder/elements/redhat-reset-bls-entries/post-install.d/03-reset-bls-entries index b6b347ce3..3f9c5846f 100755 --- a/diskimage_builder/elements/centos/post-install.d/03-reset-bls-entries +++ b/diskimage_builder/elements/redhat-reset-bls-entries/post-install.d/03-reset-bls-entries @@ -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 diff --git a/diskimage_builder/elements/rhel/element-deps b/diskimage_builder/elements/rhel/element-deps index 5745e00bf..28134abd2 100644 --- a/diskimage_builder/elements/rhel/element-deps +++ b/diskimage_builder/elements/rhel/element-deps @@ -1,5 +1,6 @@ cache-url redhat-common +redhat-reset-bls-entries rhel-common rpm-distro source-repositories diff --git a/diskimage_builder/elements/rhel/post-install.d/03-reset-bls-entries b/diskimage_builder/elements/rhel/post-install.d/03-reset-bls-entries deleted file mode 100755 index d4d5df5f5..000000000 --- a/diskimage_builder/elements/rhel/post-install.d/03-reset-bls-entries +++ /dev/null @@ -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=$(