Blame SOURCES/0002-do-not-fail-on-empty-transactions.patch

5c5e8c
From 5b9caacf40e20e74298da29b0e5de525096c0e13 Mon Sep 17 00:00:00 2001
5c5e8c
From: Igor Gnatenko <ignatenko@redhat.com>
5c5e8c
Date: Sat, 4 Mar 2017 16:56:43 +0100
5c5e8c
Subject: [PATCH 2/2] do not fail on empty transactions
5c5e8c
5c5e8c
Closes: https://github.com/rpm-software-management/microdnf/issues/3
5c5e8c
Signed-off-by: Igor Gnatenko <ignatenko@redhat.com>
5c5e8c
---
5c5e8c
 dnf/dnf-utils.c                           | 16 +++++++++-------
5c5e8c
 dnf/dnf-utils.h                           |  4 ++--
5c5e8c
 dnf/plugins/install/dnf-command-install.c |  5 +++--
5c5e8c
 dnf/plugins/update/dnf-command-update.c   |  5 +++--
5c5e8c
 4 files changed, 17 insertions(+), 13 deletions(-)
5c5e8c
5c5e8c
diff --git a/dnf/dnf-utils.c b/dnf/dnf-utils.c
5c5e8c
index 16f4d08..b3d087c 100644
5c5e8c
--- a/dnf/dnf-utils.c
5c5e8c
+++ b/dnf/dnf-utils.c
5c5e8c
@@ -2,7 +2,7 @@
5c5e8c
  *
5c5e8c
  * Copyright © 2010-2015 Richard Hughes <richard@hughsie.com>
5c5e8c
  * Copyright © 2016 Colin Walters <walters@verbum.org>
5c5e8c
- * Copyright © 2016 Igor Gnatenko <ignatenko@redhat.com>
5c5e8c
+ * Copyright © 2016-2017 Igor Gnatenko <ignatenko@redhat.com>
5c5e8c
  *
5c5e8c
  * This program is free software: you can redistribute it and/or modify
5c5e8c
  * it under the terms of the GNU General Public License as published by
5c5e8c
@@ -20,7 +20,7 @@
5c5e8c
 
5c5e8c
 #include "dnf-utils.h"
5c5e8c
 
5c5e8c
-void
5c5e8c
+gboolean
5c5e8c
 dnf_utils_print_transaction (DnfContext *ctx)
5c5e8c
 {
5c5e8c
   g_autoptr(GPtrArray) pkgs = dnf_goal_get_packages (dnf_context_get_goal (ctx),
5c5e8c
@@ -30,16 +30,18 @@ dnf_utils_print_transaction (DnfContext *ctx)
5c5e8c
                                                      DNF_PACKAGE_INFO_UPDATE,
5c5e8c
                                                      DNF_PACKAGE_INFO_REMOVE,
5c5e8c
                                                      -1);
5c5e8c
-  g_print ("Transaction: ");
5c5e8c
+
5c5e8c
   if (pkgs->len == 0)
5c5e8c
-    g_print ("(empty)");
5c5e8c
-  else
5c5e8c
-    g_print ("%u packages", pkgs->len);
5c5e8c
-  g_print ("\n");
5c5e8c
+    {
5c5e8c
+      g_print ("Nothing to do.\n");
5c5e8c
+      return FALSE;
5c5e8c
+    }
5c5e8c
+  g_print ("Transaction: %u packages\n", pkgs->len);
5c5e8c
 
5c5e8c
   for (guint i = 0; i < pkgs->len; i++)
5c5e8c
     {
5c5e8c
       DnfPackage *pkg = pkgs->pdata[i];
5c5e8c
       g_print ("%s (%s)\n", dnf_package_get_nevra (pkg), dnf_package_get_reponame (pkg));
5c5e8c
     }
5c5e8c
+  return TRUE;
5c5e8c
 }
5c5e8c
diff --git a/dnf/dnf-utils.h b/dnf/dnf-utils.h
5c5e8c
index d649109..f894800 100644
5c5e8c
--- a/dnf/dnf-utils.h
5c5e8c
+++ b/dnf/dnf-utils.h
5c5e8c
@@ -1,7 +1,7 @@
5c5e8c
 /* dnf-utils.h
5c5e8c
  *
5c5e8c
  * Copyright © 2016 Colin Walters <walters@verbum.org>
5c5e8c
- * Copyright © 2016 Igor Gnatenko <ignatenko@redhat.com>
5c5e8c
+ * Copyright © 2016-2017 Igor Gnatenko <ignatenko@redhat.com>
5c5e8c
  *
5c5e8c
  * This program is free software: you can redistribute it and/or modify
5c5e8c
  * it under the terms of the GNU General Public License as published by
5c5e8c
@@ -24,6 +24,6 @@
5c5e8c
 
5c5e8c
 G_BEGIN_DECLS
5c5e8c
 
5c5e8c
-void dnf_utils_print_transaction (DnfContext *ctx);
5c5e8c
+gboolean dnf_utils_print_transaction (DnfContext *ctx);
5c5e8c
 
5c5e8c
 G_END_DECLS
5c5e8c
diff --git a/dnf/plugins/install/dnf-command-install.c b/dnf/plugins/install/dnf-command-install.c
5c5e8c
index 6f27768..ea549da 100644
5c5e8c
--- a/dnf/plugins/install/dnf-command-install.c
5c5e8c
+++ b/dnf/plugins/install/dnf-command-install.c
5c5e8c
@@ -2,7 +2,7 @@
5c5e8c
  *
5c5e8c
  * Copyright © 2010-2015 Richard Hughes <richard@hughsie.com>
5c5e8c
  * Copyright © 2016 Colin Walters <walters@verbum.org>
5c5e8c
- * Copyright © 2016 Igor Gnatenko <ignatenko@redhat.com>
5c5e8c
+ * Copyright © 2016-2017 Igor Gnatenko <ignatenko@redhat.com>
5c5e8c
  *
5c5e8c
  * This program is free software: you can redistribute it and/or modify
5c5e8c
  * it under the terms of the GNU General Public License as published by
5c5e8c
@@ -75,7 +75,8 @@ dnf_command_install_run (DnfCommand      *cmd,
5c5e8c
     }
5c5e8c
   if (!dnf_goal_depsolve (dnf_context_get_goal (ctx), DNF_INSTALL, error))
5c5e8c
     return FALSE;
5c5e8c
-  dnf_utils_print_transaction (ctx);
5c5e8c
+  if (!dnf_utils_print_transaction (ctx))
5c5e8c
+    return TRUE;
5c5e8c
   if (!dnf_context_run (ctx, NULL, error))
5c5e8c
     return FALSE;
5c5e8c
   g_print ("Complete.\n");
5c5e8c
diff --git a/dnf/plugins/update/dnf-command-update.c b/dnf/plugins/update/dnf-command-update.c
5c5e8c
index 33f7974..652d902 100644
5c5e8c
--- a/dnf/plugins/update/dnf-command-update.c
5c5e8c
+++ b/dnf/plugins/update/dnf-command-update.c
5c5e8c
@@ -1,6 +1,6 @@
5c5e8c
 /* dnf-command-update.c
5c5e8c
  *
5c5e8c
- * Copyright © 2016 Igor Gnatenko <ignatenko@redhat.com>
5c5e8c
+ * Copyright © 2016-2017 Igor Gnatenko <ignatenko@redhat.com>
5c5e8c
  *
5c5e8c
  * This program is free software: you can redistribute it and/or modify
5c5e8c
  * it under the terms of the GNU General Public License as published by
5c5e8c
@@ -73,7 +73,8 @@ dnf_command_update_run (DnfCommand      *cmd,
5c5e8c
 
5c5e8c
   if (!dnf_goal_depsolve (dnf_context_get_goal (ctx), 0, error))
5c5e8c
     return FALSE;
5c5e8c
-  dnf_utils_print_transaction (ctx);
5c5e8c
+  if (!dnf_utils_print_transaction (ctx))
5c5e8c
+    return TRUE;
5c5e8c
   if (!dnf_context_run (ctx, NULL, error))
5c5e8c
     return FALSE;
5c5e8c
   g_print ("Complete.\n");
5c5e8c
-- 
5c5e8c
2.12.1
5c5e8c