Blob Blame History Raw
From ab986180f9c67d37b6fe826c0348cebaefe6d81a Mon Sep 17 00:00:00 2001
From: Igor Gnatenko <ignatenko@redhat.com>
Date: Fri, 29 Apr 2016 14:53:07 +0200
Subject: [PATCH] Revert "using ts.addReinstall for package reinstallation
 (RhBug:1071854)"

This reverts commit 516aad977e108df0f99c0bfc03a25b180888937f.

reinstall stuff implemented in rpm 4.12 which we don't have backported into epel7

Signed-off-by: Igor Gnatenko <ignatenko@redhat.com>
---
 dnf/base.py                   | 4 ++++
 dnf/cli/commands/reinstall.py | 1 +
 dnf/rpm/transaction.py        | 1 -
 dnf/transaction.py            | 6 +++---
 tests/test_transaction.py     | 3 ++-
 5 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/dnf/base.py b/dnf/base.py
index abb22ac..f56b4f6 100644
--- a/dnf/base.py
+++ b/dnf/base.py
@@ -1603,6 +1603,7 @@ class Base(object):
 
     def reinstall(self, pkg_spec, old_reponame=None, new_reponame=None,
                   new_reponame_neq=None, remove_na=False):
+        self._add_reinstall_rpm_probfilters()
         subj = dnf.subject.Subject(pkg_spec)
         q = subj.get_best_query(self.sack)
         installed_pkgs = [
@@ -1768,6 +1769,7 @@ class Base(object):
                     assert len(obsoleteds_) == 1
                     obsoleteds.append(obsoleteds_[0])
             assert len(news) == 1
+            self._add_reinstall_rpm_probfilters()
             self._transaction.add_reinstall(first(olds), news[0],
                                             obsoleteds)
 
@@ -1914,6 +1916,8 @@ class Base(object):
             myrepos += '\n'
         self.history.write_addon_data('config-repos', myrepos)
 
+    def _add_reinstall_rpm_probfilters(self):
+        self.rpm_probfilter.add(rpm.RPMPROB_FILTER_REPLACEPKG)
 
 def _msg_installed(pkg):
     name = ucd(pkg)
diff --git a/dnf/cli/commands/reinstall.py b/dnf/cli/commands/reinstall.py
index b0294c2..7b01345 100644
--- a/dnf/cli/commands/reinstall.py
+++ b/dnf/cli/commands/reinstall.py
@@ -75,6 +75,7 @@ class ReinstallCommand(commands.Command):
         local_pkgs = map(self.base.add_remote_rpm, filenames)
         results = map(self.base.package_reinstall, local_pkgs)
         done = functools.reduce(operator.or_, results, False)
+        self.base._add_reinstall_rpm_probfilters()
 
         # Reinstall packages.
         for pkg_spec in pkg_specs:
diff --git a/dnf/rpm/transaction.py b/dnf/rpm/transaction.py
index cfb4f61..117aec1 100644
--- a/dnf/rpm/transaction.py
+++ b/dnf/rpm/transaction.py
@@ -25,7 +25,6 @@ class TransactionWrapper(object):
                          'order',
                          'addErase',
                          'addInstall',
-                         'addReinstall',
                          'run',
                          'pgpImportPubkey',
                          'pgpPrtPkts',
diff --git a/dnf/transaction.py b/dnf/transaction.py
index 5cec604..1e2f584 100644
--- a/dnf/transaction.py
+++ b/dnf/transaction.py
@@ -186,9 +186,9 @@ class Transaction(object):
                 else:
                     ts.addInstall(hdr, tsi, 'i')
             elif tsi.op_type == REINSTALL:
-                # note: in rpm 4.12 there should not be set
-                # rpm.RPMPROB_FILTER_REPLACEPKG to work
-                ts.addReinstall(tsi.installed.header, tsi)
+                ts.addErase(tsi.erased.idx)
+                hdr = tsi.installed.header
+                ts.addInstall(hdr, tsi, 'i')
             elif tsi.op_type == UPGRADE:
                 hdr = tsi.installed.header
                 ts.addInstall(hdr, tsi, 'u')
diff --git a/tests/test_transaction.py b/tests/test_transaction.py
index a82dce2..c0aeb54 100644
--- a/tests/test_transaction.py
+++ b/tests/test_transaction.py
@@ -211,5 +211,6 @@ class RPMProbFilters(tests.support.TestCase):
         self.base._sack = tests.support.mock_sack('main')
         self.base._goal = dnf.goal.Goal(self.base.sack)
         self.base.reinstall("librita")
-        expected = rpm.rpm.RPMPROB_FILTER_OLDPACKAGE
+        expected = rpm.RPMPROB_FILTER_REPLACEPKG |\
+                   rpm.rpm.RPMPROB_FILTER_OLDPACKAGE
         self.base.ts.setProbFilter.assert_called_with(expected)
-- 
2.7.4