ostree-readonly-sysroot-migration: update old naming scheme boot entries

Instead of renaming the boot entries to the new naming scheme
update existing ones by making `ostree admin kargs edit-in-place`
to use the old naming scheme.

Resolves: #RHEL-58437
This commit is contained in:
Jonathan Lebon 2024-09-09 08:00:32 +02:00 committed by Miguel Martín
parent 22916589d6
commit 5a15e121bd
No known key found for this signature in database
GPG Key ID: 399C0C41974AC700
2 changed files with 8 additions and 14 deletions

View File

@ -4,16 +4,8 @@
set -euo pipefail
rename_boot_entries() {
local -r boot_entries="$(find /boot/loader/entries -name 'ostree-*-*\.conf')"
for boot_entry in ${boot_entries} ; do
new_boot_entry=$(echo "${boot_entry}" | sed -e 's/ostree-\([1-9]\+\).*/ostree-\1.conf/')
echo "Renaming ${boot_entry} to ${new_boot_entry}"
mv "${boot_entry}" "${new_boot_entry}"
done
}
main() {
# Used to condition execution of this unit at the systemd level
local -r stamp_file="/var/lib/.ostree-readonly-sysroot"
@ -28,10 +20,6 @@ main() {
exit 0
fi
# A new naming for bootboot entries was introduced in 2024.5
# version: https://github.com/ostreedev/ostree/pull/3206
[[ "${OSTREE_SYSROOT_OPTS:-none}" == *bootboot-naming-1* ]] || rename_boot_entries
local -r boot_entries="$(ls -A /boot/loader/entries/ | wc -l)"
# Ensure that we can read BLS entries to avoid touching systems where /boot
@ -55,6 +43,12 @@ main() {
# Some deployments are still missing the rw karg. Let's try to update them
if [[ "${boot_entries}" -ne "${rw_kargs_found}" ]]; then
# work around https://github.com/ostreedev/ostree/issues/2734#issuecomment-2353739450
stateroot=$(ls /ostree/deploy | head -n1)
if ls /boot/loader/entries/ostree-*-$stateroot.conf &>/dev/null; then
echo "Enabling bootloader naming workaround" 1>&2
export OSTREE_SYSROOT_OPTS=bootloader-naming-1
fi
ostree admin kargs edit-in-place --append-if-missing=rw || \
echo "Failed to edit kargs in place with ostree" 1>&2
fi

View File

@ -796,7 +796,7 @@ find %{buildroot} -name '*.la' -delete
- Move trusted.gpg.d to main runtime package, where it should be
* Fri Mar 07 2014 Colin Walters <walters@verbum.org> - 2014.2-2
- Depend on gpgv2
- Depend on gpgv2
- Resolves: #1073813
* Sat Mar 01 2014 Colin Walters <walters@verbum.org> - 2014.2-1