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