Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions dnf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 8 additions & 2 deletions dnf/cli/commands/remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 9 additions & 9 deletions doc/cli_vs_yum.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion doc/command_ref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down