richardphibel / rpms / dnf

Forked from rpms/dnf 2 years ago
Clone

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

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