Blame SOURCES/0006-Restore-functionality-of-remove-oldinstallonly.patch

878112
From ee670a94b7f53716ac8db4a7ee1723d886378d6f Mon Sep 17 00:00:00 2001
878112
From: Jaroslav Mracek <jmracek@redhat.com>
878112
Date: Fri, 22 Nov 2019 18:24:37 +0100
878112
Subject: [PATCH 1/3] Restore functionality of remove --oldinstallonly
878112
878112
Additionally it also starts to protect running kernel.
878112
878112
https://bugzilla.redhat.com/show_bug.cgi?id=1774666
878112
---
878112
 dnf/cli/commands/remove.py | 10 ++++++++--
878112
 1 file changed, 8 insertions(+), 2 deletions(-)
878112
878112
diff --git a/dnf/cli/commands/remove.py b/dnf/cli/commands/remove.py
878112
index f8059e4634..7b53dafcc4 100644
878112
--- a/dnf/cli/commands/remove.py
878112
+++ b/dnf/cli/commands/remove.py
878112
@@ -110,8 +110,14 @@ def run(self):
878112
 
878112
         if self.opts.oldinstallonly:
878112
             q = self.base.sack.query()
878112
-            instonly = self.base._get_installonly_query(q.installed()).latest(
878112
-                - self.base.conf.installonly_limit)
878112
+            instonly = self.base._get_installonly_query(q.installed()).latest(-1)
878112
+            # also remove running kernel from the set
878112
+            kernel = self.base.sack.get_running_kernel()
878112
+            if kernel is not None:
878112
+                running_installonly = instonly.filter(
878112
+                    epoch=kernel.epoch, version=kernel.version, release=kernel.release)
878112
+                if running_installonly:
878112
+                    instonly = instonly.difference(running_installonly)
878112
             if instonly:
878112
                 for pkg in instonly:
878112
                     self.base.package_remove(pkg)
878112
878112
From 031b424e3cf944f7585308ddda024ca6d2031c08 Mon Sep 17 00:00:00 2001
878112
From: Jaroslav Mracek <jmracek@redhat.com>
878112
Date: Fri, 6 Dec 2019 13:50:37 +0100
878112
Subject: [PATCH 2/3] Keep installed packages in upgrade transaction
878112
878112
In some cases missing installed packages could lead in an alternative
878112
decision.
878112
---
878112
 dnf/base.py | 8 +++++---
878112
 1 file changed, 5 insertions(+), 3 deletions(-)
878112
878112
diff --git a/dnf/base.py b/dnf/base.py
878112
index 8091ca0366..f9d31b3f34 100644
878112
--- a/dnf/base.py
878112
+++ b/dnf/base.py
878112
@@ -1975,17 +1975,19 @@ def package_upgrade(self, pkg):
878112
             return 0
878112
 
878112
     def _upgrade_internal(self, query, obsoletes, reponame, pkg_spec=None):
878112
-        installed = self.sack.query().installed()
878112
-        q = query.intersection(self.sack.query().filterm(name=[pkg.name for pkg in installed]))
878112
+        installed_all = self.sack.query().installed()
878112
+        q = query.intersection(self.sack.query().filterm(name=[pkg.name for pkg in installed_all]))
878112
+        installed_query = q.installed()
878112
         if obsoletes:
878112
             obsoletes = self.sack.query().available().filterm(
878112
-                obsoletes=q.installed().union(q.upgrades()))
878112
+                obsoletes=installed_query.union(q.upgrades()))
878112
             # add obsoletes into transaction
878112
             q = q.union(obsoletes)
878112
         if reponame is not None:
878112
             q.filterm(reponame=reponame)
878112
         q = self._merge_update_filters(q, pkg_spec=pkg_spec)
878112
         if q:
878112
+            q = q.available().union(installed_query.latest())
878112
             sltr = dnf.selector.Selector(self.sack)
878112
             sltr.set(pkg=q)
878112
             self._goal.upgrade(select=sltr)
878112
878112
From 7cba81e129944b8b610895d24df1c4dbaa23b6a1 Mon Sep 17 00:00:00 2001
878112
From: Jaroslav Mracek <jmracek@redhat.com>
878112
Date: Fri, 6 Dec 2019 13:51:11 +0100
878112
Subject: [PATCH 3/3] [doc] Update documentation of remove --oldinstallonly
878112
878112
---
878112
 doc/cli_vs_yum.rst  | 18 +++++++++---------
878112
 doc/command_ref.rst |  2 +-
878112
 2 files changed, 10 insertions(+), 10 deletions(-)
878112
878112
diff --git a/doc/cli_vs_yum.rst b/doc/cli_vs_yum.rst
878112
index 56945869c9..bb379ab03e 100644
878112
--- a/doc/cli_vs_yum.rst
878112
+++ b/doc/cli_vs_yum.rst
878112
@@ -387,15 +387,15 @@ Original YUM tool          New DNF command                                  Pack
878112
 
878112
 Detailed table for ``package-cleanup`` replacement:
878112
 
878112
-==================================       =====================================
878112
-``package-cleanup --dupes``              ``dnf repoquery --duplicates``
878112
-``package-cleanup --leaves``             ``dnf repoquery --unneeded``
878112
-``package-cleanup --orphans``            ``dnf repoquery --extras``
878112
-``package-cleanup --oldkernels``         ``dnf repoquery --installonly``
878112
-``package-cleanup --problems``           ``dnf repoquery --unsatisfied``
878112
-``package-cleanup --cleandupes``         ``dnf remove --duplicates``
878112
-``package-cleanup --oldkernels``         ``dnf remove --oldinstallonly``
878112
-==================================       =====================================
878112
+==========================================       ===============================================================
878112
+``package-cleanup --dupes``                      ``dnf repoquery --duplicates``
878112
+``package-cleanup --leaves``                     ``dnf repoquery --unneeded``
878112
+``package-cleanup --orphans``                    ``dnf repoquery --extras``
878112
+``package-cleanup --problems``                   ``dnf repoquery --unsatisfied``
878112
+``package-cleanup --cleandupes``                 ``dnf remove --duplicates``
878112
+``package-cleanup --oldkernels``                 ``dnf remove --oldinstallonly``
878112
+``package-cleanup --oldkernels --keep=2``        ``dnf remove $(dnf repoquery --installonly --latest-limit=-2)``
878112
+==========================================       ===============================================================
878112
 
878112
 =============================
878112
 yum-updateonboot and yum-cron
878112
diff --git a/doc/command_ref.rst b/doc/command_ref.rst
878112
index 7141fc2aae..134cc3d546 100644
878112
--- a/doc/command_ref.rst
878112
+++ b/doc/command_ref.rst
878112
@@ -1061,7 +1061,7 @@ Remove Command
878112
     dnf-shell sub-commands could help.
878112
 
878112
 ``dnf [options] remove --oldinstallonly``
878112
-    Removes old installonly packages, keeping only ``installonly_limit`` latest versions.
878112
+    Removes old installonly packages, keeping only latest versions and version of running kernel.
878112
 
878112
     There are also a few specific remove commands ``remove-n``, ``remove-na`` and ``remove-nevra``
878112
     that allow the specification of an exact argument in the NEVRA format.