dnf/SOURCES/0006-Restore-functionality-of-remove-oldinstallonly.patch
2021-09-10 09:03:27 +00:00

126 lines
5.8 KiB
Diff

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