Blame SOURCES/0001-Add-support-for-releasever.patch

94e8a5
From 95ff60a5f0042ca587d0dad92b8a58f6a56be461 Mon Sep 17 00:00:00 2001
94e8a5
From: Jaroslav Rohel <jrohel@redhat.com>
94e8a5
Date: Wed, 10 Apr 2019 16:03:48 +0200
94e8a5
Subject: [PATCH 1/2] Parse global arguments before context setup
94e8a5
94e8a5
This is a preparation for support more program arguments.
94e8a5
94e8a5
Some settings (eg. dnf_context_set_release_ver(), dnf_context_set_repo_dir())
94e8a5
must be done before dnf_context_setup() function is called.
94e8a5
So global arguments must be parsed before dnf_context_setup() is called.
94e8a5
94e8a5
On the other hand there are functions which must be called after
94e8a5
context setup. -> List of enabled and disabled repositories is stored
94e8a5
to GSList and used later.
94e8a5
---
94e8a5
 dnf/dnf-main.c | 41 ++++++++++++++++++++++++++++-------------
94e8a5
 1 file changed, 28 insertions(+), 13 deletions(-)
94e8a5
94e8a5
diff --git a/dnf/dnf-main.c b/dnf/dnf-main.c
94e8a5
index ef5a04e..ebf429f 100644
94e8a5
--- a/dnf/dnf-main.c
94e8a5
+++ b/dnf/dnf-main.c
94e8a5
@@ -30,6 +30,7 @@ static gboolean opt_yes = TRUE;
94e8a5
 static gboolean opt_nodocs = FALSE;
94e8a5
 static gboolean show_help = FALSE;
94e8a5
 static gboolean dl_pkgs_printed = FALSE;
94e8a5
+static GSList *enable_disable_repos = NULL;
94e8a5
 
94e8a5
 static gboolean
94e8a5
 process_global_option (const gchar  *option_name,
94e8a5
@@ -40,21 +41,20 @@ process_global_option (const gchar  *option_name,
94e8a5
   g_autoptr(GError) local_error = NULL;
94e8a5
   DnfContext *ctx = DNF_CONTEXT (data);
94e8a5
 
94e8a5
-  gboolean ret;
94e8a5
+  gboolean ret = TRUE;
94e8a5
   if (g_strcmp0 (option_name, "--disablerepo") == 0)
94e8a5
     {
94e8a5
-      ret = show_help ? TRUE : dnf_context_repo_disable (ctx, value, &local_error);
94e8a5
+      enable_disable_repos = g_slist_append (enable_disable_repos, g_strconcat("d", value, NULL));
94e8a5
     }
94e8a5
   else if (g_strcmp0 (option_name, "--enablerepo") == 0)
94e8a5
     {
94e8a5
-      ret = show_help ? TRUE : dnf_context_repo_enable (ctx, value, &local_error);
94e8a5
+      enable_disable_repos = g_slist_append (enable_disable_repos, g_strconcat("e", value, NULL));
94e8a5
     }
94e8a5
   else if (g_strcmp0 (option_name, "--setopt") == 0)
94e8a5
     {
94e8a5
       if (g_strcmp0 (value, "tsflags=nodocs") == 0)
94e8a5
         {
94e8a5
           opt_nodocs = TRUE;
94e8a5
-          ret = TRUE;
94e8a5
         }
94e8a5
       else
94e8a5
         {
94e8a5
@@ -235,6 +235,11 @@ main (int   argc,
94e8a5
 
94e8a5
   /*
94e8a5
    * Parse the global options.
94e8a5
+   */
94e8a5
+  if (!g_option_context_parse (opt_ctx, &argc, &argv, &error))
94e8a5
+    goto out;
94e8a5
+
94e8a5
+  /*
94e8a5
    * Initialize dnf context only if help is not requested.
94e8a5
    */
94e8a5
   if (!show_help)
94e8a5
@@ -246,14 +251,24 @@ main (int   argc,
94e8a5
                         G_CALLBACK (state_action_changed_cb),
94e8a5
                         NULL);
94e8a5
 
94e8a5
-    }
94e8a5
-  if (!g_option_context_parse (opt_ctx, &argc, &argv, &error))
94e8a5
-    goto out;
94e8a5
-  if (!show_help && opt_nodocs)
94e8a5
-    {
94e8a5
-      DnfTransaction *txn = dnf_context_get_transaction (ctx);
94e8a5
-      dnf_transaction_set_flags (txn,
94e8a5
-                                 dnf_transaction_get_flags (txn) | DNF_TRANSACTION_FLAG_NODOCS);
94e8a5
+      for (GSList * item = enable_disable_repos; item; item = item->next)
94e8a5
+        {
94e8a5
+          gchar * item_data = item->data;
94e8a5
+          int ret;
94e8a5
+          if (item_data[0] == 'd')
94e8a5
+            ret = dnf_context_repo_disable (ctx, item_data+1, &error);
94e8a5
+          else
94e8a5
+            ret = dnf_context_repo_enable (ctx, item_data+1, &error);
94e8a5
+          if (!ret)
94e8a5
+            goto out;
94e8a5
+        }
94e8a5
+
94e8a5
+      if (opt_nodocs)
94e8a5
+        {
94e8a5
+          DnfTransaction *txn = dnf_context_get_transaction (ctx);
94e8a5
+          dnf_transaction_set_flags (txn,
94e8a5
+                                     dnf_transaction_get_flags (txn) | DNF_TRANSACTION_FLAG_NODOCS);
94e8a5
+        }
94e8a5
     }
94e8a5
 
94e8a5
   /*
94e8a5
@@ -271,7 +286,7 @@ main (int   argc,
94e8a5
   if (cmd_name != NULL) --argc;
94e8a5
 
94e8a5
   g_option_context_set_help_enabled (opt_ctx, TRUE);
94e8a5
-  
94e8a5
+
94e8a5
   if (cmd_name == NULL && show_help)
94e8a5
     {
94e8a5
       g_set_prgname (argv[0]);
94e8a5
94e8a5
From 594f4ae5fdd60215a5010526406a34536472bb30 Mon Sep 17 00:00:00 2001
94e8a5
From: Jaroslav Rohel <jrohel@redhat.com>
94e8a5
Date: Thu, 11 Apr 2019 09:56:11 +0200
94e8a5
Subject: [PATCH 2/2] Add support for --releasever (RhBug:1591627)
94e8a5
94e8a5
---
94e8a5
 dnf/dnf-main.c | 5 +++++
94e8a5
 1 file changed, 5 insertions(+)
94e8a5
94e8a5
diff --git a/dnf/dnf-main.c b/dnf/dnf-main.c
94e8a5
index ebf429f..2381f20 100644
94e8a5
--- a/dnf/dnf-main.c
94e8a5
+++ b/dnf/dnf-main.c
94e8a5
@@ -50,6 +50,10 @@ process_global_option (const gchar  *option_name,
94e8a5
     {
94e8a5
       enable_disable_repos = g_slist_append (enable_disable_repos, g_strconcat("e", value, NULL));
94e8a5
     }
94e8a5
+  else if (g_strcmp0 (option_name, "--releasever") == 0)
94e8a5
+    {
94e8a5
+      dnf_context_set_release_ver (ctx, value);
94e8a5
+    }
94e8a5
   else if (g_strcmp0 (option_name, "--setopt") == 0)
94e8a5
     {
94e8a5
       if (g_strcmp0 (value, "tsflags=nodocs") == 0)
94e8a5
@@ -81,6 +85,7 @@ static const GOptionEntry global_opts[] = {
94e8a5
   { "disablerepo", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_CALLBACK, process_global_option, "Disable repository by an id", "ID" },
94e8a5
   { "enablerepo", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_CALLBACK, process_global_option, "Enable repository by an id", "ID" },
94e8a5
   { "nodocs", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, &opt_nodocs, "Install packages without docs", NULL },
94e8a5
+  { "releasever", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_CALLBACK, process_global_option, "Override the value of $releasever in config and repo files", "RELEASEVER" },
94e8a5
   { "setopt", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_CALLBACK, process_global_option, "Set transaction flag, like tsflags=nodocs", "FLAG" },
94e8a5
   { NULL }
94e8a5
 };