public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Shawn W Dunn <sfalken@kalpadesktop.org>
To: git-commits@fedoraproject.org
Subject: [rpms/transactional-update] rawhide: Add Patches for compatibility with transactional tooling on Fedora
Date: Fri, 06 Nov 2026 15:56:38 GMT	[thread overview]
Message-ID: <179398059802.1.3453498003694740987.rpms-transactional-update-f01306e4c93b@fedoraproject.org> (raw)

A new commit has been pushed.

Repo   : rpms/transactional-update
Branch : rawhide
Commit : f01306e4c93bf451c1bbe87ac493257fc2eb9fb1
Author : Shawn W Dunn <sfalken@kalpadesktop.org>
Date   : 2026-11-05T21:10:43+00:00
Stats  : +615/-1 in 8 file(s)
URL    : https://src.fedoraproject.org/rpms/transactional-update/c/f01306e4c93bf451c1bbe87ac493257fc2eb9fb1?branch=rawhide

Log:
Add Patches for compatibility with transactional tooling on Fedora

---
diff --git a/0001-Only-bind-mount-var-lib-ca-certificates-if-it-exists.patch b/0001-Only-bind-mount-var-lib-ca-certificates-if-it-exists.patch
new file mode 100644
index 0000000..3070729
--- /dev/null
+++ b/0001-Only-bind-mount-var-lib-ca-certificates-if-it-exists.patch
@@ -0,0 +1,29 @@
+From 4e6d1e71cbe8db8658fe6d316f7e14a26f26bd7f Mon Sep 17 00:00:00 2001
+From: Shawn W Dunn <sfalken@kalpadesktop.org>
+Date: Mon, 12 Oct 2026 23:54:38 +0000
+Subject: [PATCH 1/2] Only bind mount /var/lib/ca-certificates if it exists
+
+All other optional /var/lib bind mounts are guarded by
+is_directory(), using libtukit on other platforms that don't
+provide it, causes mount failures
+---
+ lib/Transaction.cpp | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/lib/Transaction.cpp b/lib/Transaction.cpp
+index 6262da9..5b0ebe3 100644
+--- a/lib/Transaction.cpp
++++ b/lib/Transaction.cpp
+@@ -157,7 +157,8 @@ void Transaction::impl::snapMount() {
+     if (mntVar.isMount()) {
+         if (fs::is_directory("/var/lib/zypp"))
+             dirsToMount.push_back(std::make_unique<BindMount>("/var/lib/zypp"));
+-        dirsToMount.push_back(std::make_unique<BindMount>("/var/lib/ca-certificates"));
++        if (fs::is_directory("/var/lib/ca-certificates"))
++            dirsToMount.push_back(std::make_unique<BindMount>("/var/lib/ca-certificates"));
+         if (fs::is_directory("/var/lib/alternatives"))
+             dirsToMount.push_back(std::make_unique<BindMount>("/var/lib/alternatives"));
+         if (fs::is_directory("/var/lib/selinux"))
+-- 
+2.55.0
+

diff --git a/0002-Do-not-assume-the-snapshots-subvol-lives-below-at.patch b/0002-Do-not-assume-the-snapshots-subvol-lives-below-at.patch
new file mode 100644
index 0000000..4e36b39
--- /dev/null
+++ b/0002-Do-not-assume-the-snapshots-subvol-lives-below-at.patch
@@ -0,0 +1,100 @@
+From 7f924bbfd832f9d46adba0bae22b53e06c5d532e Mon Sep 17 00:00:00 2001
+From: Shawn W Dunn <sfalken@kalpadesktop.org>
+Date: Mon, 12 Oct 2026 23:57:39 +0000
+Subject: [PATCH 2/2] Don't assume the .snapshots subvol lives below "@"
+
+Having "@" hardcoded as the parent parent path makes libtukit
+non-portable to other distributions, as they can use different
+parent names, causing the scriupts to fail to find the snapshots
+or the parent.
+
+Matches an optional parent path component, and extracts the snapshot
+number by pattern, rather than by field position.
+---
+diff --git i/sbin/transactional-update.in w/sbin/transactional-update.in
+index 113b79d..2ad4215 100755
+--- i/sbin/transactional-update.in
++++ w/sbin/transactional-update.in
+@@ -935,7 +935,7 @@ if [ -n "${ZYPPER_ARG}" ] && [ "${DO_MIGRATION}" -eq 0 ] && [ ${ZYPPER_AUTO_IMPO
+     ZYPPER_ARG="--gpg-auto-import-keys ${ZYPPER_ARG}"
+ fi
+ 
+-BOOTED_SNAPSHOT_ID=$(grep subvol=/@/.snapshots/ /proc/mounts | grep "/ btrfs" | sed -e 's|.*.snapshots/\(.*\)/snapshot.*|\1|g')
++BOOTED_SNAPSHOT_ID=$(grep -E 'subvol=/([^,]*/)?\.snapshots/' /proc/mounts | grep "/ btrfs" | sed -e 's|.*.snapshots/\(.*\)/snapshot.*|\1|g')
+ CURRENT_SNAPSHOT_ID=$(findmnt --target /usr --raw --noheadings --output FSROOT --first-only --direction backward --types btrfs | sed -e 's|.*.snapshots/\(.*\)/snapshot.*|\1|g')
+ if [ -z "${CURRENT_SNAPSHOT_ID}" ]; then
+     CURRENT_SNAPSHOT_ID=$(findmnt --target / --raw --noheadings --output FSROOT --first-only --direction backward --types btrfs | sed -e 's|.*.snapshots/\(.*\)/snapshot.*|\1|g')
+diff --git i/snapper/50-etc w/snapper/50-etc
+index 9222b26..4522e8d 100755
+--- i/snapper/50-etc
++++ w/snapper/50-etc
+@@ -2,6 +2,11 @@
+ # SPDX-License-Identifier: GPL-2.0-or-later
+ # SPDX-FileCopyrightText: Copyright SUSE LLC
+ 
++# Path of the .snapshots subvolume as listed by "btrfs subvolume list", i.e.
++# including the optional name of the parent subvolume ("@/" on openSUSE,
++# but other distributions use different names or none at all).
++SNAPSHOTS_RE='([^ ]*/)?\.snapshots'
++
+ make_sure_snapshot_is_writable() {
+   isRO="$(btrfs property get "/.snapshots/${snapshot}/snapshot/" ro)"
+   if [ "${isRO}" = "ro=true" ]; then
+@@ -25,7 +30,7 @@ create_reference_etc() {
+   if [ -e "/.snapshots/${parent}/snapshot/etc/etc.syncpoint/transactional-update.comparewith" ] \
+      && [ "$(cat "/.snapshots/${parent}/snapshot/etc/etc.syncpoint/transactional-update.comparewith")" = "${current}" ]; then
+     # Snapshot first, then sync to avoid racing with changes to /etc in between.
+-    if btrfs subvolume list / | grep -Eq " path (@/.snapshots/${current}/snapshot/)?etc"; then
++    if btrfs subvolume list / | grep -Eq " path (${SNAPSHOTS_RE}/${current}/snapshot/)?etc"; then
+       btrfs subvolume snapshot "/etc" "/.snapshots/${snapshot}/snapshot/etc/etc.syncpoint"
+     else
+       # Old overlay systems still have to be supported because after first boot config management software may use --continue after a migration and before the reboot
+@@ -51,11 +56,11 @@ create_snapshot_post() {
+   snapshot="${1}"
+ 
+   # "Parent UUID" means which parent this snapshot was created from
+-  parentuuid="$(btrfs subvolume list -q / | grep -E " path @/.snapshots/${snapshot}/snapshot"$ | cut -f 9 -d ' ')"
++  parentuuid="$(btrfs subvolume list -q / | grep -E " path ${SNAPSHOTS_RE}/${snapshot}/snapshot"$ | cut -f 9 -d ' ')"
+   # "Parent" is the number of the parent snapshot (as shown by snapper)
+-  parent="$(btrfs subvolume list -u / | grep " uuid ${parentuuid} " | cut -f 9- -d ' ' | cut -f 3 -d '/')"
++  parent="$(btrfs subvolume list -u / | grep " uuid ${parentuuid} " | cut -f 9- -d ' ' | sed -n 's;.*\.snapshots/\([^/]*\)/snapshot.*;\1;p')"
+   # "Parent ID" means the parent subvolume in the file system tree
+-  parentid="$(btrfs subvolume list / | grep -E " path @/.snapshots/${parent}/snapshot"$ | cut -f 2 -d ' ')"
++  parentid="$(btrfs subvolume list / | grep -E " path ${SNAPSHOTS_RE}/${parent}/snapshot"$ | cut -f 2 -d ' ')"
+   # "Current" means the snapshot number of the currently running /usr
+   current=$(findmnt --target /usr --raw --noheadings --output FSROOT --first-only --direction backward --types btrfs | sed -e 's|.*.snapshots/\(.*\)/snapshot.*|\1|g')
+   if [ -z "${current}" ]; then
+@@ -71,7 +76,7 @@ create_snapshot_post() {
+   make_sure_snapshot_is_writable
+ 
+   rm -rf "/.snapshots/${snapshot}/snapshot/etc"
+-  if btrfs subvolume list / | grep -Eq " top level ${parentid} path (@/.snapshots/${parent}/snapshot/)?etc"; then
++  if btrfs subvolume list / | grep -Eq " top level ${parentid} path (${SNAPSHOTS_RE}/${parent}/snapshot/)?etc"; then
+     btrfs subvolume snapshot "/.snapshots/${parent}/snapshot/etc" "/.snapshots/${snapshot}/snapshot/etc"
+     create_reference_etc
+   else
+@@ -118,9 +123,9 @@ delete_snapshot_pre() {
+   snapshot="${1}"
+ 
+   # Only operate on snapshots with /etc as subvolume
+-  if btrfs subvolume list / | grep -q " @/.snapshots/${snapshot}/snapshot/etc"; then
++  if btrfs subvolume list / | grep -Eq " path ${SNAPSHOTS_RE}/${snapshot}/snapshot/etc"; then
+     make_sure_snapshot_is_writable
+-    if btrfs subvolume list / | grep -q " @/.snapshots/${snapshot}/snapshot/etc/etc.syncpoint"; then
++    if btrfs subvolume list / | grep -Eq " path ${SNAPSHOTS_RE}/${snapshot}/snapshot/etc/etc.syncpoint"; then
+       btrfs subvolume delete "/.snapshots/${snapshot}/snapshot/etc/etc.syncpoint"
+     fi
+     btrfs subvolume delete "/.snapshots/${snapshot}/snapshot/etc"
+diff --git i/systemd/prepare-nextroot-for-softreboot w/systemd/prepare-nextroot-for-softreboot
+index 3ac293c..a68a370 100755
+--- i/systemd/prepare-nextroot-for-softreboot
++++ w/systemd/prepare-nextroot-for-softreboot
+@@ -17,7 +17,7 @@ snapper --no-dbus --csvout list --columns default,active | grep -q 'yes,yes' &&
+ 
+ # Mount default subvolume into /run/nextroot
+ mkdir -p /run/nextroot
+-findmnt --noheadings / | awk '{ sub("subvol=/@/[^,]*", "", $4); sub("subvolid=[^,]*", "", $4); sub("\\[.*\\]", "", $2); system("mount -o \x27" $4 "\x27 " $2 " /run/nextroot") }'
++findmnt --noheadings / | awk '{ sub("subvol=/[^,]*", "", $4); sub("subvolid=[^,]*", "", $4); sub("\\[.*\\]", "", $2); system("mount -o \x27" $4 "\x27 " $2 " /run/nextroot") }'
+ 
+ # Perform all mounts marked with x-initrd.mount inside /run/nextroot
+ awk '$1 !~ /^#/ && $4 !~ /(\<|,)bind(\>|,)/ && $4 ~ /(\<|,)x-initrd\.mount(\>|,)/ {

diff --git a/0003-sync-etc-state-Report-files-that-can-not-be-synced.patch b/0003-sync-etc-state-Report-files-that-can-not-be-synced.patch
new file mode 100644
index 0000000..5ab089b
--- /dev/null
+++ b/0003-sync-etc-state-Report-files-that-can-not-be-synced.patch
@@ -0,0 +1,101 @@
+diff --git a/dracut/sync-etc-state.cpp b/dracut/sync-etc-state.cpp
+index 662d9c0..665f107 100644
+--- a/dracut/sync-etc-state.cpp
++++ b/dracut/sync-etc-state.cpp
+@@ -195,10 +195,11 @@ bool copy_xattrs(filesystem::path ref, filesystem::path target) {
+     return true;
+ }
+ 
+-int main(int argc, const char* argv[])
++static int run(int argc, const char* argv[])
+ {
+     bool dry_run = false;
+     bool keep_syncpoint = false;
++    int errors = 0;
+     int argpos = 1;
+     filesystem::path syncpoint = "/etc/etc.syncpoint";
+     filesystem::path currentdir = "/etc";
+@@ -325,6 +326,10 @@ int main(int argc, const char* argv[])
+     // Process generated list
+     if (!dry_run) {
+         for(auto it = DIFFTOCURRENT.begin(); it != DIFFTOCURRENT.end(); ++it) {
++            // A file that can not be copied or deleted (e.g. denied by the
++            // SELinux policy) must not abort the whole run with an uncaught
++            // exception: report it, carry on and fail at the end.
++            try {
+             if (it->second == SYNC_ACTIONS::RECURSIVE_SKIP) {
+                 auto potentialContains = DIFFTOCURRENT.lower_bound(it->first);
+                 if (it->first != potentialContains->first) {
+@@ -395,6 +400,17 @@ int main(int argc, const char* argv[])
+ 
+                 copy_xattrs(parentdir / it->first, currentdir / it->first);
+             }
++            } catch (const filesystem::filesystem_error &e) {
++                cerr << "Error while processing " << it->first << ": " << e.what() << endl;
++                errors++;
++            }
++        }
++
++        if (errors > 0) {
++            // Keep the syncpoint, so that it is still possible to see what
++            // has not been synced.
++            cerr << errors << " file(s) could not be synced." << endl;
++            return 1;
+         }
+ 
+         if (!keep_syncpoint) {
+@@ -404,3 +420,15 @@ int main(int argc, const char* argv[])
+ 
+     return 0;
+ }
++
++int main(int argc, const char* argv[])
++{
++    // Everything else (e.g. a directory that can not be read) ends up here
++    // instead of in std::terminate().
++    try {
++        return run(argc, argv);
++    } catch (const exception &e) {
++        cerr << "Error: " << e.what() << endl;
++        return 1;
++    }
++}
+diff --git a/tests/etc_changes.bats b/tests/etc_changes.bats
+index a7b27f8..9ae115b 100755
+--- a/tests/etc_changes.bats
++++ b/tests/etc_changes.bats
+@@ -458,3 +458,34 @@ debug() {
+ #	mv existing_dir_for_move aftersnap_new_existing_location
+ #	mv insnap_dir_for_move aftersnap_new_insnap_location
+ #fi
++
++@test "A file that can not be written must be reported, not abort the run" {
++	if [ "$(id -u)" = 0 ]; then
++		skip "root is not subject to file permissions"
++	fi
++
++	mkdir "${mockdir_old_etc}/sub" "${mockdir_new_etc}/sub" "${mockdir_syncpoint}/sub"
++	FILES=(sub/denied.txt sub/writable.txt)
++	for dir in "${mockdir_old_etc}" "${mockdir_new_etc}" "${mockdir_syncpoint}"; do
++		createFilesIn "${dir}" "${FILES[@]}"
++	done
++	syncTimestamps "${mockdir_old_etc}"/sub/* "${mockdir_new_etc}"/sub/* "${mockdir_syncpoint}"/sub/*
++
++	# Changed in the old snapshot only, so it has to be copied. The
++	# destination (and its reference) can not be overwritten.
++	chmod 444 "${mockdir_new_etc}/sub/denied.txt" "${mockdir_syncpoint}/sub/denied.txt"
++	echo "changed" > "${mockdir_old_etc}/sub/denied.txt"
++	echo "changed" > "${mockdir_old_etc}/sub/writable.txt"
++	touch -d "-5 seconds" "${mockdir_old_etc}/sub/denied.txt" "${mockdir_old_etc}/sub/writable.txt"
++
++	run $totest "${mockdir_old_etc}" "${mockdir_new_etc}" "${mockdir_syncpoint}"
++	echo "# Output: ${output}"
++
++	# No std::terminate (SIGABRT), but an error status and a message
++	[ "${status}" -eq 1 ]
++	[[ "${output}" == *"could not be synced"* ]]
++	# The files that can be written are synced nevertheless...
++	[ "$(cat "${mockdir_new_etc}/sub/writable.txt")" = "changed" ]
++	# ...and the syncpoint is kept
++	[ -e "${mockdir_syncpoint}/sub/denied.txt" ]
++}

diff --git a/0004-Snapper-Remove-the-snapshot-left-behind-by-a-failed-creation.patch b/0004-Snapper-Remove-the-snapshot-left-behind-by-a-failed-creation.patch
new file mode 100644
index 0000000..8e9e6f9
--- /dev/null
+++ b/0004-Snapper-Remove-the-snapshot-left-behind-by-a-failed-creation.patch
@@ -0,0 +1,99 @@
+diff --git i/lib/Snapshot/Snapper.cpp w/lib/Snapshot/Snapper.cpp
+index 8094866..18e2323 100644
+--- i/lib/Snapshot/Snapper.cpp
++++ w/lib/Snapshot/Snapper.cpp
+@@ -7,8 +7,10 @@
+ 
+ #include "Snapper.hpp"
+ #include "Exceptions.hpp"
++#include "Log.hpp"
+ #include "Util.hpp"
+ #include <regex>
++#include <set>
+ 
+ namespace TransactionalUpdate {
+ 
+@@ -17,7 +19,25 @@ namespace TransactionalUpdate {
+ std::unique_ptr<Snapshot> Snapper::create(std::string base, std::string description) {
+     if (! std::filesystem::exists(snapshotsDir() / base / "snapshot"))
+         throw std::invalid_argument{"Base snapshot '" + base + "' does not exist."};
+-    snapshotId = callSnapper("create --from " + base + " --read-write --print-number --description '" + description + "' --userdata 'transactional-update-in-progress=yes'");
++
++    // snapper creates the snapshot before its plugins run, so a failing plugin
++    // makes the call fail with the snapshot already in place, and nobody has
++    // its number. Remember the open transactions to find it again.
++    std::set<std::string> openBefore;
++    bool canCleanUp = true;
++    try {
++        openBefore = openTransactions(description);
++    } catch (const std::exception &) {
++        canCleanUp = false;
++    }
++
++    try {
++        snapshotId = callSnapper("create --from " + base + " --read-write --print-number --description '" + description + "' --userdata 'transactional-update-in-progress=yes'");
++    } catch (const ExecutionException &e) {
++        if (canCleanUp)
++            removeLeftovers(description, openBefore);
++        throw;
++    }
+     Util::rtrim(snapshotId);
+     return std::make_unique<Snapper>(snapshotId);
+ }
+@@ -191,6 +211,35 @@ void Snapper::cleanup(bool important) {
+ 
+ /* Helper methods */
+ 
++// Numbers of the open transactions with this description
++std::set<std::string> Snapper::openTransactions(const std::string &description) {
++    std::set<std::string> ids;
++    for (const auto &snap : getList("number,description,userdata")) {
++        auto number = snap.find("number");
++        auto desc = snap.find("description");
++        auto userdata = snap.find("userdata");
++        if (number == snap.end() || desc == snap.end() || userdata == snap.end())
++            continue;
++        if (desc->second == description && userdata->second.find("transactional-update-in-progress=yes") != std::string::npos)
++            ids.insert(number->second);
++    }
++    return ids;
++}
++
++// Delete the snapshots that appeared since "before", after a failed creation
++void Snapper::removeLeftovers(const std::string &description, const std::set<std::string> &before) {
++    try {
++        for (const auto &id : openTransactions(description)) {
++            if (before.count(id))
++                continue;
++            tulog.info("Removing snapshot " + id + ", which was left behind by the failed snapshot creation.");
++            callSnapper("delete " + id);
++        }
++    } catch (const std::exception &e) {
++        tulog.info("WARNING: Could not remove the snapshot left behind by the failed snapshot creation: ", e.what());
++    }
++}
++
+ std::string Snapper::callSnapper(std::string opts) {
+     std::string output;
+     try {
+diff --git i/lib/Snapshot/Snapper.hpp w/lib/Snapshot/Snapper.hpp
+index 98fdd90..932c5a4 100644
+--- i/lib/Snapshot/Snapper.hpp
++++ w/lib/Snapshot/Snapper.hpp
+@@ -11,6 +11,7 @@
+ #include "SnapshotManager.hpp"
+ #include "Snapshot.hpp"
+ #include <filesystem>
++#include <set>
+ #include <string>
+ 
+ namespace TransactionalUpdate {
+@@ -41,6 +42,8 @@ public:
+     std::string rollback(std::string id) override;
+ private:
+     std::string callSnapper(std::string);
++    std::set<std::string> openTransactions(const std::string &description);
++    void removeLeftovers(const std::string &description, const std::set<std::string> &before);
+ };
+ 
+ } // namespace TransactionalUpdate

diff --git a/0005-sync-etc-state-Fix-deleting-directories-removed-in-the-old-snapshot.patch b/0005-sync-etc-state-Fix-deleting-directories-removed-in-the-old-snapshot.patch
new file mode 100644
index 0000000..4e17558
--- /dev/null
+++ b/0005-sync-etc-state-Fix-deleting-directories-removed-in-the-old-snapshot.patch
@@ -0,0 +1,67 @@
+diff --git a/dracut/sync-etc-state.cpp b/dracut/sync-etc-state.cpp
+index 665f107..84579ee 100644
+--- a/dracut/sync-etc-state.cpp
++++ b/dracut/sync-etc-state.cpp
+@@ -285,11 +285,16 @@ static int run(int argc, const char* argv[])
+                 DIFFTOCURRENT.emplace(dir_entry, SYNC_ACTIONS::DELETE);
+                 if (filesystem::is_directory(currentdir / dir_entry)) {
+                     // If some file was changed or added within that directory in the new snapshot, then don't delete dir.
+-                    // First retrieve the lexicographically closest entry, then delete anything starting with that name.
+-                    auto potentialContains = DIFFTOCURRENT.lower_bound(dir_entry);
+-                    while (potentialContains->first.native().rfind(dir_entry.path().native(), 0) == 0) {
+-                        DIFFTOCURRENT[dir_entry] = SYNC_ACTIONS::SKIP;
+-                        potentialContains++;
++                    // The entries below a directory directly follow it in the map, so start behind the directory
++                    // itself and look at everything starting with "<dir>/" (and not at "<dir>2", for example).
++                    const std::string prefix = dir_entry.path().native() + "/";
++                    for (auto contained = DIFFTOCURRENT.upper_bound(dir_entry);
++                            contained != DIFFTOCURRENT.end() && contained->first.native().compare(0, prefix.size(), prefix) == 0;
++                            ++contained) {
++                        if (contained->second != SYNC_ACTIONS::DELETE) {
++                            DIFFTOCURRENT[dir_entry] = SYNC_ACTIONS::SKIP;
++                            break;
++                        }
+                     }
+                 }
+             }
+diff --git a/tests/etc_changes.bats b/tests/etc_changes.bats
+index 9ae115b..a8b8cc4 100755
+--- a/tests/etc_changes.bats
++++ b/tests/etc_changes.bats
+@@ -489,3 +489,36 @@ debug() {
+ 	# ...and the syncpoint is kept
+ 	[ -e "${mockdir_syncpoint}/sub/denied.txt" ]
+ }
++
++@test "Directory deleted in the old snapshot is deleted in the new one" {
++	for dir in "${mockdir_new_etc}" "${mockdir_syncpoint}"; do
++		mkdir "${dir}/deleted_dir"
++		createFile "${dir}/deleted_dir/file.txt"
++	done
++	mkdir "${mockdir_old_etc}/kept_dir"
++	for dir in "${mockdir_new_etc}" "${mockdir_syncpoint}"; do
++		mkdir "${dir}/kept_dir"
++	done
++	syncTimestamps "${mockdir_new_etc}"/*/* "${mockdir_new_etc}"/* "${mockdir_syncpoint}"/*/* "${mockdir_syncpoint}"/* "${mockdir_old_etc}"/*
++
++	run $totest "${mockdir_old_etc}" "${mockdir_new_etc}" "${mockdir_syncpoint}"
++	echo "# Output: ${output}"
++
++	[ "${status}" -eq 0 ]
++	[ ! -e "${mockdir_new_etc}/deleted_dir" ]
++	[ -d "${mockdir_new_etc}/kept_dir" ]
++}
++
++@test "Directory deleted in the old snapshot is kept if it got files in the new one" {
++	for dir in "${mockdir_new_etc}" "${mockdir_syncpoint}"; do
++		mkdir "${dir}/deleted_dir"
++	done
++	syncTimestamps "${mockdir_new_etc}"/* "${mockdir_syncpoint}"/*
++	createFile "${mockdir_new_etc}/deleted_dir/added_in_new_snapshot.txt"
++
++	run $totest "${mockdir_old_etc}" "${mockdir_new_etc}" "${mockdir_syncpoint}"
++	echo "# Output: ${output}"
++
++	[ "${status}" -eq 0 ]
++	[ -e "${mockdir_new_etc}/deleted_dir/added_in_new_snapshot.txt" ]
++}

diff --git a/0006-Reboot-Find-the-BLS-entry-in-the-snapshot-without-sdbootutil.patch b/0006-Reboot-Find-the-BLS-entry-in-the-snapshot-without-sdbootutil.patch
new file mode 100644
index 0000000..4fd1b9d
--- /dev/null
+++ b/0006-Reboot-Find-the-BLS-entry-in-the-snapshot-without-sdbootutil.patch
@@ -0,0 +1,173 @@
+diff --git i/lib/BlsEntry.cpp w/lib/BlsEntry.cpp
+index a7b0921..9e7d4df 100644
+--- i/lib/BlsEntry.cpp
++++ w/lib/BlsEntry.cpp
+@@ -3,8 +3,12 @@
+ 
+ #include "BlsEntry.hpp"
+ #include "Util.hpp"
++#include <algorithm>
++#include <cstring>
+ #include <fstream>
++#include <stdexcept>
+ #include <string>
++#include <vector>
+ 
+ namespace TransactionalUpdate {
+ 
+@@ -29,4 +33,71 @@ std::pair<std::string, std::string> BlsEntry::parse_bls_entry(std::string path)
+     return std::pair(kernel, initrd);
+ }
+ 
++namespace {
++
++// Value of the first line "<key><separator><value>" of a file; empty if there is none.
++std::string getValue(const std::filesystem::path &file, const std::string &key, const std::string &separators) {
++    std::ifstream is(file);
++    std::string line;
++    while (std::getline(is, line)) {
++        Util::trim(line);
++        if (line.compare(0, key.size(), key) != 0 || line.size() <= key.size())
++            continue;
++        if (separators.find(line[key.size()]) == std::string::npos)
++            continue;
++        std::string value = line.substr(key.size() + 1);
++        Util::trim(value);
++        return value;
++    }
++    return "";
++}
++
++}
++
++std::filesystem::path BlsEntry::find_default_entry(const std::filesystem::path &entries,
++                                                   const std::filesystem::path &grubenv) {
++    if (!std::filesystem::is_directory(entries))
++        throw std::runtime_error{"BLS entries directory " + entries.string() + " does not exist."};
++
++    // The entry that has been selected for the next boots
++    if (std::filesystem::exists(grubenv)) {
++        std::string saved = getValue(grubenv, "saved_entry", "=");
++        if (!saved.empty()) {
++            auto candidate = entries / (saved + ".conf");
++            if (std::filesystem::is_regular_file(candidate))
++                return candidate;
++        }
++    }
++
++    struct Candidate {
++        std::filesystem::path path;
++        std::string sortKey;
++        std::string version;
++    };
++    std::vector<Candidate> candidates;
++    for (const auto &file : std::filesystem::directory_iterator(entries)) {
++        if (!file.is_regular_file() || file.path().extension() != ".conf")
++            continue;
++        candidates.push_back({file.path(),
++                              getValue(file.path(), "sort-key", " \t"),
++                              getValue(file.path(), "version", " \t")});
++    }
++    if (candidates.empty())
++        throw std::runtime_error{"No BLS entries found in " + entries.string() + "."};
++
++    // Specification order: entries with a sort-key first, sort-key ascending,
++    // then version descending; the file name decides in the end.
++    std::sort(candidates.begin(), candidates.end(), [](const Candidate &a, const Candidate &b) {
++        if (a.sortKey.empty() != b.sortKey.empty())
++            return b.sortKey.empty();
++        if (a.sortKey != b.sortKey)
++            return a.sortKey < b.sortKey;
++        int cmp = strverscmp(a.version.c_str(), b.version.c_str());
++        if (cmp != 0)
++            return cmp > 0;
++        return a.path.filename() > b.path.filename();
++    });
++    return candidates.front().path;
++}
++
+ }
+diff --git i/lib/BlsEntry.hpp w/lib/BlsEntry.hpp
+index ea65f2e..4e428f7 100644
+--- i/lib/BlsEntry.hpp
++++ w/lib/BlsEntry.hpp
+@@ -8,6 +8,7 @@
+ #ifndef T_U_BLS_ENTRY_H
+ #define T_U_BLS_ENTRY_H
+ 
++#include <filesystem>
+ #include <string>
+ #include <utility>
+ 
+@@ -16,6 +17,20 @@ namespace TransactionalUpdate {
+ struct BlsEntry {
+     /// Parse a valid bls entry and return the pair of its kernel and initrd
+     static std::pair<std::string, std::string> parse_bls_entry(std::string path);
++
++    /**
++     * Find the entry in a directory of BLS entries that is booted by default
++     * @param entries Directory containing the *.conf files (loader/entries)
++     * @param grubenv GRUB environment file, may not exist
++     * @return Path of the entry file
++     * @throw std::runtime_error if there is no entry
++     *
++     * The entry GRUB has been told to boot (saved_entry in grubenv) is used if
++     * it exists, otherwise the one that sorts first according to the BLS
++     * specification (sort-key ascending, then version descending).
++     */
++    static std::filesystem::path find_default_entry(const std::filesystem::path &entries,
++                                                    const std::filesystem::path &grubenv);
+ };
+ 
+ } // namespace TransactionalUpdate
+diff --git i/lib/Reboot.cpp w/lib/Reboot.cpp
+index f5fd9dd..77a97e7 100644
+--- i/lib/Reboot.cpp
++++ w/lib/Reboot.cpp
+@@ -72,18 +72,34 @@ Reboot::Reboot(std::string method) {
+             auto initrd = std::string(defaultSnap->getRoot() / "boot" / "initrd");
+             if (!std::filesystem::exists(kernel)) {
+                 // If /boot/vmlinuz is not found, probably the system is using BLS entries
+-                // BLS entries are outside of snapshots
+-                auto efi = std::filesystem::path("/boot/efi");
+-                auto bls_entry_path = Util::exec("/usr/bin/sdbootutil list-entries --only-default");
+-                Util::trim(bls_entry_path);
+-                std::tie(kernel, initrd) =
+-                    BlsEntry::parse_bls_entry(efi / "loader" / "entries" / bls_entry_path);
+-                // relative_path strips the path of the root ("/"), otherwise the operator/
+-                // doesn't work and just returns the value of efi
+-                kernel = efi / std::filesystem::path(kernel).relative_path();
+-                Util::sanitize_quotes(kernel);
+-                initrd = efi / std::filesystem::path(initrd).relative_path();
+-                Util::sanitize_quotes(initrd);
++                if (std::filesystem::exists("/usr/bin/sdbootutil")) {
++                    // BLS entries are outside of snapshots
++                    auto efi = std::filesystem::path("/boot/efi");
++                    auto bls_entry_path = Util::exec("/usr/bin/sdbootutil list-entries --only-default");
++                    Util::trim(bls_entry_path);
++                    std::tie(kernel, initrd) =
++                        BlsEntry::parse_bls_entry(efi / "loader" / "entries" / bls_entry_path);
++                    // relative_path strips the path of the root ("/"), otherwise the operator/
++                    // doesn't work and just returns the value of efi
++                    kernel = efi / std::filesystem::path(kernel).relative_path();
++                    Util::sanitize_quotes(kernel);
++                    initrd = efi / std::filesystem::path(initrd).relative_path();
++                    Util::sanitize_quotes(initrd);
++                } else {
++                    // BLS entries on the root file system (e.g. grub2-bls): the
++                    // entries and the kernels are part of the snapshot
++                    auto root = defaultSnap->getRoot();
++                    auto entry = BlsEntry::find_default_entry(root / "boot" / "loader" / "entries",
++                                                              root / "boot" / "grub2" / "grubenv");
++                    tulog.debug("Using BLS entry ", entry.string());
++                    std::tie(kernel, initrd) = BlsEntry::parse_bls_entry(entry);
++                    if (kernel.empty() || initrd.empty())
++                        throw std::runtime_error{"BLS entry " + entry.string() + " has no kernel or initrd."};
++                    kernel = root / std::filesystem::path(kernel).relative_path();
++                    Util::sanitize_quotes(kernel);
++                    initrd = root / std::filesystem::path(initrd).relative_path();
++                    Util::sanitize_quotes(initrd);
++                }
+             }
+             tulog.info("Triggering reboot using systemctl kexec.");
+             command  = "kexec --kexec-syscall-auto -l '" + kernel + "' --initrd='" + initrd + "' --reuse-cmdline;";

diff --git a/0007-Make-Transaction-getBindDir-public.patch b/0007-Make-Transaction-getBindDir-public.patch
new file mode 100644
index 0000000..4492199
--- /dev/null
+++ b/0007-Make-Transaction-getBindDir-public.patch
@@ -0,0 +1,24 @@
+--- a/lib/Transaction.hpp
++++ b/lib/Transaction.hpp
+@@ -174,9 +174,19 @@
+      */
+     std::filesystem::path getRoot();
+ 
+-    friend class Plugins;
+-protected:
++    /**
++     * @brief Return the path the transaction's mount namespace is set up in
++     * @return bind directory
++     *
++     * Unlike getRoot() this directory has everything mounted that is needed to run programs
++     * in the new snapshot, such as /dev, /proc, /sys and /boot/efi. Callers that run package
++     * manager scriptlets (e.g. kernel-install) in a chroot should use this path.
++     *
++     * Only valid while the Transaction is open, like getRoot().
++     */
+     std::filesystem::path getBindDir();
++
++    friend class Plugins;
+ private:
+     class impl;
+     std::unique_ptr<impl> pImpl;

diff --git a/transactional-update.spec b/transactional-update.spec
index fe285ed..f443b0c 100644
--- a/transactional-update.spec
+++ b/transactional-update.spec
@@ -4,13 +4,31 @@
 
 Name:           transactional-update
 Version:        6.2.0
-Release:        1%{?dist}
+Release:        2%{?dist}
 Summary:        Transactional Updates with btrfs and snapshots
 
 License:        GPL-2.0-or-later and LGPL-2.1-or-later
 URL:            https://github.com/openSUSE/transactional-update
 Source0:        %{url}/archive/v%{version}/%{name}-%{version}.tar.gz
 
+# All patches listed below are from https://github.com/openSUSE/transactional-update/pull/179 except Patch0007: https://github.com/openSUSE/transactional-update/pull/184
+# Only bind mount /var/lib/ca-certificates if it exists (it does not on Fedora)
+Patch0001:      0001-Only-bind-mount-var-lib-ca-certificates-if-it-exists.patch
+# Do not assume the .snapshots subvolume lives below "@"
+Patch0002:      0002-Do-not-assume-the-snapshots-subvol-lives-below-at.patch
+# Report files that can not be synced instead of aborting with a core dump
+Patch0003:      0003-sync-etc-state-Report-files-that-can-not-be-synced.patch
+# Remove the snapshot a failed "snapper create" leaves behind
+Patch0004:      0004-Snapper-Remove-the-snapshot-left-behind-by-a-failed-creation.patch
+# Delete directories that were deleted in the old snapshot, without crashing
+Patch0005:      0005-sync-etc-state-Fix-deleting-directories-removed-in-the-old-snapshot.patch
+# Find the default BLS entry in the snapshot for kexec when sdbootutil is missing
+Patch0006:      0006-Reboot-Find-the-BLS-entry-in-the-snapshot-without-sdbootutil.patch
+# Make Transaction::getBindDir() public so that the libdnf5 plugin can run
+# package scriptlets in tukit's mount namespace
+Patch0007:      0007-Make-Transaction-getBindDir-public.patch
+
+
 BuildRequires:  autoconf
 BuildRequires:  autoconf-archive
 BuildRequires:  automake
@@ -211,6 +229,9 @@ rm -rf %{buildroot}%{_docdir}
 
 
 %changelog
+* Thu Nov 05 2026 Shawn W Dunn <sfalken@kalpadesktop.org> - 6.2.0-2
+- Add Patches for compatibility with transactional tooling on Fedora
+
 * Wed Nov 04 2026 Neal Gompa <ngompa@fedoraproject.org> - 6.2.0-1
 - Update to version 6.2.0
 - Resolves: rhbz#2449148

                 reply	other threads:[~2026-11-06 15:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179398059802.1.3453498003694740987.rpms-transactional-update-f01306e4c93b@fedoraproject.org \
    --to=sfalken@kalpadesktop.org \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox