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

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