dnf/backport-switch-install-remove-parts-of-swap-command.patch
chenhaxing 432b0f824d dnf:backport some patches
(cherry picked from commit 7c67dd07fb9d765156111461e728ff3f9bf3b84c)
2023-02-14 14:25:51 +08:00

41 lines
1.5 KiB
Diff

From 8f3f98ee710c9909f448c2d11143d9dffb919a46 Mon Sep 17 00:00:00 2001
From: Marek Blaha <mblaha@redhat.com>
Date: Tue, 4 Jan 2022 09:48:23 +0100
Subject: [PATCH] Switch install/remove parts of swap command (RhBug:2036434)
In case the install spec refers to a local rpm file the swap command
would fail with this error:
Error: Cannot add local packages, because transaction job already exists
Changing the order in which the installation and removal parts are
performed fixes the issue.
= changelog =
msg: Fix swap command to work with local rpm files correctly
type: bugfix
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2036434
Conflict:NA
Reference:https://github.com/rpm-software-management/dnf/commit/8f3f98ee710c9909f448c2d11143d9dffb919a46
---
dnf/cli/commands/swap.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/dnf/cli/commands/swap.py b/dnf/cli/commands/swap.py
index 5f23880..d44b3f4 100644
--- a/dnf/cli/commands/swap.py
+++ b/dnf/cli/commands/swap.py
@@ -58,5 +58,8 @@ class SwapCommand(commands.Command):
cmd.run()
def run(self):
- self._perform('remove', self.opts.remove_spec)
+ # The install part must be performed before the remove one because it can
+ # operate on local rpm files. Command line packages cannot be added
+ # to the sack once the goal is created.
self._perform('install', self.opts.install_spec)
+ self._perform('remove', self.opts.remove_spec)
--
2.27.0