Fix dnf remove-n, install-n, and autoremove-n commands to only match package names
Resolves: RHEL-38470
This commit is contained in:
parent
7fc12434ea
commit
4770a44a00
138
0023-Limit-queries-to-nevra-forms-when-provided-by-comman.patch
Normal file
138
0023-Limit-queries-to-nevra-forms-when-provided-by-comman.patch
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
From 9870192e1acdfa6bb786faf8ae7f989795e52003 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jaroslav Mracek <jmracek@redhat.com>
|
||||||
|
Date: Wed, 22 May 2024 11:09:34 +0200
|
||||||
|
Subject: [PATCH 1/2] Limit queries to nevra forms when provided by command
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
Upstream commit: b3b9b3a48ca5efd9935f3f12bb65530a51ade09c
|
||||||
|
|
||||||
|
Command `dnf install-n <provide>` does not install only according
|
||||||
|
to package mame but still search in provides. The patch limits
|
||||||
|
searrch only to NEVRA forms for install, remove, autoremove,
|
||||||
|
and repoquery commands.
|
||||||
|
|
||||||
|
Resolves partially: https://issues.redhat.com/browse/RHEL-5747
|
||||||
|
Resolves: https://issues.redhat.com/browse/RHEL-38470
|
||||||
|
|
||||||
|
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
||||||
|
---
|
||||||
|
dnf/base.py | 14 ++++++++++++--
|
||||||
|
dnf/cli/commands/repoquery.py | 5 +++--
|
||||||
|
doc/api_base.rst | 6 +++++-
|
||||||
|
doc/command_ref.rst | 7 +++++--
|
||||||
|
4 files changed, 25 insertions(+), 7 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/dnf/base.py b/dnf/base.py
|
||||||
|
index b8237183..13222407 100644
|
||||||
|
--- a/dnf/base.py
|
||||||
|
+++ b/dnf/base.py
|
||||||
|
@@ -2061,9 +2061,14 @@ class Base(object):
|
||||||
|
def install(self, pkg_spec, reponame=None, strict=True, forms=None):
|
||||||
|
# :api
|
||||||
|
"""Mark package(s) given by pkg_spec and reponame for installation."""
|
||||||
|
+ kwargs = {'forms': forms, 'with_src': False}
|
||||||
|
+ if forms:
|
||||||
|
+ kwargs['with_nevra'] = True
|
||||||
|
+ kwargs['with_provides'] = False
|
||||||
|
+ kwargs['with_filenames'] = False
|
||||||
|
|
||||||
|
subj = dnf.subject.Subject(pkg_spec)
|
||||||
|
- solution = subj.get_best_solution(self.sack, forms=forms, with_src=False)
|
||||||
|
+ solution = subj.get_best_solution(self.sack, **kwargs)
|
||||||
|
|
||||||
|
if self.conf.multilib_policy == "all" or subj._is_arch_specified(solution):
|
||||||
|
q = solution['query']
|
||||||
|
@@ -2303,8 +2308,13 @@ class Base(object):
|
||||||
|
def remove(self, pkg_spec, reponame=None, forms=None):
|
||||||
|
# :api
|
||||||
|
"""Mark the specified package for removal."""
|
||||||
|
+ kwargs = {'forms': forms}
|
||||||
|
+ if forms:
|
||||||
|
+ kwargs['with_nevra'] = True
|
||||||
|
+ kwargs['with_provides'] = False
|
||||||
|
+ kwargs['with_filenames'] = False
|
||||||
|
|
||||||
|
- matches = dnf.subject.Subject(pkg_spec).get_best_query(self.sack, forms=forms)
|
||||||
|
+ matches = dnf.subject.Subject(pkg_spec).get_best_query(self.sack, **kwargs)
|
||||||
|
installed = [
|
||||||
|
pkg for pkg in matches.installed()
|
||||||
|
if reponame is None or
|
||||||
|
diff --git a/dnf/cli/commands/repoquery.py b/dnf/cli/commands/repoquery.py
|
||||||
|
index dcd7996f..e8ca38c5 100644
|
||||||
|
--- a/dnf/cli/commands/repoquery.py
|
||||||
|
+++ b/dnf/cli/commands/repoquery.py
|
||||||
|
@@ -447,9 +447,10 @@ class RepoQueryCommand(commands.Command):
|
||||||
|
if self.opts.key:
|
||||||
|
remote_packages = self._add_add_remote_packages()
|
||||||
|
|
||||||
|
- kwark = {}
|
||||||
|
+ kwark = {'with_provides': False}
|
||||||
|
if self.opts.command in self.nevra_forms:
|
||||||
|
kwark["forms"] = [self.nevra_forms[self.opts.command]]
|
||||||
|
+ kwark['with_filenames'] = False
|
||||||
|
pkgs = []
|
||||||
|
query_results = q.filter(empty=True)
|
||||||
|
|
||||||
|
@@ -460,7 +461,7 @@ class RepoQueryCommand(commands.Command):
|
||||||
|
for key in self.opts.key:
|
||||||
|
query_results = query_results.union(
|
||||||
|
dnf.subject.Subject(key, ignore_case=True).get_best_query(
|
||||||
|
- self.base.sack, with_provides=False, query=q, **kwark))
|
||||||
|
+ self.base.sack, query=q, **kwark))
|
||||||
|
q = query_results
|
||||||
|
|
||||||
|
if self.opts.recent:
|
||||||
|
diff --git a/doc/api_base.rst b/doc/api_base.rst
|
||||||
|
index 389b28ec..95d2d570 100644
|
||||||
|
--- a/doc/api_base.rst
|
||||||
|
+++ b/doc/api_base.rst
|
||||||
|
@@ -280,7 +280,11 @@
|
||||||
|
.. method:: install(pkg_spec, reponame=None, strict=True, forms=None)
|
||||||
|
|
||||||
|
Mark packages matching `pkg_spec` for installation.
|
||||||
|
- `reponame` can be a name of a repository or a list of repository names. If given, the selection of available packages is limited to packages from these repositories. If strict is set to False, the installation ignores packages with dependency solving problems. Parameter `forms` has the same meaning as in :meth:`dnf.subject.Subject.get_best_query`.
|
||||||
|
+ `reponame` can be a name of a repository or a list of repository names. If given, the selection of available
|
||||||
|
+ packages is limited to packages from these repositories. If strict is set to False, the installation ignores
|
||||||
|
+ packages with dependency solving problems. Parameter `forms` is list of pattern forms from `hawkey`_.
|
||||||
|
+ Leaving the parameter to ``None`` results in using a reasonable default list of forms. When forms is specified,
|
||||||
|
+ method will not match `pkg_spec` with provides and file provides.
|
||||||
|
|
||||||
|
.. method:: package_downgrade(pkg, strict=False)
|
||||||
|
|
||||||
|
diff --git a/doc/command_ref.rst b/doc/command_ref.rst
|
||||||
|
index ffb84407..e97c0d60 100644
|
||||||
|
--- a/doc/command_ref.rst
|
||||||
|
+++ b/doc/command_ref.rst
|
||||||
|
@@ -857,7 +857,8 @@ Install Command
|
||||||
|
are considered correct, the resulting package is picked simply by lexicographical order.
|
||||||
|
|
||||||
|
There are also a few specific install commands ``install-n``, ``install-na`` and
|
||||||
|
- ``install-nevra`` that allow the specification of an exact argument in the NEVRA format.
|
||||||
|
+ ``install-nevra`` that allow the specification of an exact argument in the NEVRA format. As a consequence, <spec>
|
||||||
|
+ will be not matched with provides and file provides.
|
||||||
|
|
||||||
|
See also :ref:`\configuration_files_replacement_policy-label`.
|
||||||
|
|
||||||
|
@@ -1190,7 +1191,8 @@ Remove Command
|
||||||
|
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.
|
||||||
|
+ that allow the specification of an exact argument in the NEVRA format. As a consequence, <spec>
|
||||||
|
+ will be not matched with provides and file provides.
|
||||||
|
|
||||||
|
Remove Examples
|
||||||
|
---------------
|
||||||
|
@@ -1254,6 +1256,7 @@ Repoquery Command
|
||||||
|
|
||||||
|
There are also a few specific repoquery commands ``repoquery-n``, ``repoquery-na`` and ``repoquery-nevra``
|
||||||
|
that allow the specification of an exact argument in the NEVRA format (does not affect arguments of options like --whatprovides <arg>, ...).
|
||||||
|
+ As a consequence, <spec> will be not matched with file provides.
|
||||||
|
|
||||||
|
Select Options
|
||||||
|
--------------
|
||||||
|
--
|
||||||
|
2.45.1
|
||||||
|
|
@ -0,0 +1,35 @@
|
|||||||
|
From b406aa778031abe550b84bdbdd6826ac3cf0866f Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jaroslav Mracek <jmracek@redhat.com>
|
||||||
|
Date: Thu, 23 May 2024 11:25:29 +0200
|
||||||
|
Subject: [PATCH 2/2] [doc] Remove provide of spec definition for repoquery
|
||||||
|
command
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
Upstream commit: f211e1a41a3d3180481e930836ee1a52a7a32487
|
||||||
|
|
||||||
|
Repoquery command never matched spec with provides.
|
||||||
|
|
||||||
|
Resolves: https://issues.redhat.com/browse/RHEL-38470
|
||||||
|
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
||||||
|
---
|
||||||
|
doc/command_ref.rst | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/doc/command_ref.rst b/doc/command_ref.rst
|
||||||
|
index e97c0d60..c419e7ed 100644
|
||||||
|
--- a/doc/command_ref.rst
|
||||||
|
+++ b/doc/command_ref.rst
|
||||||
|
@@ -1265,7 +1265,7 @@ Together with ``<package-file-spec>``, control what packages are displayed in th
|
||||||
|
packages to those matching the specification. All packages are considered if no ``<package-file-spec>`` is specified.
|
||||||
|
|
||||||
|
``<package-file-spec>``
|
||||||
|
- Package specification in the NEVRA format (name[-[epoch:]version[-release]][.arch]), a package provide or a file provide. See :ref:`Specifying Packages
|
||||||
|
+ Package specification in the NEVRA format (name[-[epoch:]version[-release]][.arch]) or a file provide. See :ref:`Specifying Packages
|
||||||
|
<specifying_packages-label>`.
|
||||||
|
|
||||||
|
``-a``, ``--all``
|
||||||
|
--
|
||||||
|
2.45.1
|
||||||
|
|
8
dnf.spec
8
dnf.spec
@ -69,7 +69,7 @@ It supports RPMs, modules and comps groups & environments.
|
|||||||
|
|
||||||
Name: dnf
|
Name: dnf
|
||||||
Version: 4.14.0
|
Version: 4.14.0
|
||||||
Release: 12%{?dist}
|
Release: 13%{?dist}
|
||||||
Summary: %{pkg_summary}
|
Summary: %{pkg_summary}
|
||||||
# For a breakdown of the licensing, see PACKAGE-LICENSING
|
# For a breakdown of the licensing, see PACKAGE-LICENSING
|
||||||
License: GPLv2+
|
License: GPLv2+
|
||||||
@ -97,6 +97,8 @@ Patch19: 0019-Update-documentation-of-history-userinstalled-comman.patch
|
|||||||
Patch20: 0020-automatic-Use-add_security_filters-not-_update_secur.patch
|
Patch20: 0020-automatic-Use-add_security_filters-not-_update_secur.patch
|
||||||
Patch21: 0021-remove-duplicates-when-no-duplicates-exit-with-0-RHE.patch
|
Patch21: 0021-remove-duplicates-when-no-duplicates-exit-with-0-RHE.patch
|
||||||
Patch22: 0022-remove-oldinstallonly-when-no-old-installonly-packag.patch
|
Patch22: 0022-remove-oldinstallonly-when-no-old-installonly-packag.patch
|
||||||
|
Patch23: 0023-Limit-queries-to-nevra-forms-when-provided-by-comman.patch
|
||||||
|
Patch24: 0024-doc-Remove-provide-of-spec-definition-for-repoquery-.patch
|
||||||
|
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
BuildRequires: cmake
|
BuildRequires: cmake
|
||||||
@ -385,6 +387,10 @@ popd
|
|||||||
%{python3_sitelib}/%{name}/automatic/
|
%{python3_sitelib}/%{name}/automatic/
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu May 23 2024 Petr Pisar <ppisar@redhat.com> - 4.14.0-13
|
||||||
|
- Fix dnf remove-n, install-n, and autoremove-n commands to only match package
|
||||||
|
names (RHEL-38470)
|
||||||
|
|
||||||
* Tue May 21 2024 Petr Pisar <ppisar@redhat.com> - 4.14.0-12
|
* Tue May 21 2024 Petr Pisar <ppisar@redhat.com> - 4.14.0-12
|
||||||
- Fix reporting nothing-to-do for "dnf remove --duplicates" (RHEL-6424)
|
- Fix reporting nothing-to-do for "dnf remove --duplicates" (RHEL-6424)
|
||||||
- Fix reporting nothing-to-do for "dnf remove --oldinstallonly" (RHEL-6424)
|
- Fix reporting nothing-to-do for "dnf remove --oldinstallonly" (RHEL-6424)
|
||||||
|
Loading…
Reference in New Issue
Block a user