richardphibel / rpms / dnf

Forked from rpms/dnf 2 years ago
Clone

Blame SOURCES/0005-Unify-downgrade-exit-codes-with-upgrade-RhBug1759847.patch

8c93e6
From 4c2f0dbd2ffecec35c9df09190a5eeb8c4abce73 Mon Sep 17 00:00:00 2001
8c93e6
From: Marek Blaha <mblaha@redhat.com>
8c93e6
Date: Fri, 22 Nov 2019 08:02:45 +0100
8c93e6
Subject: [PATCH 1/2] Remove misleading comments
8c93e6
8c93e6
---
8c93e6
 dnf/cli/cli.py | 4 ----
8c93e6
 1 file changed, 4 deletions(-)
8c93e6
8c93e6
diff --git a/dnf/cli/cli.py b/dnf/cli/cli.py
8c93e6
index 80df950c8d..9fbe7d3ada 100644
8c93e6
--- a/dnf/cli/cli.py
8c93e6
+++ b/dnf/cli/cli.py
8c93e6
@@ -405,13 +405,9 @@ def downgradePkgs(self, specs=[], file_pkgs=[], strict=False):
8c93e6
         for pkg in file_pkgs:
8c93e6
             try:
8c93e6
                 self.package_downgrade(pkg, strict=strict)
8c93e6
-                continue # it was something on disk and it ended in rpm
8c93e6
-                         # no matter what we don't go looking at repos
8c93e6
             except dnf.exceptions.MarkingError as e:
8c93e6
                 logger.info(_('No match for argument: %s'),
8c93e6
                             self.output.term.bold(pkg.location))
8c93e6
-                # it was something on disk and it ended in rpm
8c93e6
-                # no matter what we don't go looking at repos
8c93e6
 
8c93e6
         for arg in specs:
8c93e6
             try:
8c93e6
8c93e6
From 09b035f5d71c86b88da2d6ea117282fab5e87caa Mon Sep 17 00:00:00 2001
8c93e6
From: Marek Blaha <mblaha@redhat.com>
8c93e6
Date: Tue, 19 Nov 2019 07:08:21 +0100
8c93e6
Subject: [PATCH 2/2] Unify downgrade exit codes with upgrade (RhBug:1759847)
8c93e6
8c93e6
Now the dnf downgrade/upgrade commands behave consistently
8c93e6
in case the lowest/highest available version was already
8c93e6
installed. On top of that the behaviour is now compatible with
8c93e6
yum-3.
8c93e6
8c93e6
Behaviour of upgrade command in case that the latest version of
8c93e6
acpi is already installed:
8c93e6
$ dnf upgrade acpi
8c93e6
Dependencies resolved.
8c93e6
Nothing to do.
8c93e6
Complete!
8c93e6
8c93e6
The exit code of dnf upgrade is 0
8c93e6
8c93e6
In case that the lowest version of acpi is installed:
8c93e6
8c93e6
Previous behaviour:
8c93e6
$ dnf downgrade acpi
8c93e6
Package acpi of lowest version already installed, cannot downgrade it.
8c93e6
Error: No packages marked for downgrade.
8c93e6
8c93e6
The exit code of dnf downgrade was 1
8c93e6
8c93e6
New behaviour:
8c93e6
$ dnf downgrade acpi
8c93e6
Package acpi of lowest version already installed, cannot downgrade it.
8c93e6
Dependencies resolved.
8c93e6
Nothing to do.
8c93e6
Complete!
8c93e6
8c93e6
The exit code of dnf downgrade is 0
8c93e6
8c93e6
https://bugzilla.redhat.com/show_bug.cgi?id=1759847
8c93e6
---
8c93e6
 dnf/cli/cli.py | 8 +++++---
8c93e6
 1 file changed, 5 insertions(+), 3 deletions(-)
8c93e6
8c93e6
diff --git a/dnf/cli/cli.py b/dnf/cli/cli.py
8c93e6
index 9fbe7d3ada..7a8d9e3b27 100644
8c93e6
--- a/dnf/cli/cli.py
8c93e6
+++ b/dnf/cli/cli.py
8c93e6
@@ -401,10 +401,11 @@ def downgradePkgs(self, specs=[], file_pkgs=[], strict=False):
8c93e6
         :param file_pkgs: a list of pkg objects from local files
8c93e6
         """
8c93e6
 
8c93e6
-        oldcount = self._goal.req_length()
8c93e6
+        result = False
8c93e6
         for pkg in file_pkgs:
8c93e6
             try:
8c93e6
                 self.package_downgrade(pkg, strict=strict)
8c93e6
+                result = True
8c93e6
             except dnf.exceptions.MarkingError as e:
8c93e6
                 logger.info(_('No match for argument: %s'),
8c93e6
                             self.output.term.bold(pkg.location))
8c93e6
@@ -412,6 +413,7 @@ def downgradePkgs(self, specs=[], file_pkgs=[], strict=False):
8c93e6
         for arg in specs:
8c93e6
             try:
8c93e6
                 self.downgrade_to(arg, strict=strict)
8c93e6
+                result = True
8c93e6
             except dnf.exceptions.PackageNotFoundError as err:
8c93e6
                 msg = _('No package %s available.')
8c93e6
                 logger.info(msg, self.output.term.bold(arg))
8c93e6
@@ -420,8 +422,8 @@ def downgradePkgs(self, specs=[], file_pkgs=[], strict=False):
8c93e6
                             self.output.term.bold(err.pkg_spec))
8c93e6
             except dnf.exceptions.MarkingError:
8c93e6
                 assert False
8c93e6
-        cnt = self._goal.req_length() - oldcount
8c93e6
-        if cnt <= 0:
8c93e6
+
8c93e6
+        if not result:
8c93e6
             raise dnf.exceptions.Error(_('No packages marked for downgrade.'))
8c93e6
 
8c93e6
     def output_packages(self, basecmd, pkgnarrow='all', patterns=(), reponame=None):