Subject: bug#73508: closed (Re: bug#73508: Generic updaters should run last)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 19 Oct 2024 12:54:03 +0000

Your bug report

#73508: Generic updaters should run last

which was filed against the guix package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
73508: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=73508
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#73508: Generic updaters should run last
From: Maxim Cournoyer <[email-masked]>
To: Ludovic Courtès <[email-masked]>
Cc: Josselin Poiret <[email-masked]>, Simon Tournier <[email-masked]>, Mathieu Othacehe <[email-masked]>, Tobias Geerinckx-Rice <[email-masked]>, [email-masked], Christopher Baines <[email-masked]>
Date: Sat, 19 Oct 2024 21:52:14 +0900
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,

Ludovic Courtès <[email-masked]> writes:

> Hello,
>
> Maxim Cournoyer <[email-masked]> skribis:
>
>> * guix/upstream.scm (%updaters): Ensure the updaters with a name starting by
>> 'generic' appear last in the list.
>>
>> Fixes: https://issues.guix.gnu.org/
>
> This should be <https://issues.guix.gnu.org/73508>.
>
>> Change-Id: I98977f6c925c14303273755b5b4dc36035f78bda
>
> Apart from that, LGTM, thanks!

Fixed the above, and pushed!

-- 
Thanks,
Maxim

Subject: Generic updaters should run last
From: Maxim Cournoyer <[email-masked]>
To: bug-guix <[email-masked]>
Date: Fri, 27 Sep 2024 15:49:46 +0900
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,

Currently the updaters are run in the order of their alphabetical
names.  For example, with the following instrumentation to see the
updater names tried in guix/upstream.scm:

--8<---------------cut here---------------start------------->8---
@@ -259,6 +271,7 @@ (define* (package-latest-release package
 one."
   (any (match-lambda
          (($ <upstream-updater> name description pred import)
+          (pk 'trying-updater: name)
           (and (pred package)
                (import package #:version version))))
        updaters))
--8<---------------cut here---------------end--------------->8---

attempting to update gnome-desktop produces:

--8<---------------cut here---------------start------------->8---
./pre-inst-env guix refresh gnome-desktop

;;; (trying-updater: bioconductor)

;;; (trying-updater: composer)

;;; (trying-updater: cpan)

;;; (trying-updater: cran)

;;; (trying-updater: crate)

;;; (trying-updater: egg)

;;; (trying-updater: elpa)

;;; (trying-updater: gem)

;;; (trying-updater: generic-git)

;;; (trying-updater: generic-html)
gnu/packages/gnome.scm:2265:13: gnome-desktop would be upgraded from 44.0 to 44.1
--8<---------------cut here---------------end--------------->8---

It seems to me the generic updaters, being generic thus less
likely to be precise/correct, should be tried last by 'guix refresh'.

This is ensured with the following patch:

--8<---------------cut here---------------start------------->8---
modified   guix/upstream.scm
@@ -48,6 +48,7 @@ (define-module (guix upstream)
   #:use-module (srfi srfi-26)
   #:use-module (srfi srfi-34)
   #:use-module (srfi srfi-35)
+  #:use-module (srfi srfi-71)
   #:use-module (rnrs bytevectors)
   #:use-module (ice-9 match)
   #:use-module (ice-9 regex)
@@ -226,15 +227,26 @@ (define (importer-modules)
 (define %updaters
   ;; The list of publically-known updaters, alphabetically sorted.
   (delay
-    (sort (fold-module-public-variables (lambda (obj result)
-                                          (if (upstream-updater? obj)
-                                              (cons obj result)
-                                              result))
-                                        '()
-                                        (importer-modules))
-          (lambda (updater1 updater2)
-            (string<? (symbol->string (upstream-updater-name updater1))
-                      (symbol->string (upstream-updater-name updater2)))))))
+    (let* ((updaters
+            (sort (fold-module-public-variables
+                   (lambda (obj result)
+                     (if (upstream-updater? obj)
+                         (cons obj result)
+                         result))
+                   '()
+                   (importer-modules))
+                  (lambda (updater1 updater2)
+                    (string<?
+                     (symbol->string (upstream-updater-name updater1))
+                     (symbol->string (upstream-updater-name updater2))))))
+           (generic-updaters rest (partition
+                                   (compose (cut string-prefix? "generic" <>)
+                                            symbol->string
+                                            upstream-updater-name)
+                                   updaters)))
+      ;; Ensure the generic updaters are tried last, as otherwise they could
+      ;; return less accurate results.
+      (append rest generic-updaters))))
 
 ;; Tests need to mock this variable so mark it as "non-declarative".
 (set! %updaters %updaters)
@@ -259,6 +271,7 @@ (define* (package-latest-release package
--8<---------------cut here---------------end--------------->8---

Now, the 'gnome-updater' at least ends up being tried before the
'generic-html':

--8<---------------cut here---------------start------------->8---
;;; (trying-updater: bioconductor)

;;; (trying-updater: composer)

;;; (trying-updater: cpan)

;;; (trying-updater: cran)

;;; (trying-updater: crate)

;;; (trying-updater: egg)

;;; (trying-updater: elpa)

;;; (trying-updater: gem)

;;; (trying-updater: github)

;;; (trying-updater: gnome)

gnu/packages/gnome.scm:2265:13: gnome-desktop would be upgraded from 44.0 to 44.1
--8<---------------cut here---------------end--------------->8---

I'll send a 'git format-patch' version in a follow-up.

-- 
Thanks,
Maxim