From patchwork Tue Aug 22 16:52:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 53104 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 1482527BBEA; Tue, 22 Aug 2023 17:56:39 +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.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, SPF_HELO_PASS,URIBL_BLOCKED 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 B43BF27BBE2 for ; Tue, 22 Aug 2023 17:56:37 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qYUfj-0004Xg-LV; Tue, 22 Aug 2023 12:56:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qYUfi-0004WS-IE for guix-patches@gnu.org; Tue, 22 Aug 2023 12:56:02 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qYUfi-0000v1-8f; Tue, 22 Aug 2023 12:56:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qYUfj-0007jq-KS; Tue, 22 Aug 2023 12:56:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#65230] [PATCH v4 09/10] gnu-maintenance: Allow mirror URLs to fallback to the generic HTML updater. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Tue, 22 Aug 2023 16:56:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65230 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 65230@debbugs.gnu.org Cc: Maxim Cournoyer , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 65230-submit@debbugs.gnu.org id=B65230.169272332629646 (code B ref 65230); Tue, 22 Aug 2023 16:56:03 +0000 Received: (at 65230) by debbugs.gnu.org; 22 Aug 2023 16:55:26 +0000 Received: from localhost ([127.0.0.1]:60350 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qYUf7-0007i4-0O for submit@debbugs.gnu.org; Tue, 22 Aug 2023 12:55:26 -0400 Received: from mail-vk1-xa31.google.com ([2607:f8b0:4864:20::a31]:58826) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qYUet-0007gY-3C for 65230@debbugs.gnu.org; Tue, 22 Aug 2023 12:55:12 -0400 Received: by mail-vk1-xa31.google.com with SMTP id 71dfb90a1353d-48d109dc6beso689072e0c.1 for <65230@debbugs.gnu.org>; Tue, 22 Aug 2023 09:55:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692723302; x=1693328102; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MK8+avJHldEMKEtrdNMDYNjuvXlDyay5MxaVdTs4+uM=; b=QYwSDiL5PTUU87/mxNJ/6Q5hCXDhft/7UQaIn7L3aGzZW5Yo0NR+Y4js2ADGgBxAqp 32IkAyjpnvAxN2J0xDJ7w12zLH87vV2wsMc1tMiqHCDD1jHlC6lKyQj9gUE/wpZ9BjOx h/1jjjKj7gJbtg38QHeVyFU4qicqlZXhqilklrKL6cVUN2LOCRydU5o9yni0766rleVB p2WREYcbxr0SFYvmit2xcEICRBZFTd/29WTsN54joJnW8XtD1g60sK2T20015SZFM/ho nUrwpjaCBdJBAu8tPb15PpRik+9iPkvRkvtL/R4ocmHVVh7jCxEvwEredXsTJZO/Le6b JI1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692723302; x=1693328102; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MK8+avJHldEMKEtrdNMDYNjuvXlDyay5MxaVdTs4+uM=; b=GCyqu4DDQjkcpJKSbvKdPgkURV6noz91bliYkJWWMQTFH4M8kMIfeg2VDtM8LqkmKE Nq6qNNmyHz2/vUiGYsrsfUbKJq7qQuzTGoJGR0mtHFEN1UfPylF3LDOYcPbOfH5/mcJ/ 7PRq98aCVmRt5+pO3hffnOUuiu+yr/Ow98S+gPy51OhpFQnkxAfRlTUHzuwkcKefJmBa 00KkDVVqm/rDKcss3CBo+Kh/QuKUkJTPAutdRZGwD7kCbYHdPhjTmbBGTapF3sX3uNwo 8d03jcD2acufMJWS3FNyStENxYYQMldnMUR74SEIcOPZLnkzruNZ2OWSzcs7CUTq4QSY yOYw== X-Gm-Message-State: AOJu0Ywqix822/UbV67kEv4iMKYOOJMHcw/ROv+ylhdyg2bjSYRKme4p EWCMWReOfrDo5dvOLSd/JkDUTfdxN/U= X-Google-Smtp-Source: AGHT+IGqG7CiXo0xIx2uN9WuqDWfqsTxBJtoSZdarWscZNFqr7RmKJkdNkPwIrPN8oPe/apQccVnqw== X-Received: by 2002:a1f:4cc1:0:b0:48d:41c:7818 with SMTP id z184-20020a1f4cc1000000b0048d041c7818mr4330251vka.11.1692723302305; Tue, 22 Aug 2023 09:55:02 -0700 (PDT) Received: from localhost.localdomain (dsl-158-129.b2b2c.ca. [66.158.158.129]) by smtp.gmail.com with ESMTPSA id p12-20020ae9f30c000000b007678973eaa1sm3336262qkg.127.2023.08.22.09.55.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Aug 2023 09:55:01 -0700 (PDT) From: Maxim Cournoyer Date: Tue, 22 Aug 2023 12:52:26 -0400 Message-ID: <516f8771fbf6d788f0e4be285724742065fb858e.1692723147.git.maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <06b6c57b1af15b6ddca780182fc4a5e5264a67db.1692723147.git.maxim.cournoyer@gmail.com> References: <06b6c57b1af15b6ddca780182fc4a5e5264a67db.1692723147.git.maxim.cournoyer@gmail.com> MIME-Version: 1.0 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-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/gnu-maintenance.scm (http-url?): Extract from html-updatable-package?, modify to return the HTTP URL, and support the mirror:// scheme. (%disallowed-hosting-sites): New variable, extracted from html-updatable-package. (html-updatable-package?): Rewrite a mirror:// URL to an HTTP or HTTPS one. * guix/download.scm (%mirrors): Update comment. --- Changes in v4: - Rebase and fix conflict Changes in v2: - Update %mirrors comment to mention speed-related exceptions guix/download.scm | 5 +++- guix/gnu-maintenance.scm | 65 ++++++++++++++++++++++++---------------- 2 files changed, 44 insertions(+), 26 deletions(-) diff --git a/guix/download.scm b/guix/download.scm index ce6ebd0df8..31a41e8183 100644 --- a/guix/download.scm +++ b/guix/download.scm @@ -51,7 +51,10 @@ (define-module (guix download) ;;; Code: (define %mirrors - ;; Mirror lists used when `mirror://' URLs are passed. + ;; Mirror lists used when `mirror://' URLs are passed. The first mirror + ;; entry of each set should ideally be the most authoritative one, as that's + ;; what the generic HTML updater will pick to look for updates, with + ;; possible exceptions when the authoritative mirror is too slow. (let* ((gnu-mirrors '(;; This one redirects to a (supposedly) nearby and (supposedly) ;; up-to-date mirror. diff --git a/guix/gnu-maintenance.scm b/guix/gnu-maintenance.scm index 228a84bd4b..eb30b7874f 100644 --- a/guix/gnu-maintenance.scm +++ b/guix/gnu-maintenance.scm @@ -928,31 +928,43 @@ (define* (import-kernel.org-release package #:key (version #f)) #:directory directory #:file->signature file->signature))) -(define html-updatable-package? - ;; Return true if the given package may be handled by the generic HTML - ;; updater. - (let ((hosting-sites '("github.com" "github.io" "gitlab.com" - "notabug.org" "sr.ht" "gitlab.inria.fr" - "ftp.gnu.org" "download.savannah.gnu.org" - "pypi.org" "crates.io" "rubygems.org" - "bioconductor.org"))) - (define http-url? - (url-predicate (lambda (url) - (match (string->uri url) - (#f #f) - (uri - (let ((scheme (uri-scheme uri)) - (host (uri-host uri))) - (and (memq scheme '(http https)) - ;; HOST may contain prefixes, - ;; e.g. "profanity-im.github.io", hence the - ;; suffix-based test below. - (not (any (cut string-suffix? <> host) - hosting-sites))))))))) - - (lambda (package) - (or (assoc-ref (package-properties package) 'release-monitoring-url) - (http-url? package))))) +;;; These sites are disallowed for the generic HTML updater as there are +;;; better means to query them. +(define %disallowed-hosting-sites + '("github.com" "github.io" "gitlab.com" + "notabug.org" "sr.ht" "gitlab.inria.fr" + "ftp.gnu.org" "download.savannah.gnu.org" + "pypi.org" "crates.io" "rubygems.org" + "bioconductor.org")) + +(define (http-url? url) + "Return URL if URL has HTTP or HTTPS as its protocol. If URL uses the +special mirror:// protocol, substitute it with the first HTTP or HTTPS URL +prefix from its set." + (match (string->uri url) + (#f #f) + (uri + (let ((scheme (uri-scheme uri)) + (host (uri-host uri))) + (or (and (memq scheme '(http https)) + ;; HOST may contain prefixes, e.g. "profanity-im.github.io", + ;; hence the suffix-based test below. + (not (any (cut string-suffix? <> host) + %disallowed-hosting-sites)) + url) + (and (eq? scheme 'mirror) + (and=> (find http-url? + (assoc-ref %mirrors + (string->symbol host))) + (lambda (url) + (string-append (strip-trailing-slash url) + (uri-path uri)))))))))) + +(define (html-updatable-package? package) + "Return true if the given package may be handled by the generic HTML +updater." + (or (assoc-ref (package-properties package) 'release-monitoring-url) + ((url-predicate http-url?) package))) (define* (import-html-updatable-release package #:key (version #f)) "Return the latest release of PACKAGE. Do that by crawling the HTML page of @@ -960,6 +972,9 @@ (define* (import-html-updatable-release package #:key (version #f)) string to fetch a specific version." (let* ((uri (string->uri (match (origin-uri (package-source package)) + ((? (cut string-prefix? "mirror://" <>) url) + ;; Retrieve the authoritative HTTP URL from a mirror. + (http-url? url)) ((? string? url) url) ((url _ ...) url)))) (custom (assoc-ref (package-properties package)