|
|
f18df4 |
From fa7e624c50dbfc0e47c0466e47f2f6acd20a6dff Mon Sep 17 00:00:00 2001
|
|
|
f18df4 |
From: Jaroslav Rohel <jrohel@redhat.com>
|
|
|
f18df4 |
Date: Fri, 30 Oct 2020 13:45:17 +0100
|
|
|
f18df4 |
Subject: [PATCH 1/5] Add subcommands support
|
|
|
f18df4 |
|
|
|
f18df4 |
Plugins with a '_' character in command name will implement subcommands.
|
|
|
f18df4 |
Needed for modularity subcommands.
|
|
|
f18df4 |
E.g. the "command_module_enable" plugin will implement the "enable"
|
|
|
f18df4 |
subcommand of the "module" command.
|
|
|
f18df4 |
---
|
|
|
f18df4 |
dnf/dnf-main.c | 96 +++++++++++++++++++++++++++++++++++++++-----------
|
|
|
f18df4 |
1 file changed, 76 insertions(+), 20 deletions(-)
|
|
|
f18df4 |
|
|
|
f18df4 |
diff --git a/dnf/dnf-main.c b/dnf/dnf-main.c
|
|
|
f18df4 |
index b6a5a69..6cb8c0e 100644
|
|
|
f18df4 |
--- a/dnf/dnf-main.c
|
|
|
f18df4 |
+++ b/dnf/dnf-main.c
|
|
|
f18df4 |
@@ -305,6 +305,33 @@ new_global_opt_group (DnfContext *ctx)
|
|
|
f18df4 |
return opt_grp;
|
|
|
f18df4 |
}
|
|
|
f18df4 |
|
|
|
f18df4 |
+/*
|
|
|
f18df4 |
+ * The first non-option is the command/subcommand.
|
|
|
f18df4 |
+ * Get it and remove it from arguments.
|
|
|
f18df4 |
+ */
|
|
|
f18df4 |
+static const gchar *
|
|
|
f18df4 |
+get_command (int *argc,
|
|
|
f18df4 |
+ char *argv[])
|
|
|
f18df4 |
+{
|
|
|
f18df4 |
+ const gchar *cmd_name = NULL;
|
|
|
f18df4 |
+ for (gint in = 1; in < *argc; in++)
|
|
|
f18df4 |
+ {
|
|
|
f18df4 |
+ if (cmd_name != NULL)
|
|
|
f18df4 |
+ argv[in-1] = argv[in];
|
|
|
f18df4 |
+ else if (argv[in][0] != '-')
|
|
|
f18df4 |
+ cmd_name = argv[in];
|
|
|
f18df4 |
+ }
|
|
|
f18df4 |
+ if (cmd_name != NULL) --*argc;
|
|
|
f18df4 |
+ return cmd_name;
|
|
|
f18df4 |
+}
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+static gint
|
|
|
f18df4 |
+compare_strings (gconstpointer a,
|
|
|
f18df4 |
+ gconstpointer b)
|
|
|
f18df4 |
+{
|
|
|
f18df4 |
+ return strcmp (a, b);
|
|
|
f18df4 |
+}
|
|
|
f18df4 |
+
|
|
|
f18df4 |
int
|
|
|
f18df4 |
main (int argc,
|
|
|
f18df4 |
char *argv[])
|
|
|
f18df4 |
@@ -316,6 +343,7 @@ main (int argc,
|
|
|
f18df4 |
g_autoptr(GOptionContext) opt_ctx = g_option_context_new ("COMMAND");
|
|
|
f18df4 |
g_autoptr(GOptionContext) subcmd_opt_ctx = NULL;
|
|
|
f18df4 |
g_autofree gchar *subcmd_opt_param = NULL;
|
|
|
f18df4 |
+ GSList *cmds_with_subcmds = NULL; /* list of commands with subcommands */
|
|
|
f18df4 |
|
|
|
f18df4 |
setlocale (LC_ALL, "");
|
|
|
f18df4 |
|
|
|
f18df4 |
@@ -353,11 +381,26 @@ main (int argc,
|
|
|
f18df4 |
if (!peas_engine_load_plugin (engine, info))
|
|
|
f18df4 |
continue;
|
|
|
f18df4 |
if (peas_engine_provides_extension (engine, info, DNF_TYPE_COMMAND))
|
|
|
f18df4 |
- /*
|
|
|
f18df4 |
- * At least 2 spaces between the command and its description are needed
|
|
|
f18df4 |
- * so that help2man formats it correctly.
|
|
|
f18df4 |
- */
|
|
|
f18df4 |
- g_string_append_printf (cmd_summary, "\n %-16s %s", peas_plugin_info_get_name (info), peas_plugin_info_get_description (info));
|
|
|
f18df4 |
+ {
|
|
|
f18df4 |
+ g_autofree gchar *command_name = g_strdup (peas_plugin_info_get_name (info));
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+ /* Plugins with a '_' character in command name implement subcommands.
|
|
|
f18df4 |
+ E.g. the "command_module_enable" plugin implements the "enable" subcommand of the "module" command. */
|
|
|
f18df4 |
+ for (gchar *ptr = command_name; *ptr != '\0'; ++ptr)
|
|
|
f18df4 |
+ {
|
|
|
f18df4 |
+ if (*ptr == '_')
|
|
|
f18df4 |
+ {
|
|
|
f18df4 |
+ *ptr = ' ';
|
|
|
f18df4 |
+ cmds_with_subcmds = g_slist_append (cmds_with_subcmds, g_strndup (command_name, ptr - command_name));
|
|
|
f18df4 |
+ break;
|
|
|
f18df4 |
+ }
|
|
|
f18df4 |
+ }
|
|
|
f18df4 |
+ /*
|
|
|
f18df4 |
+ * At least 2 spaces between the command and its description are needed
|
|
|
f18df4 |
+ * so that help2man formats it correctly.
|
|
|
f18df4 |
+ */
|
|
|
f18df4 |
+ g_string_append_printf (cmd_summary, "\n %-16s %s", command_name, peas_plugin_info_get_description (info));
|
|
|
f18df4 |
+ }
|
|
|
f18df4 |
}
|
|
|
f18df4 |
g_option_context_set_summary (opt_ctx, cmd_summary->str);
|
|
|
f18df4 |
g_string_free (cmd_summary, TRUE);
|
|
|
f18df4 |
@@ -471,19 +514,7 @@ main (int argc,
|
|
|
f18df4 |
}
|
|
|
f18df4 |
}
|
|
|
f18df4 |
|
|
|
f18df4 |
- /*
|
|
|
f18df4 |
- * The first non-option is the command.
|
|
|
f18df4 |
- * Get it and remove it from arguments.
|
|
|
f18df4 |
- */
|
|
|
f18df4 |
- const gchar *cmd_name = NULL;
|
|
|
f18df4 |
- for (gint in = 1; in < argc; in++)
|
|
|
f18df4 |
- {
|
|
|
f18df4 |
- if (cmd_name != NULL)
|
|
|
f18df4 |
- argv[in-1] = argv[in];
|
|
|
f18df4 |
- else if (argv[in][0] != '-')
|
|
|
f18df4 |
- cmd_name = argv[in];
|
|
|
f18df4 |
- }
|
|
|
f18df4 |
- if (cmd_name != NULL) --argc;
|
|
|
f18df4 |
+ const gchar *cmd_name = get_command (&argc, argv);
|
|
|
f18df4 |
|
|
|
f18df4 |
g_option_context_set_help_enabled (opt_ctx, TRUE);
|
|
|
f18df4 |
|
|
|
f18df4 |
@@ -500,10 +531,25 @@ main (int argc,
|
|
|
f18df4 |
|
|
|
f18df4 |
PeasPluginInfo *plug = NULL;
|
|
|
f18df4 |
PeasExtension *exten = NULL;
|
|
|
f18df4 |
- if (cmd_name != NULL)
|
|
|
f18df4 |
+ const gchar *subcmd_name = NULL;
|
|
|
f18df4 |
+ gboolean with_subcmds = FALSE;
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+ /* Find the plugin that implements the command cmd_name or its subcommand.
|
|
|
f18df4 |
+ * Command name (cmd_name) can not contain '_' character. It is reserved for subcomands. */
|
|
|
f18df4 |
+ if (cmd_name != NULL && strchr(cmd_name, '_') == NULL)
|
|
|
f18df4 |
{
|
|
|
f18df4 |
+ with_subcmds = g_slist_find_custom (cmds_with_subcmds, cmd_name, compare_strings) != NULL;
|
|
|
f18df4 |
g_autofree gchar *mod_name = g_strdup_printf ("command_%s", cmd_name);
|
|
|
f18df4 |
plug = peas_engine_get_plugin_info (engine, mod_name);
|
|
|
f18df4 |
+ if (plug == NULL && with_subcmds)
|
|
|
f18df4 |
+ {
|
|
|
f18df4 |
+ subcmd_name = get_command (&argc, argv);
|
|
|
f18df4 |
+ if (subcmd_name != NULL)
|
|
|
f18df4 |
+ {
|
|
|
f18df4 |
+ g_autofree gchar *submod_name = g_strdup_printf ("command_%s_%s", cmd_name, subcmd_name);
|
|
|
f18df4 |
+ plug = peas_engine_get_plugin_info (engine, submod_name);
|
|
|
f18df4 |
+ }
|
|
|
f18df4 |
+ }
|
|
|
f18df4 |
if (plug != NULL)
|
|
|
f18df4 |
exten = peas_extension_set_get_extension (cmd_exts, plug);
|
|
|
f18df4 |
}
|
|
|
f18df4 |
@@ -513,10 +559,18 @@ main (int argc,
|
|
|
f18df4 |
error = g_error_new_literal (G_IO_ERROR,
|
|
|
f18df4 |
G_IO_ERROR_FAILED,
|
|
|
f18df4 |
"No command specified");
|
|
|
f18df4 |
- else
|
|
|
f18df4 |
+ else if (!with_subcmds)
|
|
|
f18df4 |
error = g_error_new (G_IO_ERROR,
|
|
|
f18df4 |
G_IO_ERROR_FAILED,
|
|
|
f18df4 |
"Unknown command: '%s'", cmd_name);
|
|
|
f18df4 |
+ else if (subcmd_name)
|
|
|
f18df4 |
+ error = g_error_new (G_IO_ERROR,
|
|
|
f18df4 |
+ G_IO_ERROR_FAILED,
|
|
|
f18df4 |
+ "Unknown subcommand: '%s'", subcmd_name);
|
|
|
f18df4 |
+ else
|
|
|
f18df4 |
+ error = g_error_new (G_IO_ERROR,
|
|
|
f18df4 |
+ G_IO_ERROR_FAILED,
|
|
|
f18df4 |
+ "Missing subcommand for command: '%s'", cmd_name);
|
|
|
f18df4 |
|
|
|
f18df4 |
g_autofree gchar *help = g_option_context_get_help (opt_ctx, TRUE, NULL);
|
|
|
f18df4 |
g_printerr ("This is microdnf, which implements subset of `dnf'.\n"
|
|
|
f18df4 |
@@ -533,6 +587,8 @@ main (int argc,
|
|
|
f18df4 |
goto out;
|
|
|
f18df4 |
|
|
|
f18df4 |
out:
|
|
|
f18df4 |
+ g_slist_free_full(cmds_with_subcmds, g_free);
|
|
|
f18df4 |
+
|
|
|
f18df4 |
if (error != NULL)
|
|
|
f18df4 |
{
|
|
|
f18df4 |
const gchar *prefix = "";
|
|
|
f18df4 |
--
|
|
|
f18df4 |
2.26.2
|
|
|
f18df4 |
|
|
|
f18df4 |
|
|
|
f18df4 |
From 88a2b95ebdc424091b93c381623bdb458a368b48 Mon Sep 17 00:00:00 2001
|
|
|
f18df4 |
From: Jaroslav Rohel <jrohel@redhat.com>
|
|
|
f18df4 |
Date: Fri, 30 Oct 2020 14:16:34 +0100
|
|
|
f18df4 |
Subject: [PATCH 2/5] Add "module enable" command
|
|
|
f18df4 |
|
|
|
f18df4 |
---
|
|
|
f18df4 |
dnf/CMakeLists.txt | 9 +-
|
|
|
f18df4 |
dnf/meson.build | 9 ++
|
|
|
f18df4 |
.../module_enable/dnf-command-module_enable.c | 97 +++++++++++++++++++
|
|
|
f18df4 |
.../dnf-command-module_enable.gresource.xml | 6 ++
|
|
|
f18df4 |
.../module_enable/dnf-command-module_enable.h | 33 +++++++
|
|
|
f18df4 |
.../module_enable/module_enable.plugin | 9 ++
|
|
|
f18df4 |
microdnf.spec | 2 +-
|
|
|
f18df4 |
7 files changed, 163 insertions(+), 2 deletions(-)
|
|
|
f18df4 |
create mode 100644 dnf/plugins/module_enable/dnf-command-module_enable.c
|
|
|
f18df4 |
create mode 100644 dnf/plugins/module_enable/dnf-command-module_enable.gresource.xml
|
|
|
f18df4 |
create mode 100644 dnf/plugins/module_enable/dnf-command-module_enable.h
|
|
|
f18df4 |
create mode 100644 dnf/plugins/module_enable/module_enable.plugin
|
|
|
f18df4 |
|
|
|
f18df4 |
diff --git a/dnf/CMakeLists.txt b/dnf/CMakeLists.txt
|
|
|
f18df4 |
index 0705390..b673ce4 100644
|
|
|
f18df4 |
--- a/dnf/CMakeLists.txt
|
|
|
f18df4 |
+++ b/dnf/CMakeLists.txt
|
|
|
f18df4 |
@@ -35,6 +35,12 @@ glib_compile_resources (DNF_COMMAND_CLEAN plugins/clean/dnf-command-clean.gresou
|
|
|
f18df4 |
INTERNAL)
|
|
|
f18df4 |
list (APPEND DNF_COMMAND_CLEAN "plugins/clean/dnf-command-clean.c")
|
|
|
f18df4 |
|
|
|
f18df4 |
+glib_compile_resources (DNF_COMMAND_MODULE_ENABLE plugins/module_enable/dnf-command-module_enable.gresource.xml
|
|
|
f18df4 |
+ C_PREFIX dnf_command_module_enable
|
|
|
f18df4 |
+ INTERNAL)
|
|
|
f18df4 |
+list (APPEND DNF_COMMAND_MODULE_ENABLE "plugins/module_enable/dnf-command-module_enable.c")
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+
|
|
|
f18df4 |
include_directories (${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
f18df4 |
add_executable (microdnf dnf-main.c ${DNF_SRCS}
|
|
|
f18df4 |
${DNF_COMMAND_INSTALL}
|
|
|
f18df4 |
@@ -43,7 +49,8 @@ add_executable (microdnf dnf-main.c ${DNF_SRCS}
|
|
|
f18df4 |
${DNF_COMMAND_UPDATE}
|
|
|
f18df4 |
${DNF_COMMAND_REPOLIST}
|
|
|
f18df4 |
${DNF_COMMAND_REPOQUERY}
|
|
|
f18df4 |
- ${DNF_COMMAND_CLEAN})
|
|
|
f18df4 |
+ ${DNF_COMMAND_CLEAN}
|
|
|
f18df4 |
+ ${DNF_COMMAND_MODULE_ENABLE})
|
|
|
f18df4 |
|
|
|
f18df4 |
target_link_libraries (microdnf
|
|
|
f18df4 |
${GLIB_LIBRARIES}
|
|
|
f18df4 |
diff --git a/dnf/meson.build b/dnf/meson.build
|
|
|
f18df4 |
index 12e11ac..d617453 100644
|
|
|
f18df4 |
--- a/dnf/meson.build
|
|
|
f18df4 |
+++ b/dnf/meson.build
|
|
|
f18df4 |
@@ -65,6 +65,15 @@ microdnf_srcs = [
|
|
|
f18df4 |
source_dir : 'plugins/clean',
|
|
|
f18df4 |
),
|
|
|
f18df4 |
'plugins/clean/dnf-command-clean.c',
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+ # module enable
|
|
|
f18df4 |
+ gnome.compile_resources(
|
|
|
f18df4 |
+ 'dnf-module_enable',
|
|
|
f18df4 |
+ 'plugins/module_enable/dnf-command-module_enable.gresource.xml',
|
|
|
f18df4 |
+ c_name : 'dnf_command_module_enable',
|
|
|
f18df4 |
+ source_dir : 'plugins/module_enable',
|
|
|
f18df4 |
+ ),
|
|
|
f18df4 |
+ 'plugins/module_enable/dnf-command-module_enable.c',
|
|
|
f18df4 |
]
|
|
|
f18df4 |
|
|
|
f18df4 |
microdnf = executable(
|
|
|
f18df4 |
diff --git a/dnf/plugins/module_enable/dnf-command-module_enable.c b/dnf/plugins/module_enable/dnf-command-module_enable.c
|
|
|
f18df4 |
new file mode 100644
|
|
|
f18df4 |
index 0000000..3081042
|
|
|
f18df4 |
--- /dev/null
|
|
|
f18df4 |
+++ b/dnf/plugins/module_enable/dnf-command-module_enable.c
|
|
|
f18df4 |
@@ -0,0 +1,97 @@
|
|
|
f18df4 |
+/*
|
|
|
f18df4 |
+ * Copyright (C) 2020 Red Hat, Inc.
|
|
|
f18df4 |
+ *
|
|
|
f18df4 |
+ * Licensed under the GNU Lesser General Public License Version 2.1
|
|
|
f18df4 |
+ *
|
|
|
f18df4 |
+ * This library is free software; you can redistribute it and/or
|
|
|
f18df4 |
+ * modify it under the terms of the GNU Lesser General Public
|
|
|
f18df4 |
+ * License as published by the Free Software Foundation; either
|
|
|
f18df4 |
+ * version 2.1 of the License, or (at your option) any later version.
|
|
|
f18df4 |
+ *
|
|
|
f18df4 |
+ * This library is distributed in the hope that it will be useful,
|
|
|
f18df4 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
f18df4 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
f18df4 |
+ * Lesser General Public License for more details.
|
|
|
f18df4 |
+ *
|
|
|
f18df4 |
+ * You should have received a copy of the GNU Lesser General Public
|
|
|
f18df4 |
+ * License along with this library; if not, write to the Free Software
|
|
|
f18df4 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
f18df4 |
+ */
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+#include "dnf-command-module_enable.h"
|
|
|
f18df4 |
+#include "dnf-utils.h"
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+struct _DnfCommandModuleEnable
|
|
|
f18df4 |
+{
|
|
|
f18df4 |
+ PeasExtensionBase parent_instance;
|
|
|
f18df4 |
+};
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+static void dnf_command_module_enable_iface_init (DnfCommandInterface *iface);
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+G_DEFINE_DYNAMIC_TYPE_EXTENDED (DnfCommandModuleEnable,
|
|
|
f18df4 |
+ dnf_command_module_enable,
|
|
|
f18df4 |
+ PEAS_TYPE_EXTENSION_BASE,
|
|
|
f18df4 |
+ 0,
|
|
|
f18df4 |
+ G_IMPLEMENT_INTERFACE (DNF_TYPE_COMMAND,
|
|
|
f18df4 |
+ dnf_command_module_enable_iface_init))
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+static void
|
|
|
f18df4 |
+dnf_command_module_enable_init (DnfCommandModuleEnable *self)
|
|
|
f18df4 |
+{
|
|
|
f18df4 |
+}
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+static gboolean
|
|
|
f18df4 |
+dnf_command_module_enable_run (DnfCommand *cmd,
|
|
|
f18df4 |
+ int argc,
|
|
|
f18df4 |
+ char *argv[],
|
|
|
f18df4 |
+ GOptionContext *opt_ctx,
|
|
|
f18df4 |
+ DnfContext *ctx,
|
|
|
f18df4 |
+ GError **error)
|
|
|
f18df4 |
+{
|
|
|
f18df4 |
+ g_auto(GStrv) pkgs = NULL;
|
|
|
f18df4 |
+ const GOptionEntry opts[] = {
|
|
|
f18df4 |
+ { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &pkgs, NULL, NULL },
|
|
|
f18df4 |
+ { NULL }
|
|
|
f18df4 |
+ };
|
|
|
f18df4 |
+ g_option_context_add_main_entries (opt_ctx, opts, NULL);
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+ if (!g_option_context_parse (opt_ctx, &argc, &argv, error))
|
|
|
f18df4 |
+ return FALSE;
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+ if (pkgs == NULL)
|
|
|
f18df4 |
+ {
|
|
|
f18df4 |
+ g_set_error_literal (error,
|
|
|
f18df4 |
+ G_IO_ERROR,
|
|
|
f18df4 |
+ G_IO_ERROR_FAILED,
|
|
|
f18df4 |
+ "Modules are not specified");
|
|
|
f18df4 |
+ return FALSE;
|
|
|
f18df4 |
+ }
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+ return dnf_context_enable_modules (ctx, (const char **)pkgs, error);
|
|
|
f18df4 |
+}
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+static void
|
|
|
f18df4 |
+dnf_command_module_enable_class_init (DnfCommandModuleEnableClass *klass)
|
|
|
f18df4 |
+{
|
|
|
f18df4 |
+}
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+static void
|
|
|
f18df4 |
+dnf_command_module_enable_iface_init (DnfCommandInterface *iface)
|
|
|
f18df4 |
+{
|
|
|
f18df4 |
+ iface->run = dnf_command_module_enable_run;
|
|
|
f18df4 |
+}
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+static void
|
|
|
f18df4 |
+dnf_command_module_enable_class_finalize (DnfCommandModuleEnableClass *klass)
|
|
|
f18df4 |
+{
|
|
|
f18df4 |
+}
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+G_MODULE_EXPORT void
|
|
|
f18df4 |
+dnf_command_module_enable_register_types (PeasObjectModule *module)
|
|
|
f18df4 |
+{
|
|
|
f18df4 |
+ dnf_command_module_enable_register_type (G_TYPE_MODULE (module));
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+ peas_object_module_register_extension_type (module,
|
|
|
f18df4 |
+ DNF_TYPE_COMMAND,
|
|
|
f18df4 |
+ DNF_TYPE_COMMAND_MODULE_ENABLE);
|
|
|
f18df4 |
+}
|
|
|
f18df4 |
diff --git a/dnf/plugins/module_enable/dnf-command-module_enable.gresource.xml b/dnf/plugins/module_enable/dnf-command-module_enable.gresource.xml
|
|
|
f18df4 |
new file mode 100644
|
|
|
f18df4 |
index 0000000..4b99047
|
|
|
f18df4 |
--- /dev/null
|
|
|
f18df4 |
+++ b/dnf/plugins/module_enable/dnf-command-module_enable.gresource.xml
|
|
|
f18df4 |
@@ -0,0 +1,6 @@
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+<gresources>
|
|
|
f18df4 |
+ <gresource prefix="/org/fedoraproject/dnf/plugins/module_enable">
|
|
|
f18df4 |
+ <file>module_enable.plugin</file>
|
|
|
f18df4 |
+ </gresource>
|
|
|
f18df4 |
+</gresources>
|
|
|
f18df4 |
diff --git a/dnf/plugins/module_enable/dnf-command-module_enable.h b/dnf/plugins/module_enable/dnf-command-module_enable.h
|
|
|
f18df4 |
new file mode 100644
|
|
|
f18df4 |
index 0000000..d489331
|
|
|
f18df4 |
--- /dev/null
|
|
|
f18df4 |
+++ b/dnf/plugins/module_enable/dnf-command-module_enable.h
|
|
|
f18df4 |
@@ -0,0 +1,33 @@
|
|
|
f18df4 |
+/*
|
|
|
f18df4 |
+ * Copyright (C) 2020 Red Hat, Inc.
|
|
|
f18df4 |
+ *
|
|
|
f18df4 |
+ * Licensed under the GNU Lesser General Public License Version 2.1
|
|
|
f18df4 |
+ *
|
|
|
f18df4 |
+ * This library is free software; you can redistribute it and/or
|
|
|
f18df4 |
+ * modify it under the terms of the GNU Lesser General Public
|
|
|
f18df4 |
+ * License as published by the Free Software Foundation; either
|
|
|
f18df4 |
+ * version 2.1 of the License, or (at your option) any later version.
|
|
|
f18df4 |
+ *
|
|
|
f18df4 |
+ * This library is distributed in the hope that it will be useful,
|
|
|
f18df4 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
f18df4 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
f18df4 |
+ * Lesser General Public License for more details.
|
|
|
f18df4 |
+ *
|
|
|
f18df4 |
+ * You should have received a copy of the GNU Lesser General Public
|
|
|
f18df4 |
+ * License along with this library; if not, write to the Free Software
|
|
|
f18df4 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
f18df4 |
+ */
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+#pragma once
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+#include "dnf-command.h"
|
|
|
f18df4 |
+#include <libpeas/peas.h>
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+G_BEGIN_DECLS
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+#define DNF_TYPE_COMMAND_MODULE_ENABLE dnf_command_module_enable_get_type ()
|
|
|
f18df4 |
+G_DECLARE_FINAL_TYPE (DnfCommandModuleEnable, dnf_command_module_enable, DNF, COMMAND_MODULE_ENABLE, PeasExtensionBase)
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+G_MODULE_EXPORT void dnf_command_module_enable_register_types (PeasObjectModule *module);
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+G_END_DECLS
|
|
|
f18df4 |
diff --git a/dnf/plugins/module_enable/module_enable.plugin b/dnf/plugins/module_enable/module_enable.plugin
|
|
|
f18df4 |
new file mode 100644
|
|
|
f18df4 |
index 0000000..91da9fb
|
|
|
f18df4 |
--- /dev/null
|
|
|
f18df4 |
+++ b/dnf/plugins/module_enable/module_enable.plugin
|
|
|
f18df4 |
@@ -0,0 +1,9 @@
|
|
|
f18df4 |
+[Plugin]
|
|
|
f18df4 |
+Module = command_module_enable
|
|
|
f18df4 |
+Embedded = dnf_command_module_enable_register_types
|
|
|
f18df4 |
+Name = module_enable
|
|
|
f18df4 |
+Description = Enable a module stream
|
|
|
f18df4 |
+Authors = Jaroslav Rohel <jrohel@redhat.com>
|
|
|
f18df4 |
+License = GPL-3.0+
|
|
|
f18df4 |
+Copyright = Copyright (C) 2020 Red Hat, Inc.
|
|
|
f18df4 |
+X-Command-Syntax = module enable module-spec [module-spec…]
|
|
|
f18df4 |
diff --git a/microdnf.spec b/microdnf.spec
|
|
|
f18df4 |
index db8e35e..3648e46 100644
|
|
|
f18df4 |
--- a/microdnf.spec
|
|
|
f18df4 |
+++ b/microdnf.spec
|
|
|
f18df4 |
@@ -1,4 +1,4 @@
|
|
|
f18df4 |
-%global libdnf_version 0.43.1
|
|
|
f18df4 |
+%global libdnf_version 0.55.0
|
|
|
f18df4 |
|
|
|
f18df4 |
Name: microdnf
|
|
|
f18df4 |
Version: 3.4.0
|
|
|
f18df4 |
--
|
|
|
f18df4 |
2.26.2
|
|
|
f18df4 |
|
|
|
f18df4 |
|
|
|
f18df4 |
From 7cc7bb7202cb79d6bb6daa63e32109134c273627 Mon Sep 17 00:00:00 2001
|
|
|
f18df4 |
From: Jaroslav Mracek <jmracek@redhat.com>
|
|
|
f18df4 |
Date: Fri, 23 Oct 2020 16:04:48 +0200
|
|
|
f18df4 |
Subject: [PATCH 3/5] Add reports of module changes
|
|
|
f18df4 |
|
|
|
f18df4 |
---
|
|
|
f18df4 |
dnf/dnf-utils.c | 16 ++++++++++++++--
|
|
|
f18df4 |
1 file changed, 14 insertions(+), 2 deletions(-)
|
|
|
f18df4 |
|
|
|
f18df4 |
diff --git a/dnf/dnf-utils.c b/dnf/dnf-utils.c
|
|
|
f18df4 |
index c58f519..5984f22 100644
|
|
|
f18df4 |
--- a/dnf/dnf-utils.c
|
|
|
f18df4 |
+++ b/dnf/dnf-utils.c
|
|
|
f18df4 |
@@ -68,8 +68,15 @@ dnf_utils_print_transaction (DnfContext *ctx)
|
|
|
f18df4 |
|
|
|
f18df4 |
if (pkgs->len == 0)
|
|
|
f18df4 |
{
|
|
|
f18df4 |
- g_print ("Nothing to do.\n");
|
|
|
f18df4 |
- return FALSE;
|
|
|
f18df4 |
+ g_autofree char * report = dnf_context_get_module_report (ctx);
|
|
|
f18df4 |
+ if (report)
|
|
|
f18df4 |
+ {
|
|
|
f18df4 |
+ g_print ("%s\n", report);
|
|
|
f18df4 |
+ return TRUE;
|
|
|
f18df4 |
+ } else {
|
|
|
f18df4 |
+ g_print ("Nothing to do.\n");
|
|
|
f18df4 |
+ return FALSE;
|
|
|
f18df4 |
+ }
|
|
|
f18df4 |
}
|
|
|
f18df4 |
|
|
|
f18df4 |
struct libscols_line *ln;
|
|
|
f18df4 |
@@ -147,6 +154,11 @@ dnf_utils_print_transaction (DnfContext *ctx)
|
|
|
f18df4 |
g_print (" %-15s %4d packages\n", "Removing:", pkgs_remove->len);
|
|
|
f18df4 |
g_print (" %-15s %4d packages\n", "Downgrading:", pkgs_downgrade->len);
|
|
|
f18df4 |
|
|
|
f18df4 |
+ g_autofree char * report = dnf_context_get_module_report (ctx);
|
|
|
f18df4 |
+ if (report)
|
|
|
f18df4 |
+ {
|
|
|
f18df4 |
+ g_print ("%s\n", report);
|
|
|
f18df4 |
+ }
|
|
|
f18df4 |
/* check for test mode */
|
|
|
f18df4 |
DnfTransaction *txn = dnf_context_get_transaction (ctx);
|
|
|
f18df4 |
if (dnf_transaction_get_flags (txn) & DNF_TRANSACTION_FLAG_TEST)
|
|
|
f18df4 |
--
|
|
|
f18df4 |
2.26.2
|
|
|
f18df4 |
|
|
|
f18df4 |
|
|
|
f18df4 |
From 6c4dceac5012231923187c3bbb16de4bda23789c Mon Sep 17 00:00:00 2001
|
|
|
f18df4 |
From: Jaroslav Mracek <jmracek@redhat.com>
|
|
|
f18df4 |
Date: Mon, 2 Nov 2020 12:05:01 +0100
|
|
|
f18df4 |
Subject: [PATCH 4/5] Allow to commit module changes and report module switch
|
|
|
f18df4 |
as an error
|
|
|
f18df4 |
|
|
|
f18df4 |
---
|
|
|
f18df4 |
.../module_enable/dnf-command-module_enable.c | 28 ++++++++++++++++++-
|
|
|
f18df4 |
1 file changed, 27 insertions(+), 1 deletion(-)
|
|
|
f18df4 |
|
|
|
f18df4 |
diff --git a/dnf/plugins/module_enable/dnf-command-module_enable.c b/dnf/plugins/module_enable/dnf-command-module_enable.c
|
|
|
f18df4 |
index 3081042..a5a4701 100644
|
|
|
f18df4 |
--- a/dnf/plugins/module_enable/dnf-command-module_enable.c
|
|
|
f18df4 |
+++ b/dnf/plugins/module_enable/dnf-command-module_enable.c
|
|
|
f18df4 |
@@ -67,7 +67,33 @@ dnf_command_module_enable_run (DnfCommand *cmd,
|
|
|
f18df4 |
return FALSE;
|
|
|
f18df4 |
}
|
|
|
f18df4 |
|
|
|
f18df4 |
- return dnf_context_enable_modules (ctx, (const char **)pkgs, error);
|
|
|
f18df4 |
+ if (!dnf_context_module_enable (ctx, (const char **)pkgs, error))
|
|
|
f18df4 |
+ {
|
|
|
f18df4 |
+ return FALSE;
|
|
|
f18df4 |
+ }
|
|
|
f18df4 |
+ if (!dnf_context_module_switched_check (ctx, error))
|
|
|
f18df4 |
+ {
|
|
|
f18df4 |
+ return FALSE;
|
|
|
f18df4 |
+ }
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+ if (!dnf_goal_depsolve (dnf_context_get_goal (ctx), DNF_NONE, error))
|
|
|
f18df4 |
+ {
|
|
|
f18df4 |
+ if (g_error_matches (*error, DNF_ERROR, DNF_ERROR_NO_PACKAGES_TO_UPDATE))
|
|
|
f18df4 |
+ {
|
|
|
f18df4 |
+ g_clear_error (error);
|
|
|
f18df4 |
+ } else {
|
|
|
f18df4 |
+ return FALSE;
|
|
|
f18df4 |
+ }
|
|
|
f18df4 |
+ }
|
|
|
f18df4 |
+ if (!dnf_utils_print_transaction (ctx))
|
|
|
f18df4 |
+ {
|
|
|
f18df4 |
+ return TRUE;
|
|
|
f18df4 |
+ }
|
|
|
f18df4 |
+ if (!dnf_context_run (ctx, NULL, error))
|
|
|
f18df4 |
+ {
|
|
|
f18df4 |
+ return FALSE;
|
|
|
f18df4 |
+ }
|
|
|
f18df4 |
+ return TRUE;
|
|
|
f18df4 |
}
|
|
|
f18df4 |
|
|
|
f18df4 |
static void
|
|
|
f18df4 |
--
|
|
|
f18df4 |
2.26.2
|
|
|
f18df4 |
|
|
|
f18df4 |
|
|
|
f18df4 |
From 6c86306c9c0725c73c3d4ec704f932e372e09585 Mon Sep 17 00:00:00 2001
|
|
|
f18df4 |
From: Jaroslav Mracek <jmracek@redhat.com>
|
|
|
f18df4 |
Date: Mon, 2 Nov 2020 15:17:29 +0100
|
|
|
f18df4 |
Subject: [PATCH 5/5] Add module enable and disable commands
|
|
|
f18df4 |
|
|
|
f18df4 |
---
|
|
|
f18df4 |
dnf/CMakeLists.txt | 14 +-
|
|
|
f18df4 |
dnf/meson.build | 18 +++
|
|
|
f18df4 |
.../dnf-command-module_disable.c | 119 +++++++++++++++++
|
|
|
f18df4 |
.../dnf-command-module_disable.gresource.xml | 6 +
|
|
|
f18df4 |
.../dnf-command-module_disable.h | 33 +++++
|
|
|
f18df4 |
.../module_disable/module_disable.plugin | 9 ++
|
|
|
f18df4 |
.../module_reset/dnf-command-module_reset.c | 123 ++++++++++++++++++
|
|
|
f18df4 |
.../dnf-command-module_reset.gresource.xml | 6 +
|
|
|
f18df4 |
.../module_reset/dnf-command-module_reset.h | 33 +++++
|
|
|
f18df4 |
dnf/plugins/module_reset/module_reset.plugin | 9 ++
|
|
|
f18df4 |
10 files changed, 369 insertions(+), 1 deletion(-)
|
|
|
f18df4 |
create mode 100644 dnf/plugins/module_disable/dnf-command-module_disable.c
|
|
|
f18df4 |
create mode 100644 dnf/plugins/module_disable/dnf-command-module_disable.gresource.xml
|
|
|
f18df4 |
create mode 100644 dnf/plugins/module_disable/dnf-command-module_disable.h
|
|
|
f18df4 |
create mode 100644 dnf/plugins/module_disable/module_disable.plugin
|
|
|
f18df4 |
create mode 100644 dnf/plugins/module_reset/dnf-command-module_reset.c
|
|
|
f18df4 |
create mode 100644 dnf/plugins/module_reset/dnf-command-module_reset.gresource.xml
|
|
|
f18df4 |
create mode 100644 dnf/plugins/module_reset/dnf-command-module_reset.h
|
|
|
f18df4 |
create mode 100644 dnf/plugins/module_reset/module_reset.plugin
|
|
|
f18df4 |
|
|
|
f18df4 |
diff --git a/dnf/CMakeLists.txt b/dnf/CMakeLists.txt
|
|
|
f18df4 |
index b673ce4..1d640be 100644
|
|
|
f18df4 |
--- a/dnf/CMakeLists.txt
|
|
|
f18df4 |
+++ b/dnf/CMakeLists.txt
|
|
|
f18df4 |
@@ -40,6 +40,16 @@ glib_compile_resources (DNF_COMMAND_MODULE_ENABLE plugins/module_enable/dnf-comm
|
|
|
f18df4 |
INTERNAL)
|
|
|
f18df4 |
list (APPEND DNF_COMMAND_MODULE_ENABLE "plugins/module_enable/dnf-command-module_enable.c")
|
|
|
f18df4 |
|
|
|
f18df4 |
+glib_compile_resources (DNF_COMMAND_MODULE_DISABLE plugins/module_disable/dnf-command-module_disable.gresource.xml
|
|
|
f18df4 |
+ C_PREFIX dnf_command_module_disable
|
|
|
f18df4 |
+ INTERNAL)
|
|
|
f18df4 |
+list (APPEND DNF_COMMAND_MODULE_DISABLE "plugins/module_disable/dnf-command-module_disable.c")
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+glib_compile_resources (DNF_COMMAND_MODULE_RESET plugins/module_reset/dnf-command-module_reset.gresource.xml
|
|
|
f18df4 |
+ C_PREFIX dnf_command_module_reset
|
|
|
f18df4 |
+ INTERNAL)
|
|
|
f18df4 |
+list (APPEND DNF_COMMAND_MODULE_RESET "plugins/module_reset/dnf-command-module_reset.c")
|
|
|
f18df4 |
+
|
|
|
f18df4 |
|
|
|
f18df4 |
include_directories (${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
f18df4 |
add_executable (microdnf dnf-main.c ${DNF_SRCS}
|
|
|
f18df4 |
@@ -50,7 +60,9 @@ add_executable (microdnf dnf-main.c ${DNF_SRCS}
|
|
|
f18df4 |
${DNF_COMMAND_REPOLIST}
|
|
|
f18df4 |
${DNF_COMMAND_REPOQUERY}
|
|
|
f18df4 |
${DNF_COMMAND_CLEAN}
|
|
|
f18df4 |
- ${DNF_COMMAND_MODULE_ENABLE})
|
|
|
f18df4 |
+ ${DNF_COMMAND_MODULE_ENABLE}
|
|
|
f18df4 |
+ ${DNF_COMMAND_MODULE_DISABLE}
|
|
|
f18df4 |
+ ${DNF_COMMAND_MODULE_RESET})
|
|
|
f18df4 |
|
|
|
f18df4 |
target_link_libraries (microdnf
|
|
|
f18df4 |
${GLIB_LIBRARIES}
|
|
|
f18df4 |
diff --git a/dnf/meson.build b/dnf/meson.build
|
|
|
f18df4 |
index d617453..b456202 100644
|
|
|
f18df4 |
--- a/dnf/meson.build
|
|
|
f18df4 |
+++ b/dnf/meson.build
|
|
|
f18df4 |
@@ -74,6 +74,24 @@ microdnf_srcs = [
|
|
|
f18df4 |
source_dir : 'plugins/module_enable',
|
|
|
f18df4 |
),
|
|
|
f18df4 |
'plugins/module_enable/dnf-command-module_enable.c',
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+ # module disable
|
|
|
f18df4 |
+ gnome.compile_resources(
|
|
|
f18df4 |
+ 'dnf-module_disable',
|
|
|
f18df4 |
+ 'plugins/module_disable/dnf-command-module_disable.gresource.xml',
|
|
|
f18df4 |
+ c_name : 'dnf_command_module_disable',
|
|
|
f18df4 |
+ source_dir : 'plugins/module_disable',
|
|
|
f18df4 |
+ ),
|
|
|
f18df4 |
+ 'plugins/module_disable/dnf-command-module_disable.c',
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+ # module reset
|
|
|
f18df4 |
+ gnome.compile_resources(
|
|
|
f18df4 |
+ 'dnf-module_reset',
|
|
|
f18df4 |
+ 'plugins/module_reset/dnf-command-module_reset.gresource.xml',
|
|
|
f18df4 |
+ c_name : 'dnf_command_module_reset',
|
|
|
f18df4 |
+ source_dir : 'plugins/module_reset',
|
|
|
f18df4 |
+ ),
|
|
|
f18df4 |
+ 'plugins/module_reset/dnf-command-module_reset.c',
|
|
|
f18df4 |
]
|
|
|
f18df4 |
|
|
|
f18df4 |
microdnf = executable(
|
|
|
f18df4 |
diff --git a/dnf/plugins/module_disable/dnf-command-module_disable.c b/dnf/plugins/module_disable/dnf-command-module_disable.c
|
|
|
f18df4 |
new file mode 100644
|
|
|
f18df4 |
index 0000000..eedb77c
|
|
|
f18df4 |
--- /dev/null
|
|
|
f18df4 |
+++ b/dnf/plugins/module_disable/dnf-command-module_disable.c
|
|
|
f18df4 |
@@ -0,0 +1,119 @@
|
|
|
f18df4 |
+/*
|
|
|
f18df4 |
+ * Copyright (C) 2020 Red Hat, Inc.
|
|
|
f18df4 |
+ *
|
|
|
f18df4 |
+ * Licensed under the GNU Lesser General Public License Version 2.1
|
|
|
f18df4 |
+ *
|
|
|
f18df4 |
+ * This library is free software; you can redistribute it and/or
|
|
|
f18df4 |
+ * modify it under the terms of the GNU Lesser General Public
|
|
|
f18df4 |
+ * License as published by the Free Software Foundation; either
|
|
|
f18df4 |
+ * version 2.1 of the License, or (at your option) any later version.
|
|
|
f18df4 |
+ *
|
|
|
f18df4 |
+ * This library is distributed in the hope that it will be useful,
|
|
|
f18df4 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
f18df4 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
f18df4 |
+ * Lesser General Public License for more details.
|
|
|
f18df4 |
+ *
|
|
|
f18df4 |
+ * You should have received a copy of the GNU Lesser General Public
|
|
|
f18df4 |
+ * License along with this library; if not, write to the Free Software
|
|
|
f18df4 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
f18df4 |
+ */
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+#include "dnf-command-module_disable.h"
|
|
|
f18df4 |
+#include "dnf-utils.h"
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+struct _DnfCommandModuleDisable
|
|
|
f18df4 |
+{
|
|
|
f18df4 |
+ PeasExtensionBase parent_instance;
|
|
|
f18df4 |
+};
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+static void dnf_command_module_disable_iface_init (DnfCommandInterface *iface);
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+G_DEFINE_DYNAMIC_TYPE_EXTENDED (DnfCommandModuleDisable,
|
|
|
f18df4 |
+ dnf_command_module_disable,
|
|
|
f18df4 |
+ PEAS_TYPE_EXTENSION_BASE,
|
|
|
f18df4 |
+ 0,
|
|
|
f18df4 |
+ G_IMPLEMENT_INTERFACE (DNF_TYPE_COMMAND,
|
|
|
f18df4 |
+ dnf_command_module_disable_iface_init))
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+static void
|
|
|
f18df4 |
+dnf_command_module_disable_init (DnfCommandModuleDisable *self)
|
|
|
f18df4 |
+{
|
|
|
f18df4 |
+}
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+static gboolean
|
|
|
f18df4 |
+dnf_command_module_disable_run (DnfCommand *cmd,
|
|
|
f18df4 |
+ int argc,
|
|
|
f18df4 |
+ char *argv[],
|
|
|
f18df4 |
+ GOptionContext *opt_ctx,
|
|
|
f18df4 |
+ DnfContext *ctx,
|
|
|
f18df4 |
+ GError **error)
|
|
|
f18df4 |
+{
|
|
|
f18df4 |
+ g_auto(GStrv) pkgs = NULL;
|
|
|
f18df4 |
+ const GOptionEntry opts[] = {
|
|
|
f18df4 |
+ { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &pkgs, NULL, NULL },
|
|
|
f18df4 |
+ { NULL }
|
|
|
f18df4 |
+ };
|
|
|
f18df4 |
+ g_option_context_add_main_entries (opt_ctx, opts, NULL);
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+ if (!g_option_context_parse (opt_ctx, &argc, &argv, error))
|
|
|
f18df4 |
+ return FALSE;
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+ if (pkgs == NULL)
|
|
|
f18df4 |
+ {
|
|
|
f18df4 |
+ g_set_error_literal (error,
|
|
|
f18df4 |
+ G_IO_ERROR,
|
|
|
f18df4 |
+ G_IO_ERROR_FAILED,
|
|
|
f18df4 |
+ "Modules are not specified");
|
|
|
f18df4 |
+ return FALSE;
|
|
|
f18df4 |
+ }
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+ if (!dnf_context_module_disable (ctx, (const char **)pkgs, error))
|
|
|
f18df4 |
+ {
|
|
|
f18df4 |
+ return FALSE;
|
|
|
f18df4 |
+ }
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+ if (!dnf_goal_depsolve (dnf_context_get_goal (ctx), DNF_NONE, error))
|
|
|
f18df4 |
+ {
|
|
|
f18df4 |
+ if (g_error_matches (*error, DNF_ERROR, DNF_ERROR_NO_PACKAGES_TO_UPDATE))
|
|
|
f18df4 |
+ {
|
|
|
f18df4 |
+ g_clear_error (error);
|
|
|
f18df4 |
+ } else {
|
|
|
f18df4 |
+ return FALSE;
|
|
|
f18df4 |
+ }
|
|
|
f18df4 |
+ }
|
|
|
f18df4 |
+ if (!dnf_utils_print_transaction (ctx))
|
|
|
f18df4 |
+ {
|
|
|
f18df4 |
+ return TRUE;
|
|
|
f18df4 |
+ }
|
|
|
f18df4 |
+ if (!dnf_context_run (ctx, NULL, error))
|
|
|
f18df4 |
+ {
|
|
|
f18df4 |
+ return FALSE;
|
|
|
f18df4 |
+ }
|
|
|
f18df4 |
+ return TRUE;
|
|
|
f18df4 |
+}
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+static void
|
|
|
f18df4 |
+dnf_command_module_disable_class_init (DnfCommandModuleDisableClass *klass)
|
|
|
f18df4 |
+{
|
|
|
f18df4 |
+}
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+static void
|
|
|
f18df4 |
+dnf_command_module_disable_iface_init (DnfCommandInterface *iface)
|
|
|
f18df4 |
+{
|
|
|
f18df4 |
+ iface->run = dnf_command_module_disable_run;
|
|
|
f18df4 |
+}
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+static void
|
|
|
f18df4 |
+dnf_command_module_disable_class_finalize (DnfCommandModuleDisableClass *klass)
|
|
|
f18df4 |
+{
|
|
|
f18df4 |
+}
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+G_MODULE_EXPORT void
|
|
|
f18df4 |
+dnf_command_module_disable_register_types (PeasObjectModule *module)
|
|
|
f18df4 |
+{
|
|
|
f18df4 |
+ dnf_command_module_disable_register_type (G_TYPE_MODULE (module));
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+ peas_object_module_register_extension_type (module,
|
|
|
f18df4 |
+ DNF_TYPE_COMMAND,
|
|
|
f18df4 |
+ DNF_TYPE_COMMAND_MODULE_DISABLE);
|
|
|
f18df4 |
+}
|
|
|
f18df4 |
diff --git a/dnf/plugins/module_disable/dnf-command-module_disable.gresource.xml b/dnf/plugins/module_disable/dnf-command-module_disable.gresource.xml
|
|
|
f18df4 |
new file mode 100644
|
|
|
f18df4 |
index 0000000..50a1295
|
|
|
f18df4 |
--- /dev/null
|
|
|
f18df4 |
+++ b/dnf/plugins/module_disable/dnf-command-module_disable.gresource.xml
|
|
|
f18df4 |
@@ -0,0 +1,6 @@
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+<gresources>
|
|
|
f18df4 |
+ <gresource prefix="/org/fedoraproject/dnf/plugins/module_disable">
|
|
|
f18df4 |
+ <file>module_disable.plugin</file>
|
|
|
f18df4 |
+ </gresource>
|
|
|
f18df4 |
+</gresources>
|
|
|
f18df4 |
diff --git a/dnf/plugins/module_disable/dnf-command-module_disable.h b/dnf/plugins/module_disable/dnf-command-module_disable.h
|
|
|
f18df4 |
new file mode 100644
|
|
|
f18df4 |
index 0000000..55f1786
|
|
|
f18df4 |
--- /dev/null
|
|
|
f18df4 |
+++ b/dnf/plugins/module_disable/dnf-command-module_disable.h
|
|
|
f18df4 |
@@ -0,0 +1,33 @@
|
|
|
f18df4 |
+/*
|
|
|
f18df4 |
+ * Copyright (C) 2020 Red Hat, Inc.
|
|
|
f18df4 |
+ *
|
|
|
f18df4 |
+ * Licensed under the GNU Lesser General Public License Version 2.1
|
|
|
f18df4 |
+ *
|
|
|
f18df4 |
+ * This library is free software; you can redistribute it and/or
|
|
|
f18df4 |
+ * modify it under the terms of the GNU Lesser General Public
|
|
|
f18df4 |
+ * License as published by the Free Software Foundation; either
|
|
|
f18df4 |
+ * version 2.1 of the License, or (at your option) any later version.
|
|
|
f18df4 |
+ *
|
|
|
f18df4 |
+ * This library is distributed in the hope that it will be useful,
|
|
|
f18df4 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
f18df4 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
f18df4 |
+ * Lesser General Public License for more details.
|
|
|
f18df4 |
+ *
|
|
|
f18df4 |
+ * You should have received a copy of the GNU Lesser General Public
|
|
|
f18df4 |
+ * License along with this library; if not, write to the Free Software
|
|
|
f18df4 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
f18df4 |
+ */
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+#pragma once
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+#include "dnf-command.h"
|
|
|
f18df4 |
+#include <libpeas/peas.h>
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+G_BEGIN_DECLS
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+#define DNF_TYPE_COMMAND_MODULE_DISABLE dnf_command_module_disable_get_type ()
|
|
|
f18df4 |
+G_DECLARE_FINAL_TYPE (DnfCommandModuleDisable, dnf_command_module_disable, DNF, COMMAND_MODULE_DISABLE, PeasExtensionBase)
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+G_MODULE_EXPORT void dnf_command_module_disable_register_types (PeasObjectModule *module);
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+G_END_DECLS
|
|
|
f18df4 |
diff --git a/dnf/plugins/module_disable/module_disable.plugin b/dnf/plugins/module_disable/module_disable.plugin
|
|
|
f18df4 |
new file mode 100644
|
|
|
f18df4 |
index 0000000..fc1d912
|
|
|
f18df4 |
--- /dev/null
|
|
|
f18df4 |
+++ b/dnf/plugins/module_disable/module_disable.plugin
|
|
|
f18df4 |
@@ -0,0 +1,9 @@
|
|
|
f18df4 |
+[Plugin]
|
|
|
f18df4 |
+Module = command_module_disable
|
|
|
f18df4 |
+Embedded = dnf_command_module_disable_register_types
|
|
|
f18df4 |
+Name = module_disable
|
|
|
f18df4 |
+Description = Disable a module stream
|
|
|
f18df4 |
+Authors = Jaroslav Mracek <jmracek@redhat.com>
|
|
|
f18df4 |
+License = GPL-3.0+
|
|
|
f18df4 |
+Copyright = Copyright (C) 2020 Red Hat, Inc.
|
|
|
f18df4 |
+X-Command-Syntax = module disable module-spec [module-spec…]
|
|
|
f18df4 |
diff --git a/dnf/plugins/module_reset/dnf-command-module_reset.c b/dnf/plugins/module_reset/dnf-command-module_reset.c
|
|
|
f18df4 |
new file mode 100644
|
|
|
f18df4 |
index 0000000..912c53e
|
|
|
f18df4 |
--- /dev/null
|
|
|
f18df4 |
+++ b/dnf/plugins/module_reset/dnf-command-module_reset.c
|
|
|
f18df4 |
@@ -0,0 +1,123 @@
|
|
|
f18df4 |
+/*
|
|
|
f18df4 |
+ * Copyright (C) 2020 Red Hat, Inc.
|
|
|
f18df4 |
+ *
|
|
|
f18df4 |
+ * Licensed under the GNU Lesser General Public License Version 2.1
|
|
|
f18df4 |
+ *
|
|
|
f18df4 |
+ * This library is free software; you can redistribute it and/or
|
|
|
f18df4 |
+ * modify it under the terms of the GNU Lesser General Public
|
|
|
f18df4 |
+ * License as published by the Free Software Foundation; either
|
|
|
f18df4 |
+ * version 2.1 of the License, or (at your option) any later version.
|
|
|
f18df4 |
+ *
|
|
|
f18df4 |
+ * This library is distributed in the hope that it will be useful,
|
|
|
f18df4 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
f18df4 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
f18df4 |
+ * Lesser General Public License for more details.
|
|
|
f18df4 |
+ *
|
|
|
f18df4 |
+ * You should have received a copy of the GNU Lesser General Public
|
|
|
f18df4 |
+ * License along with this library; if not, write to the Free Software
|
|
|
f18df4 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
f18df4 |
+ */
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+#include "dnf-command-module_reset.h"
|
|
|
f18df4 |
+#include "dnf-utils.h"
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+struct _DnfCommandModuleReset
|
|
|
f18df4 |
+{
|
|
|
f18df4 |
+ PeasExtensionBase parent_instance;
|
|
|
f18df4 |
+};
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+static void dnf_command_module_reset_iface_init (DnfCommandInterface *iface);
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+G_DEFINE_DYNAMIC_TYPE_EXTENDED (DnfCommandModuleReset,
|
|
|
f18df4 |
+ dnf_command_module_reset,
|
|
|
f18df4 |
+ PEAS_TYPE_EXTENSION_BASE,
|
|
|
f18df4 |
+ 0,
|
|
|
f18df4 |
+ G_IMPLEMENT_INTERFACE (DNF_TYPE_COMMAND,
|
|
|
f18df4 |
+ dnf_command_module_reset_iface_init))
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+static void
|
|
|
f18df4 |
+dnf_command_module_reset_init (DnfCommandModuleReset *self)
|
|
|
f18df4 |
+{
|
|
|
f18df4 |
+}
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+static gboolean
|
|
|
f18df4 |
+dnf_command_module_reset_run (DnfCommand *cmd,
|
|
|
f18df4 |
+ int argc,
|
|
|
f18df4 |
+ char *argv[],
|
|
|
f18df4 |
+ GOptionContext *opt_ctx,
|
|
|
f18df4 |
+ DnfContext *ctx,
|
|
|
f18df4 |
+ GError **error)
|
|
|
f18df4 |
+{
|
|
|
f18df4 |
+ g_auto(GStrv) pkgs = NULL;
|
|
|
f18df4 |
+ const GOptionEntry opts[] = {
|
|
|
f18df4 |
+ { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &pkgs, NULL, NULL },
|
|
|
f18df4 |
+ { NULL }
|
|
|
f18df4 |
+ };
|
|
|
f18df4 |
+ g_option_context_add_main_entries (opt_ctx, opts, NULL);
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+ if (!g_option_context_parse (opt_ctx, &argc, &argv, error))
|
|
|
f18df4 |
+ return FALSE;
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+ if (pkgs == NULL)
|
|
|
f18df4 |
+ {
|
|
|
f18df4 |
+ g_set_error_literal (error,
|
|
|
f18df4 |
+ G_IO_ERROR,
|
|
|
f18df4 |
+ G_IO_ERROR_FAILED,
|
|
|
f18df4 |
+ "Modules are not specified");
|
|
|
f18df4 |
+ return FALSE;
|
|
|
f18df4 |
+ }
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+ if (!dnf_context_module_reset (ctx, (const char **)pkgs, error))
|
|
|
f18df4 |
+ {
|
|
|
f18df4 |
+ return FALSE;
|
|
|
f18df4 |
+ }
|
|
|
f18df4 |
+ if (!dnf_context_module_switched_check (ctx, error))
|
|
|
f18df4 |
+ {
|
|
|
f18df4 |
+ return FALSE;
|
|
|
f18df4 |
+ }
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+ if (!dnf_goal_depsolve (dnf_context_get_goal (ctx), DNF_NONE, error))
|
|
|
f18df4 |
+ {
|
|
|
f18df4 |
+ if (g_error_matches (*error, DNF_ERROR, DNF_ERROR_NO_PACKAGES_TO_UPDATE))
|
|
|
f18df4 |
+ {
|
|
|
f18df4 |
+ g_clear_error (error);
|
|
|
f18df4 |
+ } else {
|
|
|
f18df4 |
+ return FALSE;
|
|
|
f18df4 |
+ }
|
|
|
f18df4 |
+ }
|
|
|
f18df4 |
+ if (!dnf_utils_print_transaction (ctx))
|
|
|
f18df4 |
+ {
|
|
|
f18df4 |
+ return TRUE;
|
|
|
f18df4 |
+ }
|
|
|
f18df4 |
+ if (!dnf_context_run (ctx, NULL, error))
|
|
|
f18df4 |
+ {
|
|
|
f18df4 |
+ return FALSE;
|
|
|
f18df4 |
+ }
|
|
|
f18df4 |
+ return TRUE;
|
|
|
f18df4 |
+}
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+static void
|
|
|
f18df4 |
+dnf_command_module_reset_class_init (DnfCommandModuleResetClass *klass)
|
|
|
f18df4 |
+{
|
|
|
f18df4 |
+}
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+static void
|
|
|
f18df4 |
+dnf_command_module_reset_iface_init (DnfCommandInterface *iface)
|
|
|
f18df4 |
+{
|
|
|
f18df4 |
+ iface->run = dnf_command_module_reset_run;
|
|
|
f18df4 |
+}
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+static void
|
|
|
f18df4 |
+dnf_command_module_reset_class_finalize (DnfCommandModuleResetClass *klass)
|
|
|
f18df4 |
+{
|
|
|
f18df4 |
+}
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+G_MODULE_EXPORT void
|
|
|
f18df4 |
+dnf_command_module_reset_register_types (PeasObjectModule *module)
|
|
|
f18df4 |
+{
|
|
|
f18df4 |
+ dnf_command_module_reset_register_type (G_TYPE_MODULE (module));
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+ peas_object_module_register_extension_type (module,
|
|
|
f18df4 |
+ DNF_TYPE_COMMAND,
|
|
|
f18df4 |
+ DNF_TYPE_COMMAND_MODULE_RESET);
|
|
|
f18df4 |
+}
|
|
|
f18df4 |
diff --git a/dnf/plugins/module_reset/dnf-command-module_reset.gresource.xml b/dnf/plugins/module_reset/dnf-command-module_reset.gresource.xml
|
|
|
f18df4 |
new file mode 100644
|
|
|
f18df4 |
index 0000000..27e3b15
|
|
|
f18df4 |
--- /dev/null
|
|
|
f18df4 |
+++ b/dnf/plugins/module_reset/dnf-command-module_reset.gresource.xml
|
|
|
f18df4 |
@@ -0,0 +1,6 @@
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+<gresources>
|
|
|
f18df4 |
+ <gresource prefix="/org/fedoraproject/dnf/plugins/module_reset">
|
|
|
f18df4 |
+ <file>module_reset.plugin</file>
|
|
|
f18df4 |
+ </gresource>
|
|
|
f18df4 |
+</gresources>
|
|
|
f18df4 |
diff --git a/dnf/plugins/module_reset/dnf-command-module_reset.h b/dnf/plugins/module_reset/dnf-command-module_reset.h
|
|
|
f18df4 |
new file mode 100644
|
|
|
f18df4 |
index 0000000..65dcd47
|
|
|
f18df4 |
--- /dev/null
|
|
|
f18df4 |
+++ b/dnf/plugins/module_reset/dnf-command-module_reset.h
|
|
|
f18df4 |
@@ -0,0 +1,33 @@
|
|
|
f18df4 |
+/*
|
|
|
f18df4 |
+ * Copyright (C) 2020 Red Hat, Inc.
|
|
|
f18df4 |
+ *
|
|
|
f18df4 |
+ * Licensed under the GNU Lesser General Public License Version 2.1
|
|
|
f18df4 |
+ *
|
|
|
f18df4 |
+ * This library is free software; you can redistribute it and/or
|
|
|
f18df4 |
+ * modify it under the terms of the GNU Lesser General Public
|
|
|
f18df4 |
+ * License as published by the Free Software Foundation; either
|
|
|
f18df4 |
+ * version 2.1 of the License, or (at your option) any later version.
|
|
|
f18df4 |
+ *
|
|
|
f18df4 |
+ * This library is distributed in the hope that it will be useful,
|
|
|
f18df4 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
f18df4 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
f18df4 |
+ * Lesser General Public License for more details.
|
|
|
f18df4 |
+ *
|
|
|
f18df4 |
+ * You should have received a copy of the GNU Lesser General Public
|
|
|
f18df4 |
+ * License along with this library; if not, write to the Free Software
|
|
|
f18df4 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
f18df4 |
+ */
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+#pragma once
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+#include "dnf-command.h"
|
|
|
f18df4 |
+#include <libpeas/peas.h>
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+G_BEGIN_DECLS
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+#define DNF_TYPE_COMMAND_MODULE_RESET dnf_command_module_reset_get_type ()
|
|
|
f18df4 |
+G_DECLARE_FINAL_TYPE (DnfCommandModuleReset, dnf_command_module_reset, DNF, COMMAND_MODULE_RESET, PeasExtensionBase)
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+G_MODULE_EXPORT void dnf_command_module_reset_register_types (PeasObjectModule *module);
|
|
|
f18df4 |
+
|
|
|
f18df4 |
+G_END_DECLS
|
|
|
f18df4 |
diff --git a/dnf/plugins/module_reset/module_reset.plugin b/dnf/plugins/module_reset/module_reset.plugin
|
|
|
f18df4 |
new file mode 100644
|
|
|
f18df4 |
index 0000000..c680f08
|
|
|
f18df4 |
--- /dev/null
|
|
|
f18df4 |
+++ b/dnf/plugins/module_reset/module_reset.plugin
|
|
|
f18df4 |
@@ -0,0 +1,9 @@
|
|
|
f18df4 |
+[Plugin]
|
|
|
f18df4 |
+Module = command_module_reset
|
|
|
f18df4 |
+Embedded = dnf_command_module_reset_register_types
|
|
|
f18df4 |
+Name = module_reset
|
|
|
f18df4 |
+Description = Reset a module stream
|
|
|
f18df4 |
+Authors = Jaroslav Mracek <jmracek@redhat.com>
|
|
|
f18df4 |
+License = GPL-3.0+
|
|
|
f18df4 |
+Copyright = Copyright (C) 2020 Red Hat, Inc.
|
|
|
f18df4 |
+X-Command-Syntax = module reset module-spec [module-spec…]
|
|
|
f18df4 |
--
|
|
|
f18df4 |
2.26.2
|
|
|
f18df4 |
|