From patchwork Sun Aug 28 13:18:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hartmut Goebel X-Patchwork-Id: 42028 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 7F2E227BBEA; Sun, 28 Aug 2022 14:20:44 +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 F022D27BBE9 for ; Sun, 28 Aug 2022 14:20:43 +0100 (BST) Received: from localhost ([::1]:44402 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oSIDT-0003Xk-49 for patchwork@mira.cbaines.net; Sun, 28 Aug 2022 09:20:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59410) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSICu-0002vj-Or for guix-patches@gnu.org; Sun, 28 Aug 2022 09:20:08 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:39841) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oSICu-0002fd-Es for guix-patches@gnu.org; Sun, 28 Aug 2022 09:20:08 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oSICu-0006yr-Aj for guix-patches@gnu.org; Sun, 28 Aug 2022 09:20:08 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57460] [PATCH 12/20] refresh: Allow updating to a specific version (kde) Resent-From: Hartmut Goebel Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 28 Aug 2022 13:20:08 +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.166169278026665 (code B ref 57460); Sun, 28 Aug 2022 13:20:08 +0000 Received: (at 57460) by debbugs.gnu.org; 28 Aug 2022 13:19:40 +0000 Received: from localhost ([127.0.0.1]:57798 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oSICR-0006vu-Lg for submit@debbugs.gnu.org; Sun, 28 Aug 2022 09:19:39 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:59383) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oSICA-0006tp-Ph for 57460@debbugs.gnu.org; Sun, 28 Aug 2022 09:19:23 -0400 Received: from hermia.goebel-consult.de ([46.87.137.46]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1N3bCH-1pR5xW0v8F-010aTi for <57460@debbugs.gnu.org>; Sun, 28 Aug 2022 15:19:17 +0200 Received: from lenashee.fritz.box (lenashee.goebel-consult.de [192.168.110.2]) by hermia.goebel-consult.de (Postfix) with ESMTP id 247BE65A42; Sun, 28 Aug 2022 15:18:56 +0200 (CEST) From: Hartmut Goebel Date: Sun, 28 Aug 2022 15:18:38 +0200 Message-Id: X-Mailer: git-send-email 2.30.4 In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:wUOoZFisOBafod6k2k9c2ozHRPPdSEYOjZPtTZWQKBiriA6iQte Uo/A2KJXnFGsmLu/ikfoVarNOJGa12R2SakgOdQpN+Gw8EW9+b08nKgM5u2phWanMQgsG8J ylssVJFmzij+LtE7aOfpcA6Qj+iGhOY3LEeHT2UMOPFz5ekAoQ/ppN889+r/4uPRKch6joC 66JWWtOgV0mcXyQ0AVLeA== X-UI-Out-Filterresults: notjunk:1;V03:K0:RD3zSTq95x4=:Qs2VcSnIDCabor0lR9PVSG i6ckBoTamyOOD/PTbX/NtoRdiiYeRs31H9oXEzROQK1nItMVVKBuRnPfwGzx6dmqUrea3qWlF KBlkYsCkiPHyAonkdItNoPsiJdp52IYIxwXksVpp5hp5nMMy2tbHt+87AvE/zK8kAVjK1U3FE 6JmULLh5aF3xQ53f3C9+dH1YO7Q+O6MfHyarF80A06dmScN7IF3vGC/1Na2Yu1iuoLtNE1oEQ aBSYcntElNs5gtqSkPefy5R9SmKH0JORRZK/wi2eiEkqBw7CM68Rix/AonA4rpSRIFWI5yVLm zqXwiROrhW6O0ExcykcDULiVVmRiklmg/LzaAHrgNBgByhjjCzVXrIxq4bTT+UIn3YE9U9us0 gQwFhs2blFNkPHlxE9dWV7DN+pGS7xZZ5yFL+6zK/7PUtadCMZy8QeEbyYapUDlwnJ1iwxtxa zYqYyRci1Nx3ONcVTII72Lbe0smk1Wys2c8EwflQSiP5uFPOm6McWNAOC833f0nAXcDTmPw61 F/LhOvAzPc2+o00/Ajn/eekxr67GY+GVcYeS59Q8qIa25logtnwlsO80oy7YrhWgq7V1mqECd P5oRIGRJuBZ54fO5HF4qu2wNDzNDOQM6OhKwI5OeeZCz6nniFTX7ckIXIvY53DOsL21LREaY+ vI7Wg3GKyvv7AreHRSESHb1NMMYqUWDyG33RcfE7UcSoiLROJyoloBGlK/8e1lrxxkoGrxT1I 0aLgvS9USnB4flv2fnoEurTYZGiOUayLDqw2hKMQAAk1nzIGmBRgbtdDmwY= 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/kde.scm(latest-kde-release): Rename to (import-kde-release), add keyword-argument 'version'. Rework the code to not sort the relevant files, but just find the requested or latest version. [find-latest-archive-version]: New function. --- guix/import/kde.scm | 58 ++++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/guix/import/kde.scm b/guix/import/kde.scm index 510d823a4f..d364e44edb 100644 --- a/guix/import/kde.scm +++ b/guix/import/kde.scm @@ -28,6 +28,7 @@ #:use-module (ice-9 match) #:use-module (ice-9 rdelim) #:use-module (ice-9 regex) + #:use-module (srfi srfi-1) #:use-module (srfi srfi-11) #:use-module (web uri) @@ -149,42 +150,51 @@ Output: (string-join (map version->pattern directory-parts) "/") "/")))) -(define (latest-kde-release package) +(define* (import-kde-release package #:key (version #f)) "Return the latest release of PACKAGE, a KDE package, or #f if it could not be determined." + + (define (find-latest-archive-version archives) + (fold (lambda (file1 file2) + (if (and file2 + (version>? (tarball-sans-extension (basename file2)) + (tarball-sans-extension (basename file1)))) + file2 + file1)) + #f + archives)) + (let* ((uri (string->uri (origin-uri (package-source package)))) (path-rx (uri->kde-path-pattern uri)) (name (package-upstream-name package)) (files (download.kde.org-files)) + ;; select archives for this package (relevant (filter (lambda (file) (and (regexp-exec path-rx file) (release-file? name (basename file)))) - files))) - (match (sort relevant (lambda (file1 file2) - (version>? (tarball-sans-extension - (basename file1)) - (tarball-sans-extension - (basename file2))))) - ((and tarballs (reference _ ...)) - (let* ((version (tarball->version reference)) - (tarballs (filter (lambda (file) - (string=? (tarball-sans-extension - (basename file)) - (tarball-sans-extension - (basename reference)))) - tarballs))) - (upstream-source - (package name) - (version version) - (urls (map (lambda (file) - (string-append "mirror://kde/" file)) - tarballs))))) - (() - #f)))) + files)) + ;; find latest version + (version (or version + (and (not (null? relevant)) + (tarball->version (find-latest-archive-version relevant))))) + ;; find archives matching this version + (archives (filter (lambda (file) + (string=? version (tarball->version file))) + relevant))) + (match archives + (() #f) + (_ + (upstream-source + (package name) + (version version) + (urls (map (lambda (file) + (string-append "mirror://kde/" file)) + archives))))))) + (define %kde-updater (upstream-updater (name 'kde) (description "Updater for KDE packages") (pred (url-prefix-predicate "mirror://kde/")) - (import latest-kde-release))) + (import import-kde-release)))