Blame SOURCES/0006-Add-support-of-best-behavior.patch

ace92b
From 88602163094d654451a9586121aa8ff6fd7c96b0 Mon Sep 17 00:00:00 2001
ace92b
From: Jaroslav Mracek <jmracek@redhat.com>
ace92b
Date: Wed, 23 Oct 2019 13:14:45 +0200
ace92b
Subject: [PATCH 1/3] Add option best for transactions (RhBug:1679476)
ace92b
ace92b
It adds option `--best` plus default is handled from libdnf.conf and
ace92b
dnf.conf
ace92b
ace92b
https://bugzilla.redhat.com/show_bug.cgi?id=1679476
ace92b
---
ace92b
 dnf/dnf-main.c                            | 7 ++++++-
ace92b
 dnf/plugins/install/dnf-command-install.c | 7 ++++++-
ace92b
 dnf/plugins/update/dnf-command-update.c   | 8 ++++++--
ace92b
 3 files changed, 18 insertions(+), 4 deletions(-)
ace92b
ace92b
diff --git a/dnf/dnf-main.c b/dnf/dnf-main.c
ace92b
index 693ad7f..0dce9b2 100644
ace92b
--- a/dnf/dnf-main.c
ace92b
+++ b/dnf/dnf-main.c
ace92b
@@ -28,6 +28,7 @@
ace92b
 
ace92b
 static gboolean opt_yes = TRUE;
ace92b
 static gboolean opt_nodocs = FALSE;
ace92b
+static gboolean opt_best = FALSE;
ace92b
 static gboolean show_help = FALSE;
ace92b
 static gboolean dl_pkgs_printed = FALSE;
ace92b
 static GSList *enable_disable_repos = NULL;
ace92b
@@ -82,6 +83,7 @@ process_global_option (const gchar  *option_name,
ace92b
 
ace92b
 static const GOptionEntry global_opts[] = {
ace92b
   { "assumeyes", 'y', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &opt_yes, "Does nothing, we always assume yes", NULL },
ace92b
+  { "best", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, &opt_best, "Try the best available package versions in transactions", NULL },
ace92b
   { "disablerepo", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_CALLBACK, process_global_option, "Disable repository by an id", "ID" },
ace92b
   { "enablerepo", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_CALLBACK, process_global_option, "Enable repository by an id", "ID" },
ace92b
   { "nodocs", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, &opt_nodocs, "Install packages without docs", NULL },
ace92b
@@ -283,7 +285,10 @@ main (int   argc,
ace92b
 
ace92b
       dnf_transaction_set_flags (txn, flags);
ace92b
     }
ace92b
-
ace92b
+  if (!show_help && opt_best)
ace92b
+    {
ace92b
+        dnf_context_set_best(opt_best);
ace92b
+    }
ace92b
   /*
ace92b
    * The first non-option is the command.
ace92b
    * Get it and remove it from arguments.
ace92b
diff --git a/dnf/plugins/install/dnf-command-install.c b/dnf/plugins/install/dnf-command-install.c
ace92b
index ea549da..0b2f5e5 100644
ace92b
--- a/dnf/plugins/install/dnf-command-install.c
ace92b
+++ b/dnf/plugins/install/dnf-command-install.c
ace92b
@@ -73,7 +73,12 @@ dnf_command_install_run (DnfCommand      *cmd,
ace92b
       if (!dnf_context_install (ctx, *pkg, error))
ace92b
         return FALSE;
ace92b
     }
ace92b
-  if (!dnf_goal_depsolve (dnf_context_get_goal (ctx), DNF_INSTALL, error))
ace92b
+  DnfGoalActions flags = DNF_INSTALL;
ace92b
+  if (dnf_context_get_best())
ace92b
+    {
ace92b
+      flags |= DNF_FORCE_BEST;
ace92b
+    }
ace92b
+  if (!dnf_goal_depsolve (dnf_context_get_goal (ctx), flags, error))
ace92b
     return FALSE;
ace92b
   if (!dnf_utils_print_transaction (ctx))
ace92b
     return TRUE;
ace92b
diff --git a/dnf/plugins/update/dnf-command-update.c b/dnf/plugins/update/dnf-command-update.c
ace92b
index 652d902..7bf1334 100644
ace92b
--- a/dnf/plugins/update/dnf-command-update.c
ace92b
+++ b/dnf/plugins/update/dnf-command-update.c
ace92b
@@ -70,8 +70,12 @@ dnf_command_update_run (DnfCommand      *cmd,
ace92b
             return FALSE;
ace92b
         }
ace92b
     }
ace92b
-
ace92b
-  if (!dnf_goal_depsolve (dnf_context_get_goal (ctx), 0, error))
ace92b
+  DnfGoalActions flags = 0;
ace92b
+  if (dnf_context_get_best())
ace92b
+    {
ace92b
+      flags |= DNF_FORCE_BEST;
ace92b
+    }
ace92b
+  if (!dnf_goal_depsolve (dnf_context_get_goal (ctx), flags, error))
ace92b
     return FALSE;
ace92b
   if (!dnf_utils_print_transaction (ctx))
ace92b
     return TRUE;
ace92b
-- 
ace92b
2.21.0
ace92b
ace92b
ace92b
From 6a4a490d368fc7982264f8ab898e4bd195576b30 Mon Sep 17 00:00:00 2001
ace92b
From: Jaroslav Mracek <jmracek@redhat.com>
ace92b
Date: Wed, 23 Oct 2019 13:15:17 +0200
ace92b
Subject: [PATCH 2/3] Initialized to use tito.
ace92b
ace92b
---
ace92b
 .tito/packages/.readme | 3 +++
ace92b
 .tito/tito.props       | 5 +++++
ace92b
 2 files changed, 8 insertions(+)
ace92b
 create mode 100644 .tito/packages/.readme
ace92b
 create mode 100644 .tito/tito.props
ace92b
ace92b
diff --git a/.tito/packages/.readme b/.tito/packages/.readme
ace92b
new file mode 100644
ace92b
index 0000000..b9411e2
ace92b
--- /dev/null
ace92b
+++ b/.tito/packages/.readme
ace92b
@@ -0,0 +1,3 @@
ace92b
+the .tito/packages directory contains metadata files
ace92b
+named after their packages. Each file has the latest tagged
ace92b
+version and the project's relative directory.
ace92b
diff --git a/.tito/tito.props b/.tito/tito.props
ace92b
new file mode 100644
ace92b
index 0000000..eab3f19
ace92b
--- /dev/null
ace92b
+++ b/.tito/tito.props
ace92b
@@ -0,0 +1,5 @@
ace92b
+[buildconfig]
ace92b
+builder = tito.builder.Builder
ace92b
+tagger = tito.tagger.VersionTagger
ace92b
+changelog_do_not_remove_cherrypick = 0
ace92b
+changelog_format = %s (%ae)
ace92b
-- 
ace92b
2.21.0
ace92b
ace92b
ace92b
From 4af6a4c76e7bce0ce06188319b0b4c21a235266c Mon Sep 17 00:00:00 2001
ace92b
From: Jaroslav Mracek <jmracek@redhat.com>
ace92b
Date: Wed, 23 Oct 2019 15:07:55 +0200
ace92b
Subject: [PATCH 3/3] Add option --nobest
ace92b
ace92b
It is used to overwrite configuration of best option. It is useful when
ace92b
best=True is default.
ace92b
---
ace92b
 dnf/dnf-main.c | 22 ++++++++++++++++++----
ace92b
 1 file changed, 18 insertions(+), 4 deletions(-)
ace92b
ace92b
diff --git a/dnf/dnf-main.c b/dnf/dnf-main.c
ace92b
index 0dce9b2..4f19489 100644
ace92b
--- a/dnf/dnf-main.c
ace92b
+++ b/dnf/dnf-main.c
ace92b
@@ -29,6 +29,7 @@
ace92b
 static gboolean opt_yes = TRUE;
ace92b
 static gboolean opt_nodocs = FALSE;
ace92b
 static gboolean opt_best = FALSE;
ace92b
+static gboolean opt_nobest = FALSE;
ace92b
 static gboolean show_help = FALSE;
ace92b
 static gboolean dl_pkgs_printed = FALSE;
ace92b
 static GSList *enable_disable_repos = NULL;
ace92b
@@ -86,6 +87,7 @@ static const GOptionEntry global_opts[] = {
ace92b
   { "best", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, &opt_best, "Try the best available package versions in transactions", NULL },
ace92b
   { "disablerepo", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_CALLBACK, process_global_option, "Disable repository by an id", "ID" },
ace92b
   { "enablerepo", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_CALLBACK, process_global_option, "Enable repository by an id", "ID" },
ace92b
+  { "nobest", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, &opt_nobest, "Do not limit the transaction to the best candidates", NULL },
ace92b
   { "nodocs", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, &opt_nodocs, "Install packages without docs", NULL },
ace92b
   { "releasever", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_CALLBACK, process_global_option, "Override the value of $releasever in config and repo files", "RELEASEVER" },
ace92b
   { "setopt", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_CALLBACK, process_global_option, "Set transaction flag, like tsflags=nodocs", "FLAG" },
ace92b
@@ -284,11 +286,23 @@ main (int   argc,
ace92b
         }
ace92b
 
ace92b
       dnf_transaction_set_flags (txn, flags);
ace92b
+      if (opt_best && opt_nobest)
ace92b
+        {
ace92b
+          error = g_error_new_literal(G_OPTION_ERROR,
ace92b
+                                      G_OPTION_ERROR_BAD_VALUE,
ace92b
+                                      "Argument --nobest is not allowed with argument --best");
ace92b
+          goto out;
ace92b
+        }
ace92b
+      if (opt_best)
ace92b
+        {
ace92b
+          dnf_context_set_best(TRUE);
ace92b
+        }
ace92b
+      else if (opt_nobest)
ace92b
+        {
ace92b
+          dnf_context_set_best(FALSE);
ace92b
+        }
ace92b
     }
ace92b
-  if (!show_help && opt_best)
ace92b
-    {
ace92b
-        dnf_context_set_best(opt_best);
ace92b
-    }
ace92b
+
ace92b
   /*
ace92b
    * The first non-option is the command.
ace92b
    * Get it and remove it from arguments.
ace92b
-- 
ace92b
2.21.0
ace92b