Skip to content

Commit

Permalink
system-upgrade: Handle _execute errors
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-goode committed Feb 29, 2024
1 parent 26b500a commit 94c3d97
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions dnf5.spec
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,7 @@ config-manager, copr, and repoclosure commands.

%files -n dnf5-plugins -f dnf5-plugin-builddep.lang -f dnf5-plugin-changelog.lang -f dnf5-plugin-config-manager.lang -f dnf5-plugin-copr.lang -f dnf5-plugin-needs-restarting.lang -f dnf5-plugin-repoclosure.lang
%config %{_unitdir}/dnf5-offline-transaction.service
%config %{_unitdir}/dnf5-offline-transaction-cleanup.service
%{_libdir}/dnf5/plugins/*.so
%{_mandir}/man8/dnf5-builddep.8.*
%{_mandir}/man8/dnf5-copr.8.*
Expand Down
3 changes: 3 additions & 0 deletions dnf5/commands/offline/offline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,9 @@ void OfflineExecuteCommand::run() {

auto transaction = goal->resolve();
if (transaction.get_problems() != libdnf5::GoalProblem::NO_PROBLEM) {
std::cerr << "Failed to resolve transaction. This indicates some bigger problem, since the offline transaction "
"was already successfully resolved before. Was the cache at "
<< datadir << " modified?" << std::endl;
throw libdnf5::cli::GoalResolveError(transaction);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=Offline upgrade/transaction using DNF 5 failed
DefaultDependencies=no

[Service]
Type=oneshot
# Remove the symlink if it's still there, to protect against reboot loops.
ExecStart=/usr/bin/rm -fv /system-update
# If anything goes wrong, reboot back to the normal system.
ExecStart=/usr/bin/systemctl --no-block reboot
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ DefaultDependencies=no
Requires=sysinit.target
After=sysinit.target systemd-journald.socket system-update-pre.target
Before=poweroff.target reboot.target shutdown.target system-update.target
OnFailure=dnf5-offline-transaction-cleanup.service

[Service]
# We are done when the script exits, not before
Expand Down

0 comments on commit 94c3d97

Please sign in to comment.