richardphibel / rpms / dnf

Forked from rpms/dnf 2 years ago
Clone
Blob Blame History Raw
From 4c2f0dbd2ffecec35c9df09190a5eeb8c4abce73 Mon Sep 17 00:00:00 2001
From: Marek Blaha <mblaha@redhat.com>
Date: Fri, 22 Nov 2019 08:02:45 +0100
Subject: [PATCH 1/2] Remove misleading comments

---
 dnf/cli/cli.py | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/dnf/cli/cli.py b/dnf/cli/cli.py
index 80df950c8d..9fbe7d3ada 100644
--- a/dnf/cli/cli.py
+++ b/dnf/cli/cli.py
@@ -405,13 +405,9 @@ def downgradePkgs(self, specs=[], file_pkgs=[], strict=False):
         for pkg in file_pkgs:
             try:
                 self.package_downgrade(pkg, strict=strict)
-                continue # it was something on disk and it ended in rpm
-                         # no matter what we don't go looking at repos
             except dnf.exceptions.MarkingError as e:
                 logger.info(_('No match for argument: %s'),
                             self.output.term.bold(pkg.location))
-                # it was something on disk and it ended in rpm
-                # no matter what we don't go looking at repos
 
         for arg in specs:
             try:

From 09b035f5d71c86b88da2d6ea117282fab5e87caa Mon Sep 17 00:00:00 2001
From: Marek Blaha <mblaha@redhat.com>
Date: Tue, 19 Nov 2019 07:08:21 +0100
Subject: [PATCH 2/2] Unify downgrade exit codes with upgrade (RhBug:1759847)

Now the dnf downgrade/upgrade commands behave consistently
in case the lowest/highest available version was already
installed. On top of that the behaviour is now compatible with
yum-3.

Behaviour of upgrade command in case that the latest version of
acpi is already installed:
$ dnf upgrade acpi
Dependencies resolved.
Nothing to do.
Complete!

The exit code of dnf upgrade is 0

In case that the lowest version of acpi is installed:

Previous behaviour:
$ dnf downgrade acpi
Package acpi of lowest version already installed, cannot downgrade it.
Error: No packages marked for downgrade.

The exit code of dnf downgrade was 1

New behaviour:
$ dnf downgrade acpi
Package acpi of lowest version already installed, cannot downgrade it.
Dependencies resolved.
Nothing to do.
Complete!

The exit code of dnf downgrade is 0

https://bugzilla.redhat.com/show_bug.cgi?id=1759847
---
 dnf/cli/cli.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/dnf/cli/cli.py b/dnf/cli/cli.py
index 9fbe7d3ada..7a8d9e3b27 100644
--- a/dnf/cli/cli.py
+++ b/dnf/cli/cli.py
@@ -401,10 +401,11 @@ def downgradePkgs(self, specs=[], file_pkgs=[], strict=False):
         :param file_pkgs: a list of pkg objects from local files
         """
 
-        oldcount = self._goal.req_length()
+        result = False
         for pkg in file_pkgs:
             try:
                 self.package_downgrade(pkg, strict=strict)
+                result = True
             except dnf.exceptions.MarkingError as e:
                 logger.info(_('No match for argument: %s'),
                             self.output.term.bold(pkg.location))
@@ -412,6 +413,7 @@ def downgradePkgs(self, specs=[], file_pkgs=[], strict=False):
         for arg in specs:
             try:
                 self.downgrade_to(arg, strict=strict)
+                result = True
             except dnf.exceptions.PackageNotFoundError as err:
                 msg = _('No package %s available.')
                 logger.info(msg, self.output.term.bold(arg))
@@ -420,8 +422,8 @@ def downgradePkgs(self, specs=[], file_pkgs=[], strict=False):
                             self.output.term.bold(err.pkg_spec))
             except dnf.exceptions.MarkingError:
                 assert False
-        cnt = self._goal.req_length() - oldcount
-        if cnt <= 0:
+
+        if not result:
             raise dnf.exceptions.Error(_('No packages marked for downgrade.'))
 
     def output_packages(self, basecmd, pkgnarrow='all', patterns=(), reponame=None):