richardphibel / rpms / dnf

Forked from rpms/dnf 2 years ago
Clone

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

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