Compare commits

..

No commits in common. 'c9' and 'c9-beta' have entirely different histories.
c9 ... c9-beta

2
.gitignore vendored

@ -1 +1 @@
SOURCES/libostree-2024.9.tar.xz
SOURCES/libostree-2024.4.tar.xz

@ -1 +1 @@
b37cd0e29ac24260c9082b3f62a9c3b21a46a505 SOURCES/libostree-2024.9.tar.xz
2aab75147722cc35e7bce341aa836fff81c6f176 SOURCES/libostree-2024.4.tar.xz

@ -0,0 +1,105 @@
From e47b37096343efa3bea8295f3f44c4dc90cc04e2 Mon Sep 17 00:00:00 2001
From: Colin Walters <walters@verbum.org>
Date: Tue, 27 Feb 2024 13:14:16 -0500
Subject: [PATCH] bootloader/grub2: Don't do anything if we have static configs
This builds on top of https://github.com/coreos/bootupd/pull/609/commits/fa9924e4fe403c3751392c041cd98614a2cc3611
(But in a very hacky way because we don't currently link to a JSON library)
Basically, bootupd supports injecting static configs, and this
is the currently least hacky way for us to detect this and understand
that we shouldn't try to run `grub2-mkconfig`.
A further patch I'd like to do here is also change the probing
logic to gracefully no-op if `grub2-mkconfig` doesn't exist,
but that has a bit more risk and involvement.
---
src/libostree/ostree-bootloader-grub2.c | 21 ++++++++++++
tests/kolainst/destructive/bootupd-static.sh | 36 ++++++++++++++++++++
2 files changed, 57 insertions(+)
create mode 100755 tests/kolainst/destructive/bootupd-static.sh
diff --git a/src/libostree/ostree-bootloader-grub2.c b/src/libostree/ostree-bootloader-grub2.c
index e1ee7868..cbe7605d 100644
--- a/src/libostree/ostree-bootloader-grub2.c
+++ b/src/libostree/ostree-bootloader-grub2.c
@@ -26,6 +26,11 @@
#include <string.h>
+// Written by bootupd
+#define BOOTUPD_CONFIG "boot/bootupd-state.json"
+// Horrible hack, to avoid including a JSON parser we just grep for this
+#define BOOTUPD_CONFIG_STATIC_JSON_FRAGMENT "\"static-configs\""
+
/* Maintain backwards compatibility with legacy GRUB
* installations that might rely on the -16 suffix
* for real-mode booting.
@@ -75,6 +80,22 @@ _ostree_bootloader_grub2_query (OstreeBootloader *bootloader, gboolean *out_is_a
{
OstreeBootloaderGrub2 *self = OSTREE_BOOTLOADER_GRUB2 (bootloader);
+ g_autoptr (GFile) bootupd_config
+ = g_file_resolve_relative_path (self->sysroot->path, BOOTUPD_CONFIG);
+ if (g_file_query_exists (bootupd_config, NULL))
+ {
+ g_autofree char *bootupd_config_contents = NULL;
+ if (!g_file_load_contents (bootupd_config, cancellable, &bootupd_config_contents, NULL, NULL,
+ error))
+ return glnx_prefix_error (error, "Failed to read bootupd config");
+ if (strstr (bootupd_config_contents, BOOTUPD_CONFIG_STATIC_JSON_FRAGMENT) != NULL)
+ {
+ g_debug ("Found static bootupd config");
+ *out_is_active = FALSE;
+ return TRUE;
+ }
+ }
+
/* Look for the BIOS path first */
if (g_file_query_exists (self->config_path_bios_1, NULL)
|| g_file_query_exists (self->config_path_bios_2, NULL))
diff --git a/tests/kolainst/destructive/bootupd-static.sh b/tests/kolainst/destructive/bootupd-static.sh
new file mode 100755
index 00000000..cf836813
--- /dev/null
+++ b/tests/kolainst/destructive/bootupd-static.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+set -xeuo pipefail
+
+. ${KOLA_EXT_DATA}/libinsttest.sh
+
+require_writable_sysroot
+prepare_tmpdir
+
+bootupd_state=/boot/bootupd-state.json
+mount -o remount,rw /boot
+if grep -qFe "\"static-configs\"" "${bootupd_state}"; then
+ echo "Host is using static configs already, overriding this"
+ jq 'del(.["static-configs"])' < "${bootupd_state}" > "${bootupd_state}".new
+ mv "${bootupd_state}.new" "${bootupd_state}"
+fi
+
+# Print the current value for reference, it's "none" on FCOS derivatives
+ostree config get sysroot.bootloader || true
+ostree config set sysroot.bootloader auto
+
+ostree admin deploy --stage "${host_commit}"
+systemctl stop ostree-finalize-staged.service
+used_bootloader=$(journalctl -u ostree-finalize-staged -o json MESSAGE_ID=dd440e3e549083b63d0efc7dc15255f1 | tail -1 | jq -r .OSTREE_BOOTLOADER)
+# We're verifying the legacy default now
+assert_streq "${used_bootloader}" "grub2"
+ostree admin undeploy 0
+
+# Now synthesize a bootupd config which uses static configs
+jq '. + {"static-configs": {}}' < "${bootupd_state}" > "${bootupd_state}".new
+mv "${bootupd_state}.new" "${bootupd_state}"
+ostree admin deploy --stage "${host_commit}"
+systemctl stop ostree-finalize-staged.service
+used_bootloader=$(journalctl -u ostree-finalize-staged -o json MESSAGE_ID=dd440e3e549083b63d0efc7dc15255f1 | tail -1 | jq -r .OSTREE_BOOTLOADER)
+assert_streq "${used_bootloader}" "none"
+
+echo "ok bootupd static"
--
2.41.0

@ -1,27 +1,26 @@
#!/bin/bash
# Update an existing system to use a read only sysroot
# and https://bugzilla.redhat.com/show_bug.cgi?id=2060976
set -euo pipefail
main() {
# Used to condition execution of this unit at the systemd level
local -r stamp_file="/var/lib/.ostree-readonly-sysroot"
if [[ -f "${stamp_file}" ]]; then
exit 0
fi
local -r ostree_sysroot_readonly="$(ostree config --repo=/sysroot/ostree/repo get "sysroot.readonly" &> /dev/null || echo "false")"
if [[ "${ostree_sysroot_readonly}" == "true" ]]; then
# Nothing to do
touch "${stamp_file}"
exit 0
fi
local -r boot_entries="$(ls -A /boot/loader/entries/ | wc -l)"
# Ensure that we can read BLS entries to avoid touching systems where /boot
# is not mounted
if [[ "${boot_entries}" -eq 0 ]]; then
@ -30,7 +29,7 @@ main() {
touch "${stamp_file}"
exit 0
fi
# Check if any existing deployment is still missing the rw karg
local rw_kargs_found=0
local count=0
@ -40,19 +39,13 @@ main() {
rw_kargs_found=$((rw_kargs_found + 1))
fi
done
# 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
# Re-check if any existing deployment is still missing the rw karg
rw_kargs_found=0
count=0
@ -63,7 +56,7 @@ main() {
fi
done
unset count
# If all deployments are good, then we can set the sysroot.readonly option
# in the ostree repo config
if [[ "${boot_entries}" -eq "${rw_kargs_found}" ]]; then
@ -72,10 +65,10 @@ main() {
touch "${stamp_file}"
exit 0
fi
# If anything else before failed, we will retry on next boot
echo "Will retry next boot" 1>&2
exit 0
}
main "${@}"

@ -7,12 +7,15 @@
Summary: Tool for managing bootable, immutable filesystem trees
Name: ostree
Version: 2024.9
Release: 1%{?dist}
Version: 2024.4
Release: 3%{?dist}
Source0: https://github.com/ostreedev/%{name}/releases/download/v%{version}/libostree-%{version}.tar.xz
Source1: ostree-readonly-sysroot-migration
Source2: ostree-readonly-sysroot-migration.service
# https://issues.redhat.com/browse/RHEL-27199
Patch0: 0001-bootloader-grub2-Don-t-do-anything-if-we-have-static.patch
License: LGPLv2+
URL: https://ostree.readthedocs.io/en/latest/
@ -26,7 +29,6 @@ BuildRequires: gtk-doc
BuildRequires: pkgconfig(zlib)
BuildRequires: pkgconfig(libcurl)
BuildRequires: openssl-devel
BuildRequires: pkgconfig(composefs)
# The tests still require soup
BuildRequires: pkgconfig(libsoup-2.4)
BuildRequires: libattr-devel
@ -49,7 +51,6 @@ Requires: dracut
Requires: /usr/bin/gpgv2
Requires: systemd-units
Requires: %{name}-libs%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}
Requires: composefs
%description
libostree is a shared library designed primarily for
@ -179,33 +180,6 @@ find %{buildroot} -name '*.la' -delete
%endif
%changelog
* Thu Nov 21 2024 Joseph Marrero <jmarrero@fedoraproject.org> - 2024.9-1
- Rebase to 2024.9
Resolves: #RHEL-68351
* Thu Oct 17 2024 Joseph Marrero <jmarrero@fedoraproject.org> - 2024.7-4
- Backport https://github.com/ostreedev/ostree/pull/3300
Resolves: #RHEL-62772
* Thu Sep 12 2024 Joseph Marrero <jmarrero@fedoraproject.org> - 2024.7-3
- Rebuild to pickup changes to ostree-readonly-sysroot-migration
Resolves: #RHEL-58437
* Wed Aug 14 2024 Joseph Marrero <jmarrero@fedoraproject.org> - 2024.7-2
- Backport https://github.com/ostreedev/ostree/pull/3281
Resolves: #RHEL-50680
* Fri Jul 26 2024 Joseph Marrero <jmarrero@fedoraproject.org> - 2024.7-1
- https://github.com/ostreedev/ostree/releases/tag/v2024.7
Resolves: #RHEL-50680
* Fri May 17 2024 Joseph Marrero <jmarrero@fedoraproject.org> - 2024.6-1
- https://github.com/ostreedev/ostree/releases/tag/v2024.6
Resolves: #RHEL-35886
* Thu Mar 14 2024 Colin Walters <walters@verbum.org> - 2024.5-2
- https://github.com/ostreedev/ostree/releases/tag/v2024.5
* Wed Feb 28 2024 Colin Walters <walters@verbum.org> - 2024.4-3
- Backport
https://github.com/ostreedev/ostree/pull/3205/commits/e47b37096343efa3bea8295f3f44c4dc90cc04e2
@ -806,7 +780,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

Loading…
Cancel
Save