Blame SOURCES/0003-Rename-update-command-to-upgrade-update-remain-as-compatibility-alias-RhBug-1905471.patch

c4d784
From dfb32883ee6e822289716bba82f4301bdf9d3c59 Mon Sep 17 00:00:00 2001
c4d784
From: Jaroslav Rohel <jrohel@redhat.com>
c4d784
Date: Mon, 7 Dec 2020 09:23:36 +0100
c4d784
Subject: [PATCH 1/3] Command "update" renamed to "upgrade"
c4d784
c4d784
Compatibility with DNF.
c4d784
DNF uses "upgrade". "update" is deprecated in DNF and is
c4d784
only supported for compatibility.
c4d784
---
c4d784
 dnf/CMakeLists.txt                            |  8 ++--
c4d784
 dnf/meson.build                               | 12 ++---
c4d784
 .../update/dnf-command-update.gresource.xml   |  6 ---
c4d784
 dnf/plugins/update/update.plugin              |  9 ----
c4d784
 .../dnf-command-upgrade.c}                    | 44 +++++++++----------
c4d784
 .../upgrade/dnf-command-upgrade.gresource.xml |  6 +++
c4d784
 .../dnf-command-upgrade.h}                    |  8 ++--
c4d784
 dnf/plugins/upgrade/upgrade.plugin            |  9 ++++
c4d784
 8 files changed, 51 insertions(+), 51 deletions(-)
c4d784
 delete mode 100644 dnf/plugins/update/dnf-command-update.gresource.xml
c4d784
 delete mode 100644 dnf/plugins/update/update.plugin
c4d784
 rename dnf/plugins/{update/dnf-command-update.c => upgrade/dnf-command-upgrade.c} (69%)
c4d784
 create mode 100644 dnf/plugins/upgrade/dnf-command-upgrade.gresource.xml
c4d784
 rename dnf/plugins/{update/dnf-command-update.h => upgrade/dnf-command-upgrade.h} (74%)
c4d784
 create mode 100644 dnf/plugins/upgrade/upgrade.plugin
c4d784
c4d784
diff --git a/dnf/CMakeLists.txt b/dnf/CMakeLists.txt
c4d784
index 1d640be..7f421f3 100644
c4d784
--- a/dnf/CMakeLists.txt
c4d784
+++ b/dnf/CMakeLists.txt
c4d784
@@ -15,10 +15,10 @@ glib_compile_resources (DNF_COMMAND_REMOVE plugins/remove/dnf-command-remove.gre
c4d784
                         INTERNAL)
c4d784
 list (APPEND DNF_COMMAND_REMOVE "plugins/remove/dnf-command-remove.c")
c4d784
 
c4d784
-glib_compile_resources (DNF_COMMAND_UPDATE plugins/update/dnf-command-update.gresource.xml
c4d784
-                        C_PREFIX dnf_command_update
c4d784
+glib_compile_resources (DNF_COMMAND_UPGRADE plugins/upgrade/dnf-command-upgrade.gresource.xml
c4d784
+                        C_PREFIX dnf_command_upgrade
c4d784
                         INTERNAL)
c4d784
-list (APPEND DNF_COMMAND_UPDATE "plugins/update/dnf-command-update.c")
c4d784
+list (APPEND DNF_COMMAND_UPGRADE "plugins/upgrade/dnf-command-upgrade.c")
c4d784
 
c4d784
 glib_compile_resources (DNF_COMMAND_REPOLIST plugins/repolist/dnf-command-repolist.gresource.xml
c4d784
                         C_PREFIX dnf_command_repolist
c4d784
@@ -56,7 +56,7 @@ add_executable (microdnf dnf-main.c ${DNF_SRCS}
c4d784
                 ${DNF_COMMAND_INSTALL}
c4d784
                 ${DNF_COMMAND_REINSTALL}
c4d784
                 ${DNF_COMMAND_REMOVE}
c4d784
-                ${DNF_COMMAND_UPDATE}
c4d784
+                ${DNF_COMMAND_UPGRADE}
c4d784
                 ${DNF_COMMAND_REPOLIST}
c4d784
                 ${DNF_COMMAND_REPOQUERY}
c4d784
                 ${DNF_COMMAND_CLEAN}
c4d784
diff --git a/dnf/meson.build b/dnf/meson.build
c4d784
index b456202..4d4bd9e 100644
c4d784
--- a/dnf/meson.build
c4d784
+++ b/dnf/meson.build
c4d784
@@ -30,14 +30,14 @@ microdnf_srcs = [
c4d784
   ),
c4d784
   'plugins/remove/dnf-command-remove.c',
c4d784
 
c4d784
-  # update
c4d784
+  # upgrade
c4d784
   gnome.compile_resources(
c4d784
-    'dnf-update',
c4d784
-    'plugins/update/dnf-command-update.gresource.xml',
c4d784
-    c_name : 'dnf_command_update',
c4d784
-    source_dir : 'plugins/update',
c4d784
+    'dnf-upgrade',
c4d784
+    'plugins/upgrade/dnf-command-upgrade.gresource.xml',
c4d784
+    c_name : 'dnf_command_upgrade',
c4d784
+    source_dir : 'plugins/upgrade',
c4d784
   ),
c4d784
-  'plugins/update/dnf-command-update.c',
c4d784
+  'plugins/upgrade/dnf-command-upgrade.c',
c4d784
 
c4d784
   # repolist
c4d784
   gnome.compile_resources(
c4d784
diff --git a/dnf/plugins/update/dnf-command-update.gresource.xml b/dnf/plugins/update/dnf-command-update.gresource.xml
c4d784
deleted file mode 100644
c4d784
index 6168991..0000000
c4d784
--- a/dnf/plugins/update/dnf-command-update.gresource.xml
c4d784
+++ /dev/null
c4d784
@@ -1,6 +0,0 @@
c4d784
-
c4d784
-<gresources>
c4d784
-  <gresource prefix="/org/fedoraproject/dnf/plugins/update">
c4d784
-    <file>update.plugin</file>
c4d784
-  </gresource>
c4d784
-</gresources>
c4d784
diff --git a/dnf/plugins/update/update.plugin b/dnf/plugins/update/update.plugin
c4d784
deleted file mode 100644
c4d784
index a61b911..0000000
c4d784
--- a/dnf/plugins/update/update.plugin
c4d784
+++ /dev/null
c4d784
@@ -1,9 +0,0 @@
c4d784
-[Plugin]
c4d784
-Module = command_update
c4d784
-Embedded = dnf_command_update_register_types
c4d784
-Name = update
c4d784
-Description = Update packages
c4d784
-Authors = Igor Gnatenko <ignatenko@redhat.com>
c4d784
-License = GPL-3.0+
c4d784
-Copyright = Copyright © 2016 Igor Gnatenko
c4d784
-X-Command-Syntax = update [PACKAGE…]
c4d784
diff --git a/dnf/plugins/update/dnf-command-update.c b/dnf/plugins/upgrade/dnf-command-upgrade.c
c4d784
similarity index 69%
c4d784
rename from dnf/plugins/update/dnf-command-update.c
c4d784
rename to dnf/plugins/upgrade/dnf-command-upgrade.c
c4d784
index 45ff797..5dc1c90 100644
c4d784
--- a/dnf/plugins/update/dnf-command-update.c
c4d784
+++ b/dnf/plugins/upgrade/dnf-command-upgrade.c
c4d784
@@ -1,4 +1,4 @@
c4d784
-/* dnf-command-update.c
c4d784
+/* dnf-command-upgrade.c
c4d784
  *
c4d784
  * Copyright © 2016-2017 Igor Gnatenko <ignatenko@redhat.com>
c4d784
  *
c4d784
@@ -16,35 +16,35 @@
c4d784
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
c4d784
  */
c4d784
 
c4d784
-#include "dnf-command-update.h"
c4d784
+#include "dnf-command-upgrade.h"
c4d784
 #include "dnf-utils.h"
c4d784
 
c4d784
-struct _DnfCommandUpdate
c4d784
+struct _DnfCommandUpgrade
c4d784
 {
c4d784
   PeasExtensionBase parent_instance;
c4d784
 };
c4d784
 
c4d784
-static void dnf_command_update_iface_init (DnfCommandInterface *iface);
c4d784
+static void dnf_command_upgrade_iface_init (DnfCommandInterface *iface);
c4d784
 
c4d784
-G_DEFINE_DYNAMIC_TYPE_EXTENDED (DnfCommandUpdate,
c4d784
-                                dnf_command_update,
c4d784
+G_DEFINE_DYNAMIC_TYPE_EXTENDED (DnfCommandUpgrade,
c4d784
+                                dnf_command_upgrade,
c4d784
                                 PEAS_TYPE_EXTENSION_BASE,
c4d784
                                 0,
c4d784
                                 G_IMPLEMENT_INTERFACE (DNF_TYPE_COMMAND,
c4d784
-                                                       dnf_command_update_iface_init))
c4d784
+                                                       dnf_command_upgrade_iface_init))
c4d784
 
c4d784
 static void
c4d784
-dnf_command_update_init (DnfCommandUpdate *self)
c4d784
+dnf_command_upgrade_init (DnfCommandUpgrade *self)
c4d784
 {
c4d784
 }
c4d784
 
c4d784
 static gboolean
c4d784
-dnf_command_update_run (DnfCommand      *cmd,
c4d784
-                        int              argc,
c4d784
-                        char            *argv[],
c4d784
-                        GOptionContext  *opt_ctx,
c4d784
-                        DnfContext      *ctx,
c4d784
-                        GError         **error)
c4d784
+dnf_command_upgrade_run (DnfCommand      *cmd,
c4d784
+                         int              argc,
c4d784
+                         char            *argv[],
c4d784
+                         GOptionContext  *opt_ctx,
c4d784
+                         DnfContext      *ctx,
c4d784
+                         GError         **error)
c4d784
 {
c4d784
   g_auto(GStrv) pkgs = NULL;
c4d784
   const GOptionEntry opts[] = {
c4d784
@@ -63,7 +63,7 @@ dnf_command_update_run (DnfCommand      *cmd,
c4d784
     }
c4d784
   else
c4d784
     {
c4d784
-      /* Update each package */
c4d784
+      /* Upgrade each package */
c4d784
       for (GStrv pkg = pkgs; *pkg != NULL; pkg++)
c4d784
         {
c4d784
           if (!dnf_context_update (ctx, *pkg, error))
c4d784
@@ -89,27 +89,27 @@ dnf_command_update_run (DnfCommand      *cmd,
c4d784
 }
c4d784
 
c4d784
 static void
c4d784
-dnf_command_update_class_init (DnfCommandUpdateClass *klass)
c4d784
+dnf_command_upgrade_class_init (DnfCommandUpgradeClass *klass)
c4d784
 {
c4d784
 }
c4d784
 
c4d784
 static void
c4d784
-dnf_command_update_iface_init (DnfCommandInterface *iface)
c4d784
+dnf_command_upgrade_iface_init (DnfCommandInterface *iface)
c4d784
 {
c4d784
-  iface->run = dnf_command_update_run;
c4d784
+  iface->run = dnf_command_upgrade_run;
c4d784
 }
c4d784
 
c4d784
 static void
c4d784
-dnf_command_update_class_finalize (DnfCommandUpdateClass *klass)
c4d784
+dnf_command_upgrade_class_finalize (DnfCommandUpgradeClass *klass)
c4d784
 {
c4d784
 }
c4d784
 
c4d784
 G_MODULE_EXPORT void
c4d784
-dnf_command_update_register_types (PeasObjectModule *module)
c4d784
+dnf_command_upgrade_register_types (PeasObjectModule *module)
c4d784
 {
c4d784
-  dnf_command_update_register_type (G_TYPE_MODULE (module));
c4d784
+  dnf_command_upgrade_register_type (G_TYPE_MODULE (module));
c4d784
 
c4d784
   peas_object_module_register_extension_type (module,
c4d784
                                               DNF_TYPE_COMMAND,
c4d784
-                                              DNF_TYPE_COMMAND_UPDATE);
c4d784
+                                              DNF_TYPE_COMMAND_UPGRADE);
c4d784
 }
c4d784
diff --git a/dnf/plugins/upgrade/dnf-command-upgrade.gresource.xml b/dnf/plugins/upgrade/dnf-command-upgrade.gresource.xml
c4d784
new file mode 100644
c4d784
index 0000000..97c1ce4
c4d784
--- /dev/null
c4d784
+++ b/dnf/plugins/upgrade/dnf-command-upgrade.gresource.xml
c4d784
@@ -0,0 +1,6 @@
c4d784
+
c4d784
+<gresources>
c4d784
+  <gresource prefix="/org/fedoraproject/dnf/plugins/upgrade">
c4d784
+    <file>upgrade.plugin</file>
c4d784
+  </gresource>
c4d784
+</gresources>
c4d784
diff --git a/dnf/plugins/update/dnf-command-update.h b/dnf/plugins/upgrade/dnf-command-upgrade.h
c4d784
similarity index 74%
c4d784
rename from dnf/plugins/update/dnf-command-update.h
c4d784
rename to dnf/plugins/upgrade/dnf-command-upgrade.h
c4d784
index 58bd228..5c8e976 100644
c4d784
--- a/dnf/plugins/update/dnf-command-update.h
c4d784
+++ b/dnf/plugins/upgrade/dnf-command-upgrade.h
c4d784
@@ -1,4 +1,4 @@
c4d784
-/* dnf-command-update.h
c4d784
+/* dnf-command-upgrade.h
c4d784
  *
c4d784
  * Copyright © 2016 Igor Gnatenko <ignatenko@redhat.com>
c4d784
  *
c4d784
@@ -23,9 +23,9 @@
c4d784
 
c4d784
 G_BEGIN_DECLS
c4d784
 
c4d784
-#define DNF_TYPE_COMMAND_UPDATE dnf_command_update_get_type ()
c4d784
-G_DECLARE_FINAL_TYPE (DnfCommandUpdate, dnf_command_update, DNF, COMMAND_UPDATE, PeasExtensionBase)
c4d784
+#define DNF_TYPE_COMMAND_UPGRADE dnf_command_upgrade_get_type ()
c4d784
+G_DECLARE_FINAL_TYPE (DnfCommandUpgrade, dnf_command_upgrade, DNF, COMMAND_UPGRADE, PeasExtensionBase)
c4d784
 
c4d784
-G_MODULE_EXPORT void dnf_command_update_register_types (PeasObjectModule *module);
c4d784
+G_MODULE_EXPORT void dnf_command_upgrade_register_types (PeasObjectModule *module);
c4d784
 
c4d784
 G_END_DECLS
c4d784
diff --git a/dnf/plugins/upgrade/upgrade.plugin b/dnf/plugins/upgrade/upgrade.plugin
c4d784
new file mode 100644
c4d784
index 0000000..1f2bda2
c4d784
--- /dev/null
c4d784
+++ b/dnf/plugins/upgrade/upgrade.plugin
c4d784
@@ -0,0 +1,9 @@
c4d784
+[Plugin]
c4d784
+Module = command_upgrade
c4d784
+Embedded = dnf_command_upgrade_register_types
c4d784
+Name = upgrade
c4d784
+Description = Upgrade packages
c4d784
+Authors = Igor Gnatenko <ignatenko@redhat.com>
c4d784
+License = GPL-2.0+
c4d784
+Copyright = Copyright © 2016 Igor Gnatenko
c4d784
+X-Command-Syntax = upgrade [PACKAGE…]
c4d784
-- 
c4d784
2.26.2
c4d784
c4d784
c4d784
From 1bdeb23b66b44c4549a19e9c538c30833839156e Mon Sep 17 00:00:00 2001
c4d784
From: Jaroslav Rohel <jrohel@redhat.com>
c4d784
Date: Mon, 7 Dec 2020 12:25:48 +0100
c4d784
Subject: [PATCH 2/3] Add support for command aliases
c4d784
c4d784
Added support for new custom keys to "*.plugin" file:
c4d784
X-Alias-Name - command alias name
c4d784
X-Alias-Description - description of alias
c4d784
c4d784
If both keys are present, then information will be added into help.
c4d784
---
c4d784
 dnf/dnf-main.c | 21 ++++++++++++++++++---
c4d784
 1 file changed, 18 insertions(+), 3 deletions(-)
c4d784
c4d784
diff --git a/dnf/dnf-main.c b/dnf/dnf-main.c
c4d784
index 2ea3d76..0cf634f 100644
c4d784
--- a/dnf/dnf-main.c
c4d784
+++ b/dnf/dnf-main.c
c4d784
@@ -358,6 +358,8 @@ main (int   argc,
c4d784
   g_autoptr(GOptionContext) subcmd_opt_ctx = NULL;
c4d784
   g_autofree gchar *subcmd_opt_param = NULL;
c4d784
   GSList *cmds_with_subcmds = NULL;  /* list of commands with subcommands */
c4d784
+  /* dictionary of aliases for commands */
c4d784
+  g_autoptr(GHashTable) cmds_aliases = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
c4d784
 
c4d784
   setlocale (LC_ALL, "");
c4d784
 
c4d784
@@ -397,6 +399,7 @@ main (int   argc,
c4d784
       if (peas_engine_provides_extension (engine, info, DNF_TYPE_COMMAND))
c4d784
         {
c4d784
           g_autofree gchar *command_name = g_strdup (peas_plugin_info_get_name (info));
c4d784
+          g_autofree gchar *command_alias_name = g_strdup (peas_plugin_info_get_external_data (info, "Alias-Name"));
c4d784
 
c4d784
           /* Plugins with a '_' character in command name implement subcommands.
c4d784
              E.g. the "command_module_enable" plugin implements the "enable" subcommand of the "module" command. */
c4d784
@@ -409,11 +412,21 @@ main (int   argc,
c4d784
                   break;
c4d784
                 }
c4d784
             }
c4d784
+
c4d784
+          /* Add command alias to the dictionary. */
c4d784
+          if (command_alias_name)
c4d784
+              g_hash_table_insert (cmds_aliases, g_strdup (command_alias_name), g_strdup (command_name));
c4d784
+
c4d784
           /*
c4d784
            * At least 2 spaces between the command and its description are needed
c4d784
            * so that help2man formats it correctly.
c4d784
            */
c4d784
           g_string_append_printf (cmd_summary, "\n  %-16s     %s", command_name, peas_plugin_info_get_description (info));
c4d784
+
c4d784
+          /* If command has an alias with a description, add it to the help. */
c4d784
+          const gchar *command_alias_description = peas_plugin_info_get_external_data (info, "Alias-Description");
c4d784
+          if (command_alias_name && command_alias_description)
c4d784
+            g_string_append_printf (cmd_summary, "\n  %-16s     %s", command_alias_name, command_alias_description);
c4d784
         }
c4d784
     }
c4d784
   g_option_context_set_summary (opt_ctx, cmd_summary->str);
c4d784
@@ -552,15 +565,17 @@ main (int   argc,
c4d784
    * Command name (cmd_name) can not contain '_' character. It is reserved for subcomands. */
c4d784
   if (cmd_name != NULL && strchr(cmd_name, '_') == NULL)
c4d784
     {
c4d784
-      with_subcmds = g_slist_find_custom (cmds_with_subcmds, cmd_name, compare_strings) != NULL;
c4d784
-      g_autofree gchar *mod_name = g_strdup_printf ("command_%s", cmd_name);
c4d784
+      const gchar *original_cmd_name = g_hash_table_lookup (cmds_aliases, cmd_name);
c4d784
+      const gchar *search_cmd_name = original_cmd_name ? original_cmd_name : cmd_name;
c4d784
+      with_subcmds = g_slist_find_custom (cmds_with_subcmds, search_cmd_name, compare_strings) != NULL;
c4d784
+      g_autofree gchar *mod_name = g_strdup_printf ("command_%s", search_cmd_name);
c4d784
       plug = peas_engine_get_plugin_info (engine, mod_name);
c4d784
       if (plug == NULL && with_subcmds)
c4d784
         {
c4d784
           subcmd_name = get_command (&argc, argv);
c4d784
           if (subcmd_name != NULL)
c4d784
             {
c4d784
-              g_autofree gchar *submod_name = g_strdup_printf ("command_%s_%s", cmd_name, subcmd_name);
c4d784
+              g_autofree gchar *submod_name = g_strdup_printf ("command_%s_%s", search_cmd_name, subcmd_name);
c4d784
               plug = peas_engine_get_plugin_info (engine, submod_name);
c4d784
             }
c4d784
         }
c4d784
-- 
c4d784
2.26.2
c4d784
c4d784
c4d784
From 74a918e84a2250c02dcf2190f4951eab2a3e3296 Mon Sep 17 00:00:00 2001
c4d784
From: Jaroslav Rohel <jrohel@redhat.com>
c4d784
Date: Mon, 7 Dec 2020 12:30:05 +0100
c4d784
Subject: [PATCH 3/3] Added alias "update" to "upgrade" command
c4d784
c4d784
"Update" is deprecated, but is required for compatibility.
c4d784
---
c4d784
 dnf/plugins/upgrade/upgrade.plugin | 2 ++
c4d784
 1 file changed, 2 insertions(+)
c4d784
c4d784
diff --git a/dnf/plugins/upgrade/upgrade.plugin b/dnf/plugins/upgrade/upgrade.plugin
c4d784
index 1f2bda2..87dd93e 100644
c4d784
--- a/dnf/plugins/upgrade/upgrade.plugin
c4d784
+++ b/dnf/plugins/upgrade/upgrade.plugin
c4d784
@@ -7,3 +7,5 @@ Authors = Igor Gnatenko <ignatenko@redhat.com>
c4d784
 License = GPL-2.0+
c4d784
 Copyright = Copyright © 2016 Igor Gnatenko
c4d784
 X-Command-Syntax = upgrade [PACKAGE…]
c4d784
+X-Alias-Name = update
c4d784
+X-Alias-Description = Compatibility alias for the "upgrade" command
c4d784
-- 
c4d784
2.26.2
c4d784