From patchwork Sun Aug 28 13:18:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hartmut Goebel X-Patchwork-Id: 42030 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id B0F5227BBEA; Sun, 28 Aug 2022 14:20:51 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 412BD27BBE9 for ; Sun, 28 Aug 2022 14:20:51 +0100 (BST) Received: from localhost ([::1]:46712 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oSIDa-00041K-Dp for patchwork@mira.cbaines.net; Sun, 28 Aug 2022 09:20:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59406) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSICt-0002tI-Ut for guix-patches@gnu.org; Sun, 28 Aug 2022 09:20:08 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:39839) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oSICt-0002fC-Kd for guix-patches@gnu.org; Sun, 28 Aug 2022 09:20:07 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oSICt-0006yb-9B for guix-patches@gnu.org; Sun, 28 Aug 2022 09:20:07 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57460] [PATCH 10/20] refresh: Allow updating to a specific version (gnome) Resent-From: Hartmut Goebel Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 28 Aug 2022 13:20:07 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57460 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 57460@debbugs.gnu.org Received: via spool by 57460-submit@debbugs.gnu.org id=B57460.166169277926644 (code B ref 57460); Sun, 28 Aug 2022 13:20:07 +0000 Received: (at 57460) by debbugs.gnu.org; 28 Aug 2022 13:19:39 +0000 Received: from localhost ([127.0.0.1]:57793 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oSICQ-0006vf-QQ for submit@debbugs.gnu.org; Sun, 28 Aug 2022 09:19:39 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:52315) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oSIC6-0006tV-3s for 57460@debbugs.gnu.org; Sun, 28 Aug 2022 09:19:18 -0400 Received: from hermia.goebel-consult.de ([46.87.137.46]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1N5G5b-1pSkeT2LZd-011ByZ for <57460@debbugs.gnu.org>; Sun, 28 Aug 2022 15:19:12 +0200 Received: from lenashee.fritz.box (lenashee.goebel-consult.de [192.168.110.2]) by hermia.goebel-consult.de (Postfix) with ESMTP id 05BCF65A3E; Sun, 28 Aug 2022 15:18:56 +0200 (CEST) From: Hartmut Goebel Date: Sun, 28 Aug 2022 15:18:36 +0200 Message-Id: <772d6b613a69ae950b657d94a51019928fdfca5b.1661691694.git.h.goebel@crazy-compilers.com> X-Mailer: git-send-email 2.30.4 In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:R8QWX9bMVfrvyHLNmZf6nwv8Fs/dc6W5qtQ7AmCsoc4qKdkk5/G ofbqIPGwQYstOBl+L4sK/hgg7kx//HH+WuVvfhgTSChmSxuj81Z6AFN18u7zY28lkQKdUEJ HmW0foy3n7+9+c+xbgvTajeA8nw88hcPGOsrtpgFjkRh+npF/GgxXwOgdEF6k7aMvF/NtIb D5BTOusW/lsf4yDzqSnhA== X-UI-Out-Filterresults: notjunk:1;V03:K0:HaZAM0MM3Dk=:M7S9enD+0DoNbr2fVU3tR1 JGDKaAIXSDxfuw6DKuapz8J5YMwqUXS/kTy8nCxbUUJd6r4azgU9EIsn2Nax+TAp6tFbaPR+q gm8wXbnS9EpR2OT3YPTteaZfO2e68i+wz5fe/8cm+/oeZFpJZo57o/bl/dSV5XfNjk5/dJatr NxdvDpLCB7qZezL3x77TXfWhzIH8U5ErrAzFbp0e2lzpGe+pprZlu/dNtn2jBuaVNcwS/LllH 5MGpTYCM5MU4ogNXpeeT0Fj+C7vpPRl+E/YQl7lmMoQPyhn23yApPCDNOY5H1Abe4jTdCNZRv cnoql8Yg8IWgelzfC3TZ/bQrcqNpFId7D+ZE/dJjhcaC4UeJO9RqJvbPWc1TjAe4VhuDcDlu2 FXUsguDiPc4nMHcjVOoxeIlOTIFCB6bQyQKLra03A0f/LQ95Hqe8M4wzFnurBIJRR2AWt0a8p qay+IIANMz0Dvuw5hmIVOWS0XkExPdsAeeR/JJc4G1cOWaPAlIjDSkIcLOqmayGvyKKed3c0m p46ra9z/1Y+8R2C3vzec370udNf+qr2vNIOqz7PbIrWrtWmh4Jcojsa8pwdjuDQ31W9WY/lyO 7yYMNBXZ50ZoXMNfvawmR/7tAeb2HjQ80L6SyuwPI8uPrEUWhSHPjLO5KNVzO+gls7A17p/LD d8qVPMWZT6OH8rBDG+71hBNnIraZgF2JyD9wNGYrvWXoZoHoYa/9IIdj8hhgfviQ9Zc27vN0a O49N6M0w8VxueTG+jwNcA8OSJ2UVfgZuvpq3Z1kMntlshPVHlyyrz/6+qJQ= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * guix/import/gnome.scm(latest-gnome-release): Rename to (import-gnome-release), add keyword-argument 'version'. If version is given, try to find the respective version [find-latest-release]: New function, based on former code. [find-version-release]: New function. --- guix/import/gnome.scm | 47 ++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/guix/import/gnome.scm b/guix/import/gnome.scm index 3562e17e0f..496c253969 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 Hartmut Goebel ;;; ;;; This file is part of GNU Guix. ;;; @@ -54,7 +55,7 @@ source for metadata." name "/" relative-url)))) '("tar.lz" "tar.xz" "tar.bz2" "tar.gz"))))))) -(define (latest-gnome-release package) +(define* (import-gnome-release package #:key (version #f)) "Return the latest release of PACKAGE, a GNOME package, or #f if it could not be determined." (define %not-dot @@ -72,6 +73,31 @@ not be determined." ;; Some packages like "NetworkManager" have camel-case names. (package-upstream-name package)) + (define (find-latest-release releases) + (fold (match-lambda* + (((key . value) result) + (cond ((even-minor-version? key) + (match result + (#f + (cons key value)) + ((newest . _) + (if (version>? key newest) + (cons key value) + result)))) + (else + result)))) + #f + releases)) + + (define (find-version-release releases version) + (fold (match-lambda* + (((key . value) result) + (if (string=? key version) + (cons key value) + result))) + #f + releases)) + (guard (c ((http-get-error? c) (if (= 404 (http-get-error-code c)) #f @@ -92,20 +118,9 @@ not be determined." (match json (#(4 releases _ ...) (let* ((releases (assoc-ref releases upstream-name)) - (latest (fold (match-lambda* - (((key . value) result) - (cond ((even-minor-version? key) - (match result - (#f - (cons key value)) - ((newest . _) - (if (version>? key newest) - (cons key value) - result)))) - (else - result)))) - #f - releases))) + (latest (if version + (find-version-release releases version) + (find-latest-release releases)))) (and latest (jsonish->upstream-source upstream-name latest)))))))) @@ -114,4 +129,4 @@ not be determined." (name 'gnome) (description "Updater for GNOME packages") (pred (url-prefix-predicate "mirror://gnome/")) - (import latest-gnome-release))) + (import import-gnome-release)))