diff --git a/SOURCES/0001-Add-module-enable-disable-reset-command.patch b/SOURCES/0001-Add-module-enable-disable-reset-command.patch new file mode 100644 index 0000000..f53eee7 --- /dev/null +++ b/SOURCES/0001-Add-module-enable-disable-reset-command.patch @@ -0,0 +1,997 @@ +From fa7e624c50dbfc0e47c0466e47f2f6acd20a6dff Mon Sep 17 00:00:00 2001 +From: Jaroslav Rohel <jrohel@redhat.com> +Date: Fri, 30 Oct 2020 13:45:17 +0100 +Subject: [PATCH 1/5] Add subcommands support + +Plugins with a '_' character in command name will implement subcommands. +Needed for modularity subcommands. +E.g. the "command_module_enable" plugin will implement the "enable" +subcommand of the "module" command. +--- + dnf/dnf-main.c | 96 +++++++++++++++++++++++++++++++++++++++----------- + 1 file changed, 76 insertions(+), 20 deletions(-) + +diff --git a/dnf/dnf-main.c b/dnf/dnf-main.c +index b6a5a69..6cb8c0e 100644 +--- a/dnf/dnf-main.c ++++ b/dnf/dnf-main.c +@@ -305,6 +305,33 @@ new_global_opt_group (DnfContext *ctx) + return opt_grp; + } + ++/* ++ * The first non-option is the command/subcommand. ++ * Get it and remove it from arguments. ++ */ ++static const gchar * ++get_command (int *argc, ++ char *argv[]) ++{ ++ const gchar *cmd_name = NULL; ++ for (gint in = 1; in < *argc; in++) ++ { ++ if (cmd_name != NULL) ++ argv[in-1] = argv[in]; ++ else if (argv[in][0] != '-') ++ cmd_name = argv[in]; ++ } ++ if (cmd_name != NULL) --*argc; ++ return cmd_name; ++} ++ ++static gint ++compare_strings (gconstpointer a, ++ gconstpointer b) ++{ ++ return strcmp (a, b); ++} ++ + int + main (int argc, + char *argv[]) +@@ -316,6 +343,7 @@ main (int argc, + g_autoptr(GOptionContext) opt_ctx = g_option_context_new ("COMMAND"); + g_autoptr(GOptionContext) subcmd_opt_ctx = NULL; + g_autofree gchar *subcmd_opt_param = NULL; ++ GSList *cmds_with_subcmds = NULL; /* list of commands with subcommands */ + + setlocale (LC_ALL, ""); + +@@ -353,11 +381,26 @@ main (int argc, + if (!peas_engine_load_plugin (engine, info)) + continue; + if (peas_engine_provides_extension (engine, info, DNF_TYPE_COMMAND)) +- /* +- * At least 2 spaces between the command and its description are needed +- * so that help2man formats it correctly. +- */ +- g_string_append_printf (cmd_summary, "\n %-16s %s", peas_plugin_info_get_name (info), peas_plugin_info_get_description (info)); ++ { ++ g_autofree gchar *command_name = g_strdup (peas_plugin_info_get_name (info)); ++ ++ /* Plugins with a '_' character in command name implement subcommands. ++ E.g. the "command_module_enable" plugin implements the "enable" subcommand of the "module" command. */ ++ for (gchar *ptr = command_name; *ptr != '\0'; ++ptr) ++ { ++ if (*ptr == '_') ++ { ++ *ptr = ' '; ++ cmds_with_subcmds = g_slist_append (cmds_with_subcmds, g_strndup (command_name, ptr - command_name)); ++ break; ++ } ++ } ++ /* ++ * At least 2 spaces between the command and its description are needed ++ * so that help2man formats it correctly. ++ */ ++ g_string_append_printf (cmd_summary, "\n %-16s %s", command_name, peas_plugin_info_get_description (info)); ++ } + } + g_option_context_set_summary (opt_ctx, cmd_summary->str); + g_string_free (cmd_summary, TRUE); +@@ -471,19 +514,7 @@ main (int argc, + } + } + +- /* +- * The first non-option is the command. +- * Get it and remove it from arguments. +- */ +- const gchar *cmd_name = NULL; +- for (gint in = 1; in < argc; in++) +- { +- if (cmd_name != NULL) +- argv[in-1] = argv[in]; +- else if (argv[in][0] != '-') +- cmd_name = argv[in]; +- } +- if (cmd_name != NULL) --argc; ++ const gchar *cmd_name = get_command (&argc, argv); + + g_option_context_set_help_enabled (opt_ctx, TRUE); + +@@ -500,10 +531,25 @@ main (int argc, + + PeasPluginInfo *plug = NULL; + PeasExtension *exten = NULL; +- if (cmd_name != NULL) ++ const gchar *subcmd_name = NULL; ++ gboolean with_subcmds = FALSE; ++ ++ /* Find the plugin that implements the command cmd_name or its subcommand. ++ * Command name (cmd_name) can not contain '_' character. It is reserved for subcomands. */ ++ if (cmd_name != NULL && strchr(cmd_name, '_') == NULL) + { ++ with_subcmds = g_slist_find_custom (cmds_with_subcmds, cmd_name, compare_strings) != NULL; + g_autofree gchar *mod_name = g_strdup_printf ("command_%s", cmd_name); + plug = peas_engine_get_plugin_info (engine, mod_name); ++ if (plug == NULL && with_subcmds) ++ { ++ subcmd_name = get_command (&argc, argv); ++ if (subcmd_name != NULL) ++ { ++ g_autofree gchar *submod_name = g_strdup_printf ("command_%s_%s", cmd_name, subcmd_name); ++ plug = peas_engine_get_plugin_info (engine, submod_name); ++ } ++ } + if (plug != NULL) + exten = peas_extension_set_get_extension (cmd_exts, plug); + } +@@ -513,10 +559,18 @@ main (int argc, + error = g_error_new_literal (G_IO_ERROR, + G_IO_ERROR_FAILED, + "No command specified"); +- else ++ else if (!with_subcmds) + error = g_error_new (G_IO_ERROR, + G_IO_ERROR_FAILED, + "Unknown command: '%s'", cmd_name); ++ else if (subcmd_name) ++ error = g_error_new (G_IO_ERROR, ++ G_IO_ERROR_FAILED, ++ "Unknown subcommand: '%s'", subcmd_name); ++ else ++ error = g_error_new (G_IO_ERROR, ++ G_IO_ERROR_FAILED, ++ "Missing subcommand for command: '%s'", cmd_name); + + g_autofree gchar *help = g_option_context_get_help (opt_ctx, TRUE, NULL); + g_printerr ("This is microdnf, which implements subset of `dnf'.\n" +@@ -533,6 +587,8 @@ main (int argc, + goto out; + + out: ++ g_slist_free_full(cmds_with_subcmds, g_free); ++ + if (error != NULL) + { + const gchar *prefix = ""; +-- +2.26.2 + + +From 88a2b95ebdc424091b93c381623bdb458a368b48 Mon Sep 17 00:00:00 2001 +From: Jaroslav Rohel <jrohel@redhat.com> +Date: Fri, 30 Oct 2020 14:16:34 +0100 +Subject: [PATCH 2/5] Add "module enable" command + +--- + dnf/CMakeLists.txt | 9 +- + dnf/meson.build | 9 ++ + .../module_enable/dnf-command-module_enable.c | 97 +++++++++++++++++++ + .../dnf-command-module_enable.gresource.xml | 6 ++ + .../module_enable/dnf-command-module_enable.h | 33 +++++++ + .../module_enable/module_enable.plugin | 9 ++ + microdnf.spec | 2 +- + 7 files changed, 163 insertions(+), 2 deletions(-) + create mode 100644 dnf/plugins/module_enable/dnf-command-module_enable.c + create mode 100644 dnf/plugins/module_enable/dnf-command-module_enable.gresource.xml + create mode 100644 dnf/plugins/module_enable/dnf-command-module_enable.h + create mode 100644 dnf/plugins/module_enable/module_enable.plugin + +diff --git a/dnf/CMakeLists.txt b/dnf/CMakeLists.txt +index 0705390..b673ce4 100644 +--- a/dnf/CMakeLists.txt ++++ b/dnf/CMakeLists.txt +@@ -35,6 +35,12 @@ glib_compile_resources (DNF_COMMAND_CLEAN plugins/clean/dnf-command-clean.gresou + INTERNAL) + list (APPEND DNF_COMMAND_CLEAN "plugins/clean/dnf-command-clean.c") + ++glib_compile_resources (DNF_COMMAND_MODULE_ENABLE plugins/module_enable/dnf-command-module_enable.gresource.xml ++ C_PREFIX dnf_command_module_enable ++ INTERNAL) ++list (APPEND DNF_COMMAND_MODULE_ENABLE "plugins/module_enable/dnf-command-module_enable.c") ++ ++ + include_directories (${CMAKE_CURRENT_SOURCE_DIR}) + add_executable (microdnf dnf-main.c ${DNF_SRCS} + ${DNF_COMMAND_INSTALL} +@@ -43,7 +49,8 @@ add_executable (microdnf dnf-main.c ${DNF_SRCS} + ${DNF_COMMAND_UPDATE} + ${DNF_COMMAND_REPOLIST} + ${DNF_COMMAND_REPOQUERY} +- ${DNF_COMMAND_CLEAN}) ++ ${DNF_COMMAND_CLEAN} ++ ${DNF_COMMAND_MODULE_ENABLE}) + + target_link_libraries (microdnf + ${GLIB_LIBRARIES} +diff --git a/dnf/meson.build b/dnf/meson.build +index 12e11ac..d617453 100644 +--- a/dnf/meson.build ++++ b/dnf/meson.build +@@ -65,6 +65,15 @@ microdnf_srcs = [ + source_dir : 'plugins/clean', + ), + 'plugins/clean/dnf-command-clean.c', ++ ++ # module enable ++ gnome.compile_resources( ++ 'dnf-module_enable', ++ 'plugins/module_enable/dnf-command-module_enable.gresource.xml', ++ c_name : 'dnf_command_module_enable', ++ source_dir : 'plugins/module_enable', ++ ), ++ 'plugins/module_enable/dnf-command-module_enable.c', + ] + + microdnf = executable( +diff --git a/dnf/plugins/module_enable/dnf-command-module_enable.c b/dnf/plugins/module_enable/dnf-command-module_enable.c +new file mode 100644 +index 0000000..3081042 +--- /dev/null ++++ b/dnf/plugins/module_enable/dnf-command-module_enable.c +@@ -0,0 +1,97 @@ ++/* ++ * Copyright (C) 2020 Red Hat, Inc. ++ * ++ * Licensed under the GNU Lesser General Public License Version 2.1 ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ++ */ ++ ++#include "dnf-command-module_enable.h" ++#include "dnf-utils.h" ++ ++struct _DnfCommandModuleEnable ++{ ++ PeasExtensionBase parent_instance; ++}; ++ ++static void dnf_command_module_enable_iface_init (DnfCommandInterface *iface); ++ ++G_DEFINE_DYNAMIC_TYPE_EXTENDED (DnfCommandModuleEnable, ++ dnf_command_module_enable, ++ PEAS_TYPE_EXTENSION_BASE, ++ 0, ++ G_IMPLEMENT_INTERFACE (DNF_TYPE_COMMAND, ++ dnf_command_module_enable_iface_init)) ++ ++static void ++dnf_command_module_enable_init (DnfCommandModuleEnable *self) ++{ ++} ++ ++static gboolean ++dnf_command_module_enable_run (DnfCommand *cmd, ++ int argc, ++ char *argv[], ++ GOptionContext *opt_ctx, ++ DnfContext *ctx, ++ GError **error) ++{ ++ g_auto(GStrv) pkgs = NULL; ++ const GOptionEntry opts[] = { ++ { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &pkgs, NULL, NULL }, ++ { NULL } ++ }; ++ g_option_context_add_main_entries (opt_ctx, opts, NULL); ++ ++ if (!g_option_context_parse (opt_ctx, &argc, &argv, error)) ++ return FALSE; ++ ++ if (pkgs == NULL) ++ { ++ g_set_error_literal (error, ++ G_IO_ERROR, ++ G_IO_ERROR_FAILED, ++ "Modules are not specified"); ++ return FALSE; ++ } ++ ++ return dnf_context_enable_modules (ctx, (const char **)pkgs, error); ++} ++ ++static void ++dnf_command_module_enable_class_init (DnfCommandModuleEnableClass *klass) ++{ ++} ++ ++static void ++dnf_command_module_enable_iface_init (DnfCommandInterface *iface) ++{ ++ iface->run = dnf_command_module_enable_run; ++} ++ ++static void ++dnf_command_module_enable_class_finalize (DnfCommandModuleEnableClass *klass) ++{ ++} ++ ++G_MODULE_EXPORT void ++dnf_command_module_enable_register_types (PeasObjectModule *module) ++{ ++ dnf_command_module_enable_register_type (G_TYPE_MODULE (module)); ++ ++ peas_object_module_register_extension_type (module, ++ DNF_TYPE_COMMAND, ++ DNF_TYPE_COMMAND_MODULE_ENABLE); ++} +diff --git a/dnf/plugins/module_enable/dnf-command-module_enable.gresource.xml b/dnf/plugins/module_enable/dnf-command-module_enable.gresource.xml +new file mode 100644 +index 0000000..4b99047 +--- /dev/null ++++ b/dnf/plugins/module_enable/dnf-command-module_enable.gresource.xml +@@ -0,0 +1,6 @@ ++<?xml version="1.0" encoding="UTF-8"?> ++<gresources> ++ <gresource prefix="/org/fedoraproject/dnf/plugins/module_enable"> ++ <file>module_enable.plugin</file> ++ </gresource> ++</gresources> +diff --git a/dnf/plugins/module_enable/dnf-command-module_enable.h b/dnf/plugins/module_enable/dnf-command-module_enable.h +new file mode 100644 +index 0000000..d489331 +--- /dev/null ++++ b/dnf/plugins/module_enable/dnf-command-module_enable.h +@@ -0,0 +1,33 @@ ++/* ++ * Copyright (C) 2020 Red Hat, Inc. ++ * ++ * Licensed under the GNU Lesser General Public License Version 2.1 ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ++ */ ++ ++#pragma once ++ ++#include "dnf-command.h" ++#include <libpeas/peas.h> ++ ++G_BEGIN_DECLS ++ ++#define DNF_TYPE_COMMAND_MODULE_ENABLE dnf_command_module_enable_get_type () ++G_DECLARE_FINAL_TYPE (DnfCommandModuleEnable, dnf_command_module_enable, DNF, COMMAND_MODULE_ENABLE, PeasExtensionBase) ++ ++G_MODULE_EXPORT void dnf_command_module_enable_register_types (PeasObjectModule *module); ++ ++G_END_DECLS +diff --git a/dnf/plugins/module_enable/module_enable.plugin b/dnf/plugins/module_enable/module_enable.plugin +new file mode 100644 +index 0000000..91da9fb +--- /dev/null ++++ b/dnf/plugins/module_enable/module_enable.plugin +@@ -0,0 +1,9 @@ ++[Plugin] ++Module = command_module_enable ++Embedded = dnf_command_module_enable_register_types ++Name = module_enable ++Description = Enable a module stream ++Authors = Jaroslav Rohel <jrohel@redhat.com> ++License = GPL-3.0+ ++Copyright = Copyright (C) 2020 Red Hat, Inc. ++X-Command-Syntax = module enable module-spec [module-spec…] +diff --git a/microdnf.spec b/microdnf.spec +index db8e35e..3648e46 100644 +--- a/microdnf.spec ++++ b/microdnf.spec +@@ -1,4 +1,4 @@ +-%global libdnf_version 0.43.1 ++%global libdnf_version 0.55.0 + + Name: microdnf + Version: 3.4.0 +-- +2.26.2 + + +From 7cc7bb7202cb79d6bb6daa63e32109134c273627 Mon Sep 17 00:00:00 2001 +From: Jaroslav Mracek <jmracek@redhat.com> +Date: Fri, 23 Oct 2020 16:04:48 +0200 +Subject: [PATCH 3/5] Add reports of module changes + +--- + dnf/dnf-utils.c | 16 ++++++++++++++-- + 1 file changed, 14 insertions(+), 2 deletions(-) + +diff --git a/dnf/dnf-utils.c b/dnf/dnf-utils.c +index c58f519..5984f22 100644 +--- a/dnf/dnf-utils.c ++++ b/dnf/dnf-utils.c +@@ -68,8 +68,15 @@ dnf_utils_print_transaction (DnfContext *ctx) + + if (pkgs->len == 0) + { +- g_print ("Nothing to do.\n"); +- return FALSE; ++ g_autofree char * report = dnf_context_get_module_report (ctx); ++ if (report) ++ { ++ g_print ("%s\n", report); ++ return TRUE; ++ } else { ++ g_print ("Nothing to do.\n"); ++ return FALSE; ++ } + } + + struct libscols_line *ln; +@@ -147,6 +154,11 @@ dnf_utils_print_transaction (DnfContext *ctx) + g_print (" %-15s %4d packages\n", "Removing:", pkgs_remove->len); + g_print (" %-15s %4d packages\n", "Downgrading:", pkgs_downgrade->len); + ++ g_autofree char * report = dnf_context_get_module_report (ctx); ++ if (report) ++ { ++ g_print ("%s\n", report); ++ } + /* check for test mode */ + DnfTransaction *txn = dnf_context_get_transaction (ctx); + if (dnf_transaction_get_flags (txn) & DNF_TRANSACTION_FLAG_TEST) +-- +2.26.2 + + +From 6c4dceac5012231923187c3bbb16de4bda23789c Mon Sep 17 00:00:00 2001 +From: Jaroslav Mracek <jmracek@redhat.com> +Date: Mon, 2 Nov 2020 12:05:01 +0100 +Subject: [PATCH 4/5] Allow to commit module changes and report module switch + as an error + +--- + .../module_enable/dnf-command-module_enable.c | 28 ++++++++++++++++++- + 1 file changed, 27 insertions(+), 1 deletion(-) + +diff --git a/dnf/plugins/module_enable/dnf-command-module_enable.c b/dnf/plugins/module_enable/dnf-command-module_enable.c +index 3081042..a5a4701 100644 +--- a/dnf/plugins/module_enable/dnf-command-module_enable.c ++++ b/dnf/plugins/module_enable/dnf-command-module_enable.c +@@ -67,7 +67,33 @@ dnf_command_module_enable_run (DnfCommand *cmd, + return FALSE; + } + +- return dnf_context_enable_modules (ctx, (const char **)pkgs, error); ++ if (!dnf_context_module_enable (ctx, (const char **)pkgs, error)) ++ { ++ return FALSE; ++ } ++ if (!dnf_context_module_switched_check (ctx, error)) ++ { ++ return FALSE; ++ } ++ ++ if (!dnf_goal_depsolve (dnf_context_get_goal (ctx), DNF_NONE, error)) ++ { ++ if (g_error_matches (*error, DNF_ERROR, DNF_ERROR_NO_PACKAGES_TO_UPDATE)) ++ { ++ g_clear_error (error); ++ } else { ++ return FALSE; ++ } ++ } ++ if (!dnf_utils_print_transaction (ctx)) ++ { ++ return TRUE; ++ } ++ if (!dnf_context_run (ctx, NULL, error)) ++ { ++ return FALSE; ++ } ++ return TRUE; + } + + static void +-- +2.26.2 + + +From 6c86306c9c0725c73c3d4ec704f932e372e09585 Mon Sep 17 00:00:00 2001 +From: Jaroslav Mracek <jmracek@redhat.com> +Date: Mon, 2 Nov 2020 15:17:29 +0100 +Subject: [PATCH 5/5] Add module enable and disable commands + +--- + dnf/CMakeLists.txt | 14 +- + dnf/meson.build | 18 +++ + .../dnf-command-module_disable.c | 119 +++++++++++++++++ + .../dnf-command-module_disable.gresource.xml | 6 + + .../dnf-command-module_disable.h | 33 +++++ + .../module_disable/module_disable.plugin | 9 ++ + .../module_reset/dnf-command-module_reset.c | 123 ++++++++++++++++++ + .../dnf-command-module_reset.gresource.xml | 6 + + .../module_reset/dnf-command-module_reset.h | 33 +++++ + dnf/plugins/module_reset/module_reset.plugin | 9 ++ + 10 files changed, 369 insertions(+), 1 deletion(-) + create mode 100644 dnf/plugins/module_disable/dnf-command-module_disable.c + create mode 100644 dnf/plugins/module_disable/dnf-command-module_disable.gresource.xml + create mode 100644 dnf/plugins/module_disable/dnf-command-module_disable.h + create mode 100644 dnf/plugins/module_disable/module_disable.plugin + create mode 100644 dnf/plugins/module_reset/dnf-command-module_reset.c + create mode 100644 dnf/plugins/module_reset/dnf-command-module_reset.gresource.xml + create mode 100644 dnf/plugins/module_reset/dnf-command-module_reset.h + create mode 100644 dnf/plugins/module_reset/module_reset.plugin + +diff --git a/dnf/CMakeLists.txt b/dnf/CMakeLists.txt +index b673ce4..1d640be 100644 +--- a/dnf/CMakeLists.txt ++++ b/dnf/CMakeLists.txt +@@ -40,6 +40,16 @@ glib_compile_resources (DNF_COMMAND_MODULE_ENABLE plugins/module_enable/dnf-comm + INTERNAL) + list (APPEND DNF_COMMAND_MODULE_ENABLE "plugins/module_enable/dnf-command-module_enable.c") + ++glib_compile_resources (DNF_COMMAND_MODULE_DISABLE plugins/module_disable/dnf-command-module_disable.gresource.xml ++ C_PREFIX dnf_command_module_disable ++ INTERNAL) ++list (APPEND DNF_COMMAND_MODULE_DISABLE "plugins/module_disable/dnf-command-module_disable.c") ++ ++glib_compile_resources (DNF_COMMAND_MODULE_RESET plugins/module_reset/dnf-command-module_reset.gresource.xml ++ C_PREFIX dnf_command_module_reset ++ INTERNAL) ++list (APPEND DNF_COMMAND_MODULE_RESET "plugins/module_reset/dnf-command-module_reset.c") ++ + + include_directories (${CMAKE_CURRENT_SOURCE_DIR}) + add_executable (microdnf dnf-main.c ${DNF_SRCS} +@@ -50,7 +60,9 @@ add_executable (microdnf dnf-main.c ${DNF_SRCS} + ${DNF_COMMAND_REPOLIST} + ${DNF_COMMAND_REPOQUERY} + ${DNF_COMMAND_CLEAN} +- ${DNF_COMMAND_MODULE_ENABLE}) ++ ${DNF_COMMAND_MODULE_ENABLE} ++ ${DNF_COMMAND_MODULE_DISABLE} ++ ${DNF_COMMAND_MODULE_RESET}) + + target_link_libraries (microdnf + ${GLIB_LIBRARIES} +diff --git a/dnf/meson.build b/dnf/meson.build +index d617453..b456202 100644 +--- a/dnf/meson.build ++++ b/dnf/meson.build +@@ -74,6 +74,24 @@ microdnf_srcs = [ + source_dir : 'plugins/module_enable', + ), + 'plugins/module_enable/dnf-command-module_enable.c', ++ ++ # module disable ++ gnome.compile_resources( ++ 'dnf-module_disable', ++ 'plugins/module_disable/dnf-command-module_disable.gresource.xml', ++ c_name : 'dnf_command_module_disable', ++ source_dir : 'plugins/module_disable', ++ ), ++ 'plugins/module_disable/dnf-command-module_disable.c', ++ ++ # module reset ++ gnome.compile_resources( ++ 'dnf-module_reset', ++ 'plugins/module_reset/dnf-command-module_reset.gresource.xml', ++ c_name : 'dnf_command_module_reset', ++ source_dir : 'plugins/module_reset', ++ ), ++ 'plugins/module_reset/dnf-command-module_reset.c', + ] + + microdnf = executable( +diff --git a/dnf/plugins/module_disable/dnf-command-module_disable.c b/dnf/plugins/module_disable/dnf-command-module_disable.c +new file mode 100644 +index 0000000..eedb77c +--- /dev/null ++++ b/dnf/plugins/module_disable/dnf-command-module_disable.c +@@ -0,0 +1,119 @@ ++/* ++ * Copyright (C) 2020 Red Hat, Inc. ++ * ++ * Licensed under the GNU Lesser General Public License Version 2.1 ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ++ */ ++ ++#include "dnf-command-module_disable.h" ++#include "dnf-utils.h" ++ ++struct _DnfCommandModuleDisable ++{ ++ PeasExtensionBase parent_instance; ++}; ++ ++static void dnf_command_module_disable_iface_init (DnfCommandInterface *iface); ++ ++G_DEFINE_DYNAMIC_TYPE_EXTENDED (DnfCommandModuleDisable, ++ dnf_command_module_disable, ++ PEAS_TYPE_EXTENSION_BASE, ++ 0, ++ G_IMPLEMENT_INTERFACE (DNF_TYPE_COMMAND, ++ dnf_command_module_disable_iface_init)) ++ ++static void ++dnf_command_module_disable_init (DnfCommandModuleDisable *self) ++{ ++} ++ ++static gboolean ++dnf_command_module_disable_run (DnfCommand *cmd, ++ int argc, ++ char *argv[], ++ GOptionContext *opt_ctx, ++ DnfContext *ctx, ++ GError **error) ++{ ++ g_auto(GStrv) pkgs = NULL; ++ const GOptionEntry opts[] = { ++ { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &pkgs, NULL, NULL }, ++ { NULL } ++ }; ++ g_option_context_add_main_entries (opt_ctx, opts, NULL); ++ ++ if (!g_option_context_parse (opt_ctx, &argc, &argv, error)) ++ return FALSE; ++ ++ if (pkgs == NULL) ++ { ++ g_set_error_literal (error, ++ G_IO_ERROR, ++ G_IO_ERROR_FAILED, ++ "Modules are not specified"); ++ return FALSE; ++ } ++ ++ if (!dnf_context_module_disable (ctx, (const char **)pkgs, error)) ++ { ++ return FALSE; ++ } ++ ++ if (!dnf_goal_depsolve (dnf_context_get_goal (ctx), DNF_NONE, error)) ++ { ++ if (g_error_matches (*error, DNF_ERROR, DNF_ERROR_NO_PACKAGES_TO_UPDATE)) ++ { ++ g_clear_error (error); ++ } else { ++ return FALSE; ++ } ++ } ++ if (!dnf_utils_print_transaction (ctx)) ++ { ++ return TRUE; ++ } ++ if (!dnf_context_run (ctx, NULL, error)) ++ { ++ return FALSE; ++ } ++ return TRUE; ++} ++ ++static void ++dnf_command_module_disable_class_init (DnfCommandModuleDisableClass *klass) ++{ ++} ++ ++static void ++dnf_command_module_disable_iface_init (DnfCommandInterface *iface) ++{ ++ iface->run = dnf_command_module_disable_run; ++} ++ ++static void ++dnf_command_module_disable_class_finalize (DnfCommandModuleDisableClass *klass) ++{ ++} ++ ++G_MODULE_EXPORT void ++dnf_command_module_disable_register_types (PeasObjectModule *module) ++{ ++ dnf_command_module_disable_register_type (G_TYPE_MODULE (module)); ++ ++ peas_object_module_register_extension_type (module, ++ DNF_TYPE_COMMAND, ++ DNF_TYPE_COMMAND_MODULE_DISABLE); ++} +diff --git a/dnf/plugins/module_disable/dnf-command-module_disable.gresource.xml b/dnf/plugins/module_disable/dnf-command-module_disable.gresource.xml +new file mode 100644 +index 0000000..50a1295 +--- /dev/null ++++ b/dnf/plugins/module_disable/dnf-command-module_disable.gresource.xml +@@ -0,0 +1,6 @@ ++<?xml version="1.0" encoding="UTF-8"?> ++<gresources> ++ <gresource prefix="/org/fedoraproject/dnf/plugins/module_disable"> ++ <file>module_disable.plugin</file> ++ </gresource> ++</gresources> +diff --git a/dnf/plugins/module_disable/dnf-command-module_disable.h b/dnf/plugins/module_disable/dnf-command-module_disable.h +new file mode 100644 +index 0000000..55f1786 +--- /dev/null ++++ b/dnf/plugins/module_disable/dnf-command-module_disable.h +@@ -0,0 +1,33 @@ ++/* ++ * Copyright (C) 2020 Red Hat, Inc. ++ * ++ * Licensed under the GNU Lesser General Public License Version 2.1 ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ++ */ ++ ++#pragma once ++ ++#include "dnf-command.h" ++#include <libpeas/peas.h> ++ ++G_BEGIN_DECLS ++ ++#define DNF_TYPE_COMMAND_MODULE_DISABLE dnf_command_module_disable_get_type () ++G_DECLARE_FINAL_TYPE (DnfCommandModuleDisable, dnf_command_module_disable, DNF, COMMAND_MODULE_DISABLE, PeasExtensionBase) ++ ++G_MODULE_EXPORT void dnf_command_module_disable_register_types (PeasObjectModule *module); ++ ++G_END_DECLS +diff --git a/dnf/plugins/module_disable/module_disable.plugin b/dnf/plugins/module_disable/module_disable.plugin +new file mode 100644 +index 0000000..fc1d912 +--- /dev/null ++++ b/dnf/plugins/module_disable/module_disable.plugin +@@ -0,0 +1,9 @@ ++[Plugin] ++Module = command_module_disable ++Embedded = dnf_command_module_disable_register_types ++Name = module_disable ++Description = Disable a module stream ++Authors = Jaroslav Mracek <jmracek@redhat.com> ++License = GPL-3.0+ ++Copyright = Copyright (C) 2020 Red Hat, Inc. ++X-Command-Syntax = module disable module-spec [module-spec…] +diff --git a/dnf/plugins/module_reset/dnf-command-module_reset.c b/dnf/plugins/module_reset/dnf-command-module_reset.c +new file mode 100644 +index 0000000..912c53e +--- /dev/null ++++ b/dnf/plugins/module_reset/dnf-command-module_reset.c +@@ -0,0 +1,123 @@ ++/* ++ * Copyright (C) 2020 Red Hat, Inc. ++ * ++ * Licensed under the GNU Lesser General Public License Version 2.1 ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ++ */ ++ ++#include "dnf-command-module_reset.h" ++#include "dnf-utils.h" ++ ++struct _DnfCommandModuleReset ++{ ++ PeasExtensionBase parent_instance; ++}; ++ ++static void dnf_command_module_reset_iface_init (DnfCommandInterface *iface); ++ ++G_DEFINE_DYNAMIC_TYPE_EXTENDED (DnfCommandModuleReset, ++ dnf_command_module_reset, ++ PEAS_TYPE_EXTENSION_BASE, ++ 0, ++ G_IMPLEMENT_INTERFACE (DNF_TYPE_COMMAND, ++ dnf_command_module_reset_iface_init)) ++ ++static void ++dnf_command_module_reset_init (DnfCommandModuleReset *self) ++{ ++} ++ ++static gboolean ++dnf_command_module_reset_run (DnfCommand *cmd, ++ int argc, ++ char *argv[], ++ GOptionContext *opt_ctx, ++ DnfContext *ctx, ++ GError **error) ++{ ++ g_auto(GStrv) pkgs = NULL; ++ const GOptionEntry opts[] = { ++ { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &pkgs, NULL, NULL }, ++ { NULL } ++ }; ++ g_option_context_add_main_entries (opt_ctx, opts, NULL); ++ ++ if (!g_option_context_parse (opt_ctx, &argc, &argv, error)) ++ return FALSE; ++ ++ if (pkgs == NULL) ++ { ++ g_set_error_literal (error, ++ G_IO_ERROR, ++ G_IO_ERROR_FAILED, ++ "Modules are not specified"); ++ return FALSE; ++ } ++ ++ if (!dnf_context_module_reset (ctx, (const char **)pkgs, error)) ++ { ++ return FALSE; ++ } ++ if (!dnf_context_module_switched_check (ctx, error)) ++ { ++ return FALSE; ++ } ++ ++ if (!dnf_goal_depsolve (dnf_context_get_goal (ctx), DNF_NONE, error)) ++ { ++ if (g_error_matches (*error, DNF_ERROR, DNF_ERROR_NO_PACKAGES_TO_UPDATE)) ++ { ++ g_clear_error (error); ++ } else { ++ return FALSE; ++ } ++ } ++ if (!dnf_utils_print_transaction (ctx)) ++ { ++ return TRUE; ++ } ++ if (!dnf_context_run (ctx, NULL, error)) ++ { ++ return FALSE; ++ } ++ return TRUE; ++} ++ ++static void ++dnf_command_module_reset_class_init (DnfCommandModuleResetClass *klass) ++{ ++} ++ ++static void ++dnf_command_module_reset_iface_init (DnfCommandInterface *iface) ++{ ++ iface->run = dnf_command_module_reset_run; ++} ++ ++static void ++dnf_command_module_reset_class_finalize (DnfCommandModuleResetClass *klass) ++{ ++} ++ ++G_MODULE_EXPORT void ++dnf_command_module_reset_register_types (PeasObjectModule *module) ++{ ++ dnf_command_module_reset_register_type (G_TYPE_MODULE (module)); ++ ++ peas_object_module_register_extension_type (module, ++ DNF_TYPE_COMMAND, ++ DNF_TYPE_COMMAND_MODULE_RESET); ++} +diff --git a/dnf/plugins/module_reset/dnf-command-module_reset.gresource.xml b/dnf/plugins/module_reset/dnf-command-module_reset.gresource.xml +new file mode 100644 +index 0000000..27e3b15 +--- /dev/null ++++ b/dnf/plugins/module_reset/dnf-command-module_reset.gresource.xml +@@ -0,0 +1,6 @@ ++<?xml version="1.0" encoding="UTF-8"?> ++<gresources> ++ <gresource prefix="/org/fedoraproject/dnf/plugins/module_reset"> ++ <file>module_reset.plugin</file> ++ </gresource> ++</gresources> +diff --git a/dnf/plugins/module_reset/dnf-command-module_reset.h b/dnf/plugins/module_reset/dnf-command-module_reset.h +new file mode 100644 +index 0000000..65dcd47 +--- /dev/null ++++ b/dnf/plugins/module_reset/dnf-command-module_reset.h +@@ -0,0 +1,33 @@ ++/* ++ * Copyright (C) 2020 Red Hat, Inc. ++ * ++ * Licensed under the GNU Lesser General Public License Version 2.1 ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ++ */ ++ ++#pragma once ++ ++#include "dnf-command.h" ++#include <libpeas/peas.h> ++ ++G_BEGIN_DECLS ++ ++#define DNF_TYPE_COMMAND_MODULE_RESET dnf_command_module_reset_get_type () ++G_DECLARE_FINAL_TYPE (DnfCommandModuleReset, dnf_command_module_reset, DNF, COMMAND_MODULE_RESET, PeasExtensionBase) ++ ++G_MODULE_EXPORT void dnf_command_module_reset_register_types (PeasObjectModule *module); ++ ++G_END_DECLS +diff --git a/dnf/plugins/module_reset/module_reset.plugin b/dnf/plugins/module_reset/module_reset.plugin +new file mode 100644 +index 0000000..c680f08 +--- /dev/null ++++ b/dnf/plugins/module_reset/module_reset.plugin +@@ -0,0 +1,9 @@ ++[Plugin] ++Module = command_module_reset ++Embedded = dnf_command_module_reset_register_types ++Name = module_reset ++Description = Reset a module stream ++Authors = Jaroslav Mracek <jmracek@redhat.com> ++License = GPL-3.0+ ++Copyright = Copyright (C) 2020 Red Hat, Inc. ++X-Command-Syntax = module reset module-spec [module-spec…] +-- +2.26.2 + diff --git a/SOURCES/0002-Add-support-for-setting-a-platform-module-ID.patch b/SOURCES/0002-Add-support-for-setting-a-platform-module-ID.patch new file mode 100644 index 0000000..ef0d380 --- /dev/null +++ b/SOURCES/0002-Add-support-for-setting-a-platform-module-ID.patch @@ -0,0 +1,52 @@ +From 4f9a7a0eda7b5d30a5697b07809fc1a93cb976d1 Mon Sep 17 00:00:00 2001 +From: Neal Gompa <ngompa13@gmail.com> +Date: Fri, 20 Nov 2020 06:01:16 -0500 +Subject: [PATCH] Add support for setting a platform module ID + +Now that Micro DNF supports modularity, we need to be able to selectively +override what it detects as the platform module when working with +installroots that have modular content when they differ from the host. + +nsella +Note: the commit 7419ab465a04af525e39005e33ff869647c6bde2 was omitted +--- + dnf/dnf-main.c | 16 +++++++++++++++- + 1 file changed, 15 insertions(+), 1 deletion(-) + +diff --git a/dnf/dnf-main.c b/dnf/dnf-main.c +index 6cb8c0e..2ea3d76 100644 +--- a/dnf/dnf-main.c ++++ b/dnf/dnf-main.c +@@ -131,6 +131,20 @@ process_global_option (const gchar *option_name, + } + } + } ++ else if (strcmp (setopt[0], "module_platform_id") == 0) ++ { ++ const char *module_platform_id = setopt[1]; ++ if (module_platform_id[0] != '\0') ++ { ++ dnf_context_set_platform_module (ctx, module_platform_id); ++ } ++ else ++ { ++ local_error = g_error_new (G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE, ++ "Empty value in: %s", value); ++ ret = FALSE; ++ } ++ } + else if (strcmp (setopt[0], "cachedir") == 0) + { + cachedir_used = TRUE; +@@ -212,7 +226,7 @@ static const GOptionEntry global_opts[] = { + { "refresh", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, &opt_refresh, "Set metadata as expired before running the command", NULL }, + { "releasever", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_CALLBACK, process_global_option, "Override the value of $releasever in config and repo files", "RELEASEVER" }, + { "setopt", '\0', G_OPTION_FLAG_NONE, G_OPTION_ARG_CALLBACK, process_global_option, +- "Override a configuration option (install_weak_deps=0/1, cachedir=<path>, reposdir=<path1>,<path2>,..., tsflags=nodocs/test, varsdir=<path1>,<path2>,...)", "<option>=<value>" }, ++ "Override a configuration option (install_weak_deps=0/1, module_platform_id=<name:stream>, cachedir=<path>, reposdir=<path1>,<path2>,..., tsflags=nodocs/test, varsdir=<path1>,<path2>,...)", "<option>=<value>" }, + { NULL } + }; + +-- +2.26.2 + diff --git a/SOURCES/0003-Rename-update-command-to-upgrade-update-remain-as-compatibility-alias-RhBug-1905471.patch b/SOURCES/0003-Rename-update-command-to-upgrade-update-remain-as-compatibility-alias-RhBug-1905471.patch new file mode 100644 index 0000000..9d6619e --- /dev/null +++ b/SOURCES/0003-Rename-update-command-to-upgrade-update-remain-as-compatibility-alias-RhBug-1905471.patch @@ -0,0 +1,372 @@ +From dfb32883ee6e822289716bba82f4301bdf9d3c59 Mon Sep 17 00:00:00 2001 +From: Jaroslav Rohel <jrohel@redhat.com> +Date: Mon, 7 Dec 2020 09:23:36 +0100 +Subject: [PATCH 1/3] Command "update" renamed to "upgrade" + +Compatibility with DNF. +DNF uses "upgrade". "update" is deprecated in DNF and is +only supported for compatibility. +--- + dnf/CMakeLists.txt | 8 ++-- + dnf/meson.build | 12 ++--- + .../update/dnf-command-update.gresource.xml | 6 --- + dnf/plugins/update/update.plugin | 9 ---- + .../dnf-command-upgrade.c} | 44 +++++++++---------- + .../upgrade/dnf-command-upgrade.gresource.xml | 6 +++ + .../dnf-command-upgrade.h} | 8 ++-- + dnf/plugins/upgrade/upgrade.plugin | 9 ++++ + 8 files changed, 51 insertions(+), 51 deletions(-) + delete mode 100644 dnf/plugins/update/dnf-command-update.gresource.xml + delete mode 100644 dnf/plugins/update/update.plugin + rename dnf/plugins/{update/dnf-command-update.c => upgrade/dnf-command-upgrade.c} (69%) + create mode 100644 dnf/plugins/upgrade/dnf-command-upgrade.gresource.xml + rename dnf/plugins/{update/dnf-command-update.h => upgrade/dnf-command-upgrade.h} (74%) + create mode 100644 dnf/plugins/upgrade/upgrade.plugin + +diff --git a/dnf/CMakeLists.txt b/dnf/CMakeLists.txt +index 1d640be..7f421f3 100644 +--- a/dnf/CMakeLists.txt ++++ b/dnf/CMakeLists.txt +@@ -15,10 +15,10 @@ glib_compile_resources (DNF_COMMAND_REMOVE plugins/remove/dnf-command-remove.gre + INTERNAL) + list (APPEND DNF_COMMAND_REMOVE "plugins/remove/dnf-command-remove.c") + +-glib_compile_resources (DNF_COMMAND_UPDATE plugins/update/dnf-command-update.gresource.xml +- C_PREFIX dnf_command_update ++glib_compile_resources (DNF_COMMAND_UPGRADE plugins/upgrade/dnf-command-upgrade.gresource.xml ++ C_PREFIX dnf_command_upgrade + INTERNAL) +-list (APPEND DNF_COMMAND_UPDATE "plugins/update/dnf-command-update.c") ++list (APPEND DNF_COMMAND_UPGRADE "plugins/upgrade/dnf-command-upgrade.c") + + glib_compile_resources (DNF_COMMAND_REPOLIST plugins/repolist/dnf-command-repolist.gresource.xml + C_PREFIX dnf_command_repolist +@@ -56,7 +56,7 @@ add_executable (microdnf dnf-main.c ${DNF_SRCS} + ${DNF_COMMAND_INSTALL} + ${DNF_COMMAND_REINSTALL} + ${DNF_COMMAND_REMOVE} +- ${DNF_COMMAND_UPDATE} ++ ${DNF_COMMAND_UPGRADE} + ${DNF_COMMAND_REPOLIST} + ${DNF_COMMAND_REPOQUERY} + ${DNF_COMMAND_CLEAN} +diff --git a/dnf/meson.build b/dnf/meson.build +index b456202..4d4bd9e 100644 +--- a/dnf/meson.build ++++ b/dnf/meson.build +@@ -30,14 +30,14 @@ microdnf_srcs = [ + ), + 'plugins/remove/dnf-command-remove.c', + +- # update ++ # upgrade + gnome.compile_resources( +- 'dnf-update', +- 'plugins/update/dnf-command-update.gresource.xml', +- c_name : 'dnf_command_update', +- source_dir : 'plugins/update', ++ 'dnf-upgrade', ++ 'plugins/upgrade/dnf-command-upgrade.gresource.xml', ++ c_name : 'dnf_command_upgrade', ++ source_dir : 'plugins/upgrade', + ), +- 'plugins/update/dnf-command-update.c', ++ 'plugins/upgrade/dnf-command-upgrade.c', + + # repolist + gnome.compile_resources( +diff --git a/dnf/plugins/update/dnf-command-update.gresource.xml b/dnf/plugins/update/dnf-command-update.gresource.xml +deleted file mode 100644 +index 6168991..0000000 +--- a/dnf/plugins/update/dnf-command-update.gresource.xml ++++ /dev/null +@@ -1,6 +0,0 @@ +-<?xml version="1.0" encoding="UTF-8"?> +-<gresources> +- <gresource prefix="/org/fedoraproject/dnf/plugins/update"> +- <file>update.plugin</file> +- </gresource> +-</gresources> +diff --git a/dnf/plugins/update/update.plugin b/dnf/plugins/update/update.plugin +deleted file mode 100644 +index a61b911..0000000 +--- a/dnf/plugins/update/update.plugin ++++ /dev/null +@@ -1,9 +0,0 @@ +-[Plugin] +-Module = command_update +-Embedded = dnf_command_update_register_types +-Name = update +-Description = Update packages +-Authors = Igor Gnatenko <ignatenko@redhat.com> +-License = GPL-3.0+ +-Copyright = Copyright © 2016 Igor Gnatenko +-X-Command-Syntax = update [PACKAGE…] +diff --git a/dnf/plugins/update/dnf-command-update.c b/dnf/plugins/upgrade/dnf-command-upgrade.c +similarity index 69% +rename from dnf/plugins/update/dnf-command-update.c +rename to dnf/plugins/upgrade/dnf-command-upgrade.c +index 45ff797..5dc1c90 100644 +--- a/dnf/plugins/update/dnf-command-update.c ++++ b/dnf/plugins/upgrade/dnf-command-upgrade.c +@@ -1,4 +1,4 @@ +-/* dnf-command-update.c ++/* dnf-command-upgrade.c + * + * Copyright © 2016-2017 Igor Gnatenko <ignatenko@redhat.com> + * +@@ -16,35 +16,35 @@ + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +-#include "dnf-command-update.h" ++#include "dnf-command-upgrade.h" + #include "dnf-utils.h" + +-struct _DnfCommandUpdate ++struct _DnfCommandUpgrade + { + PeasExtensionBase parent_instance; + }; + +-static void dnf_command_update_iface_init (DnfCommandInterface *iface); ++static void dnf_command_upgrade_iface_init (DnfCommandInterface *iface); + +-G_DEFINE_DYNAMIC_TYPE_EXTENDED (DnfCommandUpdate, +- dnf_command_update, ++G_DEFINE_DYNAMIC_TYPE_EXTENDED (DnfCommandUpgrade, ++ dnf_command_upgrade, + PEAS_TYPE_EXTENSION_BASE, + 0, + G_IMPLEMENT_INTERFACE (DNF_TYPE_COMMAND, +- dnf_command_update_iface_init)) ++ dnf_command_upgrade_iface_init)) + + static void +-dnf_command_update_init (DnfCommandUpdate *self) ++dnf_command_upgrade_init (DnfCommandUpgrade *self) + { + } + + static gboolean +-dnf_command_update_run (DnfCommand *cmd, +- int argc, +- char *argv[], +- GOptionContext *opt_ctx, +- DnfContext *ctx, +- GError **error) ++dnf_command_upgrade_run (DnfCommand *cmd, ++ int argc, ++ char *argv[], ++ GOptionContext *opt_ctx, ++ DnfContext *ctx, ++ GError **error) + { + g_auto(GStrv) pkgs = NULL; + const GOptionEntry opts[] = { +@@ -63,7 +63,7 @@ dnf_command_update_run (DnfCommand *cmd, + } + else + { +- /* Update each package */ ++ /* Upgrade each package */ + for (GStrv pkg = pkgs; *pkg != NULL; pkg++) + { + if (!dnf_context_update (ctx, *pkg, error)) +@@ -89,27 +89,27 @@ dnf_command_update_run (DnfCommand *cmd, + } + + static void +-dnf_command_update_class_init (DnfCommandUpdateClass *klass) ++dnf_command_upgrade_class_init (DnfCommandUpgradeClass *klass) + { + } + + static void +-dnf_command_update_iface_init (DnfCommandInterface *iface) ++dnf_command_upgrade_iface_init (DnfCommandInterface *iface) + { +- iface->run = dnf_command_update_run; ++ iface->run = dnf_command_upgrade_run; + } + + static void +-dnf_command_update_class_finalize (DnfCommandUpdateClass *klass) ++dnf_command_upgrade_class_finalize (DnfCommandUpgradeClass *klass) + { + } + + G_MODULE_EXPORT void +-dnf_command_update_register_types (PeasObjectModule *module) ++dnf_command_upgrade_register_types (PeasObjectModule *module) + { +- dnf_command_update_register_type (G_TYPE_MODULE (module)); ++ dnf_command_upgrade_register_type (G_TYPE_MODULE (module)); + + peas_object_module_register_extension_type (module, + DNF_TYPE_COMMAND, +- DNF_TYPE_COMMAND_UPDATE); ++ DNF_TYPE_COMMAND_UPGRADE); + } +diff --git a/dnf/plugins/upgrade/dnf-command-upgrade.gresource.xml b/dnf/plugins/upgrade/dnf-command-upgrade.gresource.xml +new file mode 100644 +index 0000000..97c1ce4 +--- /dev/null ++++ b/dnf/plugins/upgrade/dnf-command-upgrade.gresource.xml +@@ -0,0 +1,6 @@ ++<?xml version="1.0" encoding="UTF-8"?> ++<gresources> ++ <gresource prefix="/org/fedoraproject/dnf/plugins/upgrade"> ++ <file>upgrade.plugin</file> ++ </gresource> ++</gresources> +diff --git a/dnf/plugins/update/dnf-command-update.h b/dnf/plugins/upgrade/dnf-command-upgrade.h +similarity index 74% +rename from dnf/plugins/update/dnf-command-update.h +rename to dnf/plugins/upgrade/dnf-command-upgrade.h +index 58bd228..5c8e976 100644 +--- a/dnf/plugins/update/dnf-command-update.h ++++ b/dnf/plugins/upgrade/dnf-command-upgrade.h +@@ -1,4 +1,4 @@ +-/* dnf-command-update.h ++/* dnf-command-upgrade.h + * + * Copyright © 2016 Igor Gnatenko <ignatenko@redhat.com> + * +@@ -23,9 +23,9 @@ + + G_BEGIN_DECLS + +-#define DNF_TYPE_COMMAND_UPDATE dnf_command_update_get_type () +-G_DECLARE_FINAL_TYPE (DnfCommandUpdate, dnf_command_update, DNF, COMMAND_UPDATE, PeasExtensionBase) ++#define DNF_TYPE_COMMAND_UPGRADE dnf_command_upgrade_get_type () ++G_DECLARE_FINAL_TYPE (DnfCommandUpgrade, dnf_command_upgrade, DNF, COMMAND_UPGRADE, PeasExtensionBase) + +-G_MODULE_EXPORT void dnf_command_update_register_types (PeasObjectModule *module); ++G_MODULE_EXPORT void dnf_command_upgrade_register_types (PeasObjectModule *module); + + G_END_DECLS +diff --git a/dnf/plugins/upgrade/upgrade.plugin b/dnf/plugins/upgrade/upgrade.plugin +new file mode 100644 +index 0000000..1f2bda2 +--- /dev/null ++++ b/dnf/plugins/upgrade/upgrade.plugin +@@ -0,0 +1,9 @@ ++[Plugin] ++Module = command_upgrade ++Embedded = dnf_command_upgrade_register_types ++Name = upgrade ++Description = Upgrade packages ++Authors = Igor Gnatenko <ignatenko@redhat.com> ++License = GPL-2.0+ ++Copyright = Copyright © 2016 Igor Gnatenko ++X-Command-Syntax = upgrade [PACKAGE…] +-- +2.26.2 + + +From 1bdeb23b66b44c4549a19e9c538c30833839156e Mon Sep 17 00:00:00 2001 +From: Jaroslav Rohel <jrohel@redhat.com> +Date: Mon, 7 Dec 2020 12:25:48 +0100 +Subject: [PATCH 2/3] Add support for command aliases + +Added support for new custom keys to "*.plugin" file: +X-Alias-Name - command alias name +X-Alias-Description - description of alias + +If both keys are present, then information will be added into help. +--- + dnf/dnf-main.c | 21 ++++++++++++++++++--- + 1 file changed, 18 insertions(+), 3 deletions(-) + +diff --git a/dnf/dnf-main.c b/dnf/dnf-main.c +index 2ea3d76..0cf634f 100644 +--- a/dnf/dnf-main.c ++++ b/dnf/dnf-main.c +@@ -358,6 +358,8 @@ main (int argc, + g_autoptr(GOptionContext) subcmd_opt_ctx = NULL; + g_autofree gchar *subcmd_opt_param = NULL; + GSList *cmds_with_subcmds = NULL; /* list of commands with subcommands */ ++ /* dictionary of aliases for commands */ ++ g_autoptr(GHashTable) cmds_aliases = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); + + setlocale (LC_ALL, ""); + +@@ -397,6 +399,7 @@ main (int argc, + if (peas_engine_provides_extension (engine, info, DNF_TYPE_COMMAND)) + { + g_autofree gchar *command_name = g_strdup (peas_plugin_info_get_name (info)); ++ g_autofree gchar *command_alias_name = g_strdup (peas_plugin_info_get_external_data (info, "Alias-Name")); + + /* Plugins with a '_' character in command name implement subcommands. + E.g. the "command_module_enable" plugin implements the "enable" subcommand of the "module" command. */ +@@ -409,11 +412,21 @@ main (int argc, + break; + } + } ++ ++ /* Add command alias to the dictionary. */ ++ if (command_alias_name) ++ g_hash_table_insert (cmds_aliases, g_strdup (command_alias_name), g_strdup (command_name)); ++ + /* + * At least 2 spaces between the command and its description are needed + * so that help2man formats it correctly. + */ + g_string_append_printf (cmd_summary, "\n %-16s %s", command_name, peas_plugin_info_get_description (info)); ++ ++ /* If command has an alias with a description, add it to the help. */ ++ const gchar *command_alias_description = peas_plugin_info_get_external_data (info, "Alias-Description"); ++ if (command_alias_name && command_alias_description) ++ g_string_append_printf (cmd_summary, "\n %-16s %s", command_alias_name, command_alias_description); + } + } + g_option_context_set_summary (opt_ctx, cmd_summary->str); +@@ -552,15 +565,17 @@ main (int argc, + * Command name (cmd_name) can not contain '_' character. It is reserved for subcomands. */ + if (cmd_name != NULL && strchr(cmd_name, '_') == NULL) + { +- with_subcmds = g_slist_find_custom (cmds_with_subcmds, cmd_name, compare_strings) != NULL; +- g_autofree gchar *mod_name = g_strdup_printf ("command_%s", cmd_name); ++ const gchar *original_cmd_name = g_hash_table_lookup (cmds_aliases, cmd_name); ++ const gchar *search_cmd_name = original_cmd_name ? original_cmd_name : cmd_name; ++ with_subcmds = g_slist_find_custom (cmds_with_subcmds, search_cmd_name, compare_strings) != NULL; ++ g_autofree gchar *mod_name = g_strdup_printf ("command_%s", search_cmd_name); + plug = peas_engine_get_plugin_info (engine, mod_name); + if (plug == NULL && with_subcmds) + { + subcmd_name = get_command (&argc, argv); + if (subcmd_name != NULL) + { +- g_autofree gchar *submod_name = g_strdup_printf ("command_%s_%s", cmd_name, subcmd_name); ++ g_autofree gchar *submod_name = g_strdup_printf ("command_%s_%s", search_cmd_name, subcmd_name); + plug = peas_engine_get_plugin_info (engine, submod_name); + } + } +-- +2.26.2 + + +From 74a918e84a2250c02dcf2190f4951eab2a3e3296 Mon Sep 17 00:00:00 2001 +From: Jaroslav Rohel <jrohel@redhat.com> +Date: Mon, 7 Dec 2020 12:30:05 +0100 +Subject: [PATCH 3/3] Added alias "update" to "upgrade" command + +"Update" is deprecated, but is required for compatibility. +--- + dnf/plugins/upgrade/upgrade.plugin | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/dnf/plugins/upgrade/upgrade.plugin b/dnf/plugins/upgrade/upgrade.plugin +index 1f2bda2..87dd93e 100644 +--- a/dnf/plugins/upgrade/upgrade.plugin ++++ b/dnf/plugins/upgrade/upgrade.plugin +@@ -7,3 +7,5 @@ Authors = Igor Gnatenko <ignatenko@redhat.com> + License = GPL-2.0+ + Copyright = Copyright © 2016 Igor Gnatenko + X-Command-Syntax = upgrade [PACKAGE…] ++X-Alias-Name = update ++X-Alias-Description = Compatibility alias for the "upgrade" command +-- +2.26.2 + diff --git a/SOURCES/0004-Print-info-about-obsoleted-packages-before-transaction-RhBug-1855542.patch b/SOURCES/0004-Print-info-about-obsoleted-packages-before-transaction-RhBug-1855542.patch new file mode 100644 index 0000000..57808d6 --- /dev/null +++ b/SOURCES/0004-Print-info-about-obsoleted-packages-before-transaction-RhBug-1855542.patch @@ -0,0 +1,170 @@ +From 9224bd0556c5b056ae6250d8aa582dfdcc2de650 Mon Sep 17 00:00:00 2001 +From: Jaroslav Rohel <jrohel@redhat.com> +Date: Mon, 13 Jul 2020 22:17:10 +0200 +Subject: [PATCH] Print info about obsoleted packages before transaction + (RhBug:1855542) +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +- Added number of obsolete packages into transaction summary. +- Added which packages are obsolete and by whom they are replaced. + +The user can run microdnf in test mode (--setopt=tsflags=test) to know +what microdnf will do. However, without this patch, information about +obsolete (replaced as obsolete) packages was missing. + +Example output before patch: +# microdnf install TestB +Package Repository Size +Installing: + TestB-1.0.0-1.noarch ci-obsoletes 5,9 kB +Transaction Summary: + Installing: 1 packages + Reinstalling: 0 packages + Upgrading: 0 packages + Removing: 0 packages + Downgrading: 0 packages +Downloading packages... +Running transaction test... +Installing: TestB;1.0.0-1;noarch;ci-obsoletes +Obsoleting: TestA;1.0.0-1;noarch;installed +Complete. + +Example output after patch: +# microdnf install TestB +Package Repository Size +Installing: + TestB-1.0.0-1.noarch ci-obsoletes 5,9 kB + replacing TestA-1.0.0-1.noarch +Transaction Summary: + Installing: 1 packages + Reinstalling: 0 packages + Upgrading: 0 packages + Obsoleting: 1 packages + Removing: 0 packages + Downgrading: 0 packages +Downloading packages... +Running transaction test... +Installing: TestB;1.0.0-1;noarch;ci-obsoletes +Obsoleting: TestA;1.0.0-1;noarch;installed +Complete. +--- + dnf/dnf-utils.c | 37 ++++++++++++++++++++++++++++--------- + 1 file changed, 28 insertions(+), 9 deletions(-) + +diff --git a/dnf/dnf-utils.c b/dnf/dnf-utils.c +index c58f519..ff0e891 100644 +--- a/dnf/dnf-utils.c ++++ b/dnf/dnf-utils.c +@@ -3,6 +3,7 @@ + * Copyright © 2010-2015 Richard Hughes <richard@hughsie.com> + * Copyright © 2016 Colin Walters <walters@verbum.org> + * Copyright © 2016-2017 Igor Gnatenko <ignatenko@redhat.com> ++ * Copyright © 2017-2020 Jaroslav Rohel <jrohel@redhat.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by +@@ -34,13 +35,15 @@ dnf_package_cmp_cb (DnfPackage **pkg1, DnfPackage **pkg2) + + + static void +-dnf_utils_add_transaction_packages (struct libscols_table *tb, ++dnf_utils_add_transaction_packages (DnfContext *ctx, ++ struct libscols_table *tb, + struct libscols_line *parent, + GPtrArray *pkgs) + { + // sort packages by NEVRA + g_ptr_array_sort (pkgs, (GCompareFunc) dnf_package_cmp_cb); + ++ HyGoal goal = dnf_context_get_goal (ctx); + for (guint i = 0; i < pkgs->len; i++) + { + DnfPackage *pkg = pkgs->pdata[i]; +@@ -48,9 +51,21 @@ dnf_utils_add_transaction_packages (struct libscols_table *tb, + struct libscols_line *ln = scols_table_new_line (tb, parent); + scols_line_set_data (ln, COL_NEVRA, dnf_package_get_nevra (pkg)); + scols_line_set_data (ln, COL_REPO, dnf_package_get_reponame (pkg)); +- char *formatted_pkg_size = g_format_size (dnf_package_get_size (pkg)); ++ g_autofree gchar *formatted_pkg_size = g_format_size (dnf_package_get_size (pkg)); + scols_line_set_data (ln, COL_SIZE, formatted_pkg_size); +- g_free(formatted_pkg_size); ++ ++ if (dnf_package_get_action (pkg) != DNF_STATE_ACTION_REMOVE) ++ { ++ g_autoptr(GPtrArray) pkgs_replaced = hy_goal_list_obsoleted_by_package (goal, pkg); ++ g_ptr_array_sort (pkgs_replaced, (GCompareFunc) dnf_package_cmp_cb); ++ for (guint i = 0; i < pkgs_replaced->len; i++) ++ { ++ DnfPackage *pkg = pkgs_replaced->pdata[i]; ++ struct libscols_line *replacing_ln = scols_table_new_line (tb, ln); ++ g_autofree gchar *replacing_text = g_strconcat ("replacing ", dnf_package_get_nevra (pkg), NULL); ++ scols_line_set_data (replacing_ln, COL_NEVRA, replacing_text); ++ } ++ } + } + } + +@@ -92,10 +107,9 @@ dnf_utils_print_transaction (DnfContext *ctx) + { + ln = scols_table_new_line (tb, NULL); + scols_line_set_data (ln, COL_NEVRA, "Installing:"); +- dnf_utils_add_transaction_packages (tb, ln, pkgs_install); ++ dnf_utils_add_transaction_packages (ctx, tb, ln, pkgs_install); + } + +- + g_autoptr(GPtrArray) pkgs_reinstall = dnf_goal_get_packages (dnf_context_get_goal (ctx), + DNF_PACKAGE_INFO_REINSTALL, + -1); +@@ -103,7 +117,7 @@ dnf_utils_print_transaction (DnfContext *ctx) + { + ln = scols_table_new_line (tb, NULL); + scols_line_set_data (ln, COL_NEVRA, "Reinstalling:"); +- dnf_utils_add_transaction_packages (tb, ln, pkgs_reinstall); ++ dnf_utils_add_transaction_packages (ctx, tb, ln, pkgs_reinstall); + } + + g_autoptr(GPtrArray) pkgs_upgrade = dnf_goal_get_packages (dnf_context_get_goal (ctx), +@@ -113,9 +127,13 @@ dnf_utils_print_transaction (DnfContext *ctx) + { + ln = scols_table_new_line (tb, NULL); + scols_line_set_data (ln, COL_NEVRA, "Upgrading:"); +- dnf_utils_add_transaction_packages (tb, ln, pkgs_upgrade); ++ dnf_utils_add_transaction_packages (ctx, tb, ln, pkgs_upgrade); + } + ++ g_autoptr(GPtrArray) pkgs_obsolete = dnf_goal_get_packages (dnf_context_get_goal (ctx), ++ DNF_PACKAGE_INFO_OBSOLETE, ++ -1); ++ + g_autoptr(GPtrArray) pkgs_remove = dnf_goal_get_packages (dnf_context_get_goal (ctx), + DNF_PACKAGE_INFO_REMOVE, + -1); +@@ -123,7 +141,7 @@ dnf_utils_print_transaction (DnfContext *ctx) + { + ln = scols_table_new_line (tb, NULL); + scols_line_set_data (ln, COL_NEVRA, "Removing:"); +- dnf_utils_add_transaction_packages (tb, ln, pkgs_remove); ++ dnf_utils_add_transaction_packages (ctx, tb, ln, pkgs_remove); + } + + g_autoptr(GPtrArray) pkgs_downgrade = dnf_goal_get_packages (dnf_context_get_goal (ctx), +@@ -133,7 +151,7 @@ dnf_utils_print_transaction (DnfContext *ctx) + { + ln = scols_table_new_line (tb, NULL); + scols_line_set_data (ln, COL_NEVRA, "Downgrading:"); +- dnf_utils_add_transaction_packages (tb, ln, pkgs_downgrade); ++ dnf_utils_add_transaction_packages (ctx, tb, ln, pkgs_downgrade); + } + + scols_print_table (tb); +@@ -144,6 +162,7 @@ dnf_utils_print_transaction (DnfContext *ctx) + g_print (" %-15s %4d packages\n", "Installing:", pkgs_install->len); + g_print (" %-15s %4d packages\n", "Reinstalling:", pkgs_reinstall->len); + g_print (" %-15s %4d packages\n", "Upgrading:", pkgs_upgrade->len); ++ g_print (" %-15s %4d packages\n", "Obsoleting:", pkgs_obsolete->len); + g_print (" %-15s %4d packages\n", "Removing:", pkgs_remove->len); + g_print (" %-15s %4d packages\n", "Downgrading:", pkgs_downgrade->len); + diff --git a/SPECS/microdnf.spec b/SPECS/microdnf.spec index fde7f12..0089caa 100644 --- a/SPECS/microdnf.spec +++ b/SPECS/microdnf.spec @@ -1,13 +1,17 @@ -%global libdnf_version 0.43.1 +%global libdnf_version 0.55.0-4 Name: microdnf Version: 3.4.0 -Release: 1%{?dist} +Release: 4%{?dist} Summary: Minimal C implementation of DNF License: GPLv3+ URL: https://github.com/rpm-software-management/microdnf Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz +Patch0: 0001-Add-module-enable-disable-reset-command.patch +Patch1: 0002-Add-support-for-setting-a-platform-module-ID.patch +Patch2: 0003-Rename-update-command-to-upgrade-update-remain-as-compatibility-alias-RhBug-1905471.patch +Patch3: 0004-Print-info-about-obsoleted-packages-before-transaction-RhBug-1855542.patch BuildRequires: gcc BuildRequires: meson >= 0.36.0 @@ -53,6 +57,16 @@ capabilities are intentionally not implemented in Micro DNF. %{_bindir}/%{name} %changelog +* Mon Feb 08 2021 Nicola Sella <nsella@redhat.com> - 3.4.0-4 +- Print info about obsoleted packages before transaction (RhBug:1855542) + +* Fri Jan 29 2021 Nicola Sella <nsella@redhat.com> - 3.4.0-3 +- Patch: Add support for setting a platform module ID +- Rename "update" command to "upgrade", "update" remain as compatibility alias + +* Fri Jan 15 2021 Nicola Sella <nsella@redhat.com> - 3.4.0-2 +- Patch: Add module enable/disable/reset command + * Mon Apr 06 2020 Ales Matej <amatej@redhat.com> - 3.4.0-1 - Update to 3.4.0 - Fix: do not download metadata in remove command