From 5dd3acd0a0941ff9764959b313aae48095c66312 Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Tue, 6 Sep 2022 23:09:53 -0400 Subject: [PATCH] import: gnome: Improve version handling logic. Before this change, we'd get: $ guix refresh gedit updating from version 40.1 to version 43.alpha... This is because the new GNOME version scheme introduced in 2021 with GNOME 40 was not treated correctly. Also, no longer ignore odd numbered minor versions, as this appears to be a declining practice in GNOME. * guix/import/gnome.scm (latest-gnome-release) : New predicate. : Rename to... : ...this. Return #f in case the version corresponds to a development release. * guix/import/gnome.scm (latest-gnome-release): Adjust accordingly. --- guix/import/gnome.scm | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/guix/import/gnome.scm b/guix/import/gnome.scm index 49ad7169fd..9d8cd8ec76 100644 --- a/guix/import/gnome.scm +++ b/guix/import/gnome.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017, 2019, 2021 Ludovic Courtès +;;; Copyright © 2022 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -24,9 +25,11 @@ (define-module (guix import gnome) #:use-module (json) #:use-module (srfi srfi-1) #:use-module (srfi srfi-11) + #:use-module (srfi srfi-26) #:use-module (srfi srfi-34) #:use-module (web uri) #:use-module (ice-9 match) + #:use-module (ice-9 regex) #:export (%gnome-updater)) ;;; Commentary: @@ -60,18 +63,26 @@ (define (latest-gnome-release package) (define %not-dot (char-set-complement (char-set #\.))) - (define (even-minor-version? version) - (match (string-tokenize version %not-dot) - (((= string->number major) (= string->number minor) (= string->number micro)) - ;; This is for things like GLib, with version strings like "2.72.3". - (and minor (even? minor) micro)) - (((= string->number major) (= string->number minor)) - ;; GNOME applications have version strings like "42.1" (only two - ;; integers) and are not subject to the odd/even policy. MAJOR and - ;; MINOR should be valid numbers though; "43.alpha" is rejected. - (and major minor)) - (_ - #f))) + (define (pre-release-text? text) + (string-match "^(alpha|beta|rc)" text)) + + (define (release-version? version) + "Predicate to check if VERSION matches the format of a GNOME release +version. A release version can have more than one form, depending on the +GNOME component, but typically it takes the form of a major-minor tuple, where +minor can also be prefixed wih \"alpha\", \"beta\" or \"rc\". For more +information about the GNOME versioning scheme, see: +https://discourse.gnome.org/t/new-gnome-versioning-scheme/4235" + (define components (string-tokenize version %not-dot)) + (if (any pre-release-text? components) + #f ;ignore pre-releases + (match components + (((= string->number major) (= string->number minor) . _) + ;; Any other 3+ components versions such as "2.72.2". + (and major minor)) + (((= string->number major) . _) + ;; A GNOME version strings like "42.1". + major)))) (define upstream-name ;; Some packages like "NetworkManager" have camel-case names. @@ -99,7 +110,7 @@ (define upstream-name (let* ((releases (assoc-ref releases upstream-name)) (latest (fold (match-lambda* (((key . value) result) - (cond ((even-minor-version? key) + (cond ((release-version? key) (match result (#f (cons key value))