diff options
author | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2022-09-06 23:09:53 -0400 |
---|---|---|
committer | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2022-09-13 02:04:36 -0400 |
commit | 5dd3acd0a0941ff9764959b313aae48095c66312 (patch) | |
tree | 1051680b91f069aeb83ff30feb82b4866a46ecf6 | |
parent | f93ad1565b48c127aabcd933e99a13ff2097e2f5 (diff) | |
download | guix-5dd3acd0a0941ff9764959b313aae48095c66312.tar.gz guix-5dd3acd0a0941ff9764959b313aae48095c66312.zip |
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)
<pre-release-text?>: New predicate.
<even-minor-version?>: Rename to...
<release-version?>: ...this. Return #f in case the version corresponds to a
development release.
* guix/import/gnome.scm (latest-gnome-release): Adjust accordingly.
-rw-r--r-- | guix/import/gnome.scm | 37 |
1 files 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 <ludo@gnu.org> +;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com> ;;; ;;; This file is part of GNU Guix. ;;; @@ -24,9 +25,11 @@ #: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 @@ not be determined." (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 @@ not be determined." (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)) |