GNU bug report logs - #77741
[PATCH] upstream: Do not update to same version.

Previous Next

Package: guix-patches;

Reported by: Christopher Baines <mail <at> cbaines.net>

Date: Fri, 11 Apr 2025 14:02:02 UTC

Severity: normal

Tags: patch

To reply to this bug, email your comments to 77741 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix <at> cbaines.net, dev <at> jpoiret.xyz, ludo <at> gnu.org, othacehe <at> gnu.org, zimon.toutoune <at> gmail.com, me <at> tobias.gr, guix-patches <at> gnu.org:
bug#77741; Package guix-patches. (Fri, 11 Apr 2025 14:02:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Christopher Baines <mail <at> cbaines.net>:
New bug report received and forwarded. Copy sent to guix <at> cbaines.net, dev <at> jpoiret.xyz, ludo <at> gnu.org, othacehe <at> gnu.org, zimon.toutoune <at> gmail.com, me <at> tobias.gr, guix-patches <at> gnu.org. (Fri, 11 Apr 2025 14:02:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Christopher Baines <mail <at> cbaines.net>
To: guix-patches <at> gnu.org
Subject: [PATCH] upstream: Do not update to same version.
Date: Fri, 11 Apr 2025 15:00:53 +0100
From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>

Previously, 'guix refresh --update' would do actually rewrite the file with
the same version/hash information when the target version was the same as the
current version:

  guix refresh --update idutils=4.6
  idutils.scm: warning: downgrading 'idutils' from 4.6 to 4.6
  [...]
  idutils.scm: idutils: updating from version 4.6 to version 4.6...

This changes handles this case so that it does and prints nothing.

* guix/upstream.scm (package-update): Use `version-compare' to distinguish the
equal versions case.

Change-Id: I079e030d573f5968725ef13b3f626e2f8d02cb2f
---
 guix/upstream.scm     | 63 +++++++++++++++++++++++--------------------
 tests/guix-refresh.sh |  9 +++++++
 2 files changed, 43 insertions(+), 29 deletions(-)

diff --git a/guix/upstream.scm b/guix/upstream.scm
index af09f62088..259c074412 100644
--- a/guix/upstream.scm
+++ b/guix/upstream.scm
@@ -525,39 +525,44 @@ (define* (package-update store package
 partially specified, in which case the package will be updated to the newest
 compatible version if there are no exact match for VERSION.  For example,
 providing \"46\" as the version may update the package to version \"46.6.4\"."
+  (define (update* source)
+    (let ((method (match (package-source package)
+                    ((? origin? origin)
+                     (origin-method origin))
+                    (_
+                     #f))))
+      (match (assq method %method-updates)
+        (#f
+         (raise (make-compound-condition
+                 (formatted-message (G_ "cannot download for \
+this method: ~s")
+                                    method)
+                 (condition
+                  (&error-location
+                   (location (package-location package)))))))
+        ((_ . update)
+         (update store package source
+                 #:key-server key-server
+                 #:key-download key-download)))))
+
   (match (package-latest-release package updaters
                                  #:version version
                                  #:partial-version? partial-version?)
     ((? upstream-source? source)
-     (if (or (version>? (upstream-source-version source)
-                        (package-version package))
-             (and version
-                  (begin
-                    (warning (package-location package)
-                             (G_ "downgrading '~a' from ~a to ~a~%")
-                             (package-name package)
-                             (package-version package)
-                             (upstream-source-version source))
-                    #t)))
-         (let ((method (match (package-source package)
-                         ((? origin? origin)
-                          (origin-method origin))
-                         (_
-                          #f))))
-           (match (assq method %method-updates)
-             (#f
-              (raise (make-compound-condition
-                      (formatted-message (G_ "cannot download for \
-this method: ~s")
-                                         method)
-                      (condition
-                       (&error-location
-                        (location (package-location package)))))))
-             ((_ . update)
-              (update store package source
-                      #:key-server key-server
-                      #:key-download key-download))))
-         (values #f #f #f)))
+     (case (version-compare (upstream-source-version source)
+                            (package-version package))
+       ((>)
+        (update* source))
+       ((<)
+        (and version
+             (warning (package-location package)
+                      (G_ "downgrading '~a' from ~a to ~a~%")
+                      (package-name package)
+                      (package-version package)
+                      (upstream-source-version source)))
+        (update* source))
+       (else
+        (values #f #f #f))))
     (#f
      ;; Warn rather than abort so that other updates can still take place.
      (if version
diff --git a/tests/guix-refresh.sh b/tests/guix-refresh.sh
index b5b38189cb..0f1af8cae7 100644
--- a/tests/guix-refresh.sh
+++ b/tests/guix-refresh.sh
@@ -44,6 +44,15 @@ case "$(guix refresh -t test idutils 2>&1)" in
     *"$idutils_version"*"already the latest version"*) true;;
     *) false;;
 esac
+
+# No-op when updating to same version.
+case "$(guix refresh -t test -u idutils \
+--target-version=$idutils_version 2>&1)" in
+    *downgrading*) false;;
+    *updating*) false;;
+    *) true;;
+esac
+
 guix refresh -t test libreoffice # XXX: should return non-zero?
 case "$(guix refresh -t test libreoffice 2>&1)" in
     *"greater than the latest known version"*"1.0"*) true;;

base-commit: 172e9a1aa1ee2ef3e557cf46a11e451aa7982983
-- 
2.49.0





Information forwarded to guix-patches <at> gnu.org:
bug#77741; Package guix-patches. (Fri, 11 Apr 2025 15:00:02 GMT) Full text and rfc822 format available.

Message #8 received at 77741 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Christopher Baines <mail <at> cbaines.net>
Cc: Josselin Poiret <dev <at> jpoiret.xyz>,
 Simon Tournier <zimon.toutoune <at> gmail.com>, Mathieu Othacehe <othacehe <at> gnu.org>,
 Tobias Geerinckx-Rice <me <at> tobias.gr>, Christopher Baines <guix <at> cbaines.net>,
 77741 <at> debbugs.gnu.org
Subject: Re: [bug#77741] [PATCH] upstream: Do not update to same version.
Date: Fri, 11 Apr 2025 16:58:40 +0200
Christopher Baines <mail <at> cbaines.net> skribis:

> From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
>
> Previously, 'guix refresh --update' would do actually rewrite the file with
> the same version/hash information when the target version was the same as the
> current version:
>
>   guix refresh --update idutils=4.6
>   idutils.scm: warning: downgrading 'idutils' from 4.6 to 4.6
>   [...]
>   idutils.scm: idutils: updating from version 4.6 to version 4.6...
>
> This changes handles this case so that it does and prints nothing.
>
> * guix/upstream.scm (package-update): Use `version-compare' to distinguish the
> equal versions case.
>
> Change-Id: I079e030d573f5968725ef13b3f626e2f8d02cb2f

LGTM!




This bug report was last modified 1 day ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.