dcavalca / rpms / dnf

Forked from rpms/dnf 2 years ago
Clone

Blame SOURCES/0002-Add---nobest-option.patch

0f2fcc
From fd935bb941c0ce0df3aa628fc10f43699ee50c66 Mon Sep 17 00:00:00 2001
0f2fcc
From: Jaroslav Mracek <jmracek@redhat.com>
0f2fcc
Date: Mon, 4 Feb 2019 10:04:49 +0100
0f2fcc
Subject: [PATCH] Add --nobest option
0f2fcc
0f2fcc
---
0f2fcc
 dnf/cli/main.py          | 24 +++++++++++++++++++-----
0f2fcc
 dnf/cli/option_parser.py |  9 +++++----
0f2fcc
 doc/command_ref.rst      |  3 +++
0f2fcc
 3 files changed, 27 insertions(+), 9 deletions(-)
0f2fcc
0f2fcc
diff --git a/dnf/cli/main.py b/dnf/cli/main.py
0f2fcc
index 519c553..d534da9 100644
0f2fcc
--- a/dnf/cli/main.py
0f2fcc
+++ b/dnf/cli/main.py
0f2fcc
@@ -123,13 +123,27 @@ def cli_run(cli, base):
0f2fcc
             ret = resolving(cli, base)
0f2fcc
         except dnf.exceptions.DepsolveError as e:
0f2fcc
             ex_Error(e)
0f2fcc
+            msg = ""
0f2fcc
             if not cli.demands.allow_erasing and base._goal.problem_conflicts(available=True):
0f2fcc
-                msg = _("(try to add '%s' to command line to replace conflicting "
0f2fcc
-                        "packages") % "--allowerasing"
0f2fcc
-                if cli.base.conf.strict:
0f2fcc
-                    msg += _(" or '%s' to skip uninstallable packages)") % "--skip-broken"
0f2fcc
+                msg += _("(try to add '%s' to command line to replace conflicting "
0f2fcc
+                         "packages") % "--allowerasing"
0f2fcc
+            if cli.base.conf.strict:
0f2fcc
+                if not msg:
0f2fcc
+                    msg += "(try to add "
0f2fcc
                 else:
0f2fcc
-                    msg += ")"
0f2fcc
+                    msg += " or "
0f2fcc
+                msg += _("'%s' to skip uninstallable packages") % "--skip-broken"
0f2fcc
+            if cli.base.conf.best:
0f2fcc
+                opt = cli.base.conf._get_option("best")
0f2fcc
+                prio = opt._get_priority()
0f2fcc
+                if prio <= dnf.conf.PRIO_MAINCONFIG:
0f2fcc
+                    if not msg:
0f2fcc
+                        msg += "(try to add "
0f2fcc
+                    else:
0f2fcc
+                        msg += " or "
0f2fcc
+                    msg += _("'%s' to use not only best candidate packages") % "--nobest"
0f2fcc
+            if msg:
0f2fcc
+                msg += ")"
0f2fcc
                 logger.info(msg)
0f2fcc
             raise
0f2fcc
         if ret:
0f2fcc
diff --git a/dnf/cli/option_parser.py b/dnf/cli/option_parser.py
0f2fcc
index e60179c..e158d16 100644
0f2fcc
--- a/dnf/cli/option_parser.py
0f2fcc
+++ b/dnf/cli/option_parser.py
0f2fcc
@@ -197,10 +197,11 @@ class OptionParser(argparse.ArgumentParser):
0f2fcc
                                  default=None,
0f2fcc
                                  help=_('allow erasing of installed packages to '
0f2fcc
                                         'resolve dependencies'))
0f2fcc
-        main_parser.add_argument("-b", "--best", action="store_true",
0f2fcc
-                                 default=None,
0f2fcc
-                                 help=_("try the best available package "
0f2fcc
-                                        "versions in transactions."))
0f2fcc
+        best_group = main_parser.add_mutually_exclusive_group()
0f2fcc
+        best_group.add_argument("-b", "--best", action="store_true", dest='best', default=None,
0f2fcc
+                                help=_("try the best available package versions in transactions."))
0f2fcc
+        best_group.add_argument("--nobest", action="store_false", dest='best',
0f2fcc
+                                help=_("not narrow transaction to best candidate"))
0f2fcc
         main_parser.add_argument("-C", "--cacheonly", dest="cacheonly",
0f2fcc
                                  action="store_true", default=None,
0f2fcc
                                  help=_("run entirely from system cache, "
0f2fcc
diff --git a/doc/command_ref.rst b/doc/command_ref.rst
0f2fcc
index 6ba31ff..99f2fbd 100644
0f2fcc
--- a/doc/command_ref.rst
0f2fcc
+++ b/doc/command_ref.rst
0f2fcc
@@ -271,6 +271,9 @@ Options
0f2fcc
     disable removal of dependencies that are no longer used. It sets
0f2fcc
     :ref:`clean_requirements_on_remove <clean_requirements_on_remove-label>` conf option to ``False``.
0f2fcc
 
0f2fcc
+``--nobest``
0f2fcc
+    Set best option as false, therefore transactions are not limited to only best candidates.
0f2fcc
+
0f2fcc
 ``--nodocs``
0f2fcc
     do not install documentation by using rpm flag 'RPMTRANS_FLAG_NODOCS'
0f2fcc
 
0f2fcc
--
0f2fcc
libgit2 0.27.7
0f2fcc