From patchwork Tue Aug 15 20:29:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 15908 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 B1F0A27BBE9; Tue, 15 Aug 2023 21:32:22 +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 21FDB27BBE2 for ; Tue, 15 Aug 2023 21:32:21 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qW0i5-00058o-BZ; Tue, 15 Aug 2023 16:32:13 -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 1qW0i1-00054p-8r for guix-patches@gnu.org; Tue, 15 Aug 2023 16:32:09 -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 1qW0i0-0008NA-W3; Tue, 15 Aug 2023 16:32:09 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qW0hy-0005h7-L8; Tue, 15 Aug 2023 16:32:06 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#65230] [PATCH v2 12/13] 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, 15 Aug 2023 20:32:06 +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.169213148421733 (code B ref 65230); Tue, 15 Aug 2023 20:32:06 +0000 Received: (at 65230) by debbugs.gnu.org; 15 Aug 2023 20:31:24 +0000 Received: from localhost ([127.0.0.1]:36811 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qW0hH-0005eT-Oo for submit@debbugs.gnu.org; Tue, 15 Aug 2023 16:31:24 -0400 Received: from mail-qk1-x72e.google.com ([2607:f8b0:4864:20::72e]:60555) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qW0h9-0005dL-SH for 65230@debbugs.gnu.org; Tue, 15 Aug 2023 16:31:17 -0400 Received: by mail-qk1-x72e.google.com with SMTP id af79cd13be357-76cab6fe9c0so515324285a.0 for <65230@debbugs.gnu.org>; Tue, 15 Aug 2023 13:31:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692131470; x=1692736270; 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=SEeClsUv+e3kHzfh3GOl/JxDCKKLfgqIO+d081rOqTc=; b=UYm7gnThyMAVEbVCpvcWhlRkfXlkcYPnwjnI1xKK/lk6KYcgDjz5rLdW0Hz+CmIhNs RzKlU0Ns6Utjb2DOgwJPstKzl+dVvxFWHih2YG8KaeASkVqs2XdyT6ssb1SET5U3y4Kn oExp20nqCzdvlG1uIyn1PbqnUXgzIAXM23CSEh/POzVZEN2cvocZdr2SEqn7D63ux8JO W/x2epLcdwbEX5LPqEX7tiMH2dd8KN2PAl6VhbEP5gZ/hUWVB5Pi16XaGztI/IofEz6r Uj3vqkwqEkmmetiQdkfwA3r86xytN1dxNXvxp51bx+ejBNGB4OjzhCxUtrsYyFMMhlV8 4Czw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692131470; x=1692736270; 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=SEeClsUv+e3kHzfh3GOl/JxDCKKLfgqIO+d081rOqTc=; b=BFgAjpHMRJK8aPn3WvRVdrmg51a7F4Ao+iyF+Lb3FGWlVAO1Z801CSvnV06bPWMx+m W8PUuJBJ6k6b+I+XqZ8ewf5UruHRJCEK2cyF29EzqVTQbB3AX/MPxtD2jNL56dUVJaOy mPFjcDyGOvpOl8jyyYL+3NG8Nb+NKMt9N5abUZW4CRXs6NF6x97wMwK7g6xBFcweqEFL aYIZ3B/dfOr2p+ycMFwySSI6Y06xoXSxEJJNT2+HgLgZZpP6mp1Ad/3fODUrTn5gsaft z+KjUU2GI9+PrExqZhFytZrUtSIEoNZ3DV5acQzJbbD26FLyrBo71ZD47preQpQu2Wl9 JS2A== X-Gm-Message-State: AOJu0YwozoXJGlz5nE5cGwDACzAR/eVkWwSe0JmyllyQK9z02Si6SOCo HI08k/VxM2u8HLnd2FQysrg+J9ApOeAKMg== X-Google-Smtp-Source: AGHT+IHdLo3eILTXO4pzPemfIjr5KoaGk0E3Lv5+XR2ftZJdpnPOWeJFErDPHvC0v6jjOGsAF+AbDg== X-Received: by 2002:a05:620a:372b:b0:767:5bdf:3e22 with SMTP id de43-20020a05620a372b00b007675bdf3e22mr19603465qkb.40.1692131470187; Tue, 15 Aug 2023 13:31:10 -0700 (PDT) Received: from localhost.localdomain (dsl-148-65.b2b2c.ca. [66.158.148.65]) by smtp.gmail.com with ESMTPSA id f26-20020ac86eda000000b0040fe13251dasm4021078qtv.83.2023.08.15.13.31.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Aug 2023 13:31:09 -0700 (PDT) From: Maxim Cournoyer Date: Tue, 15 Aug 2023 16:29:36 -0400 Message-ID: <4f3cd2f7afc562f9e0b93f87daf4aeadd0c7954e.1692131377.git.maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <73d2f33e50141cd7bf6118f7f2db156e455294b1.1692131377.git.maxim.cournoyer@gmail.com> References: <73d2f33e50141cd7bf6118f7f2db156e455294b1.1692131377.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 v2: - Update %mirrors comment to mention speed-related exceptions guix/download.scm | 5 +++- guix/gnu-maintenance.scm | 58 +++++++++++++++++++++++++--------------- 2 files changed, 41 insertions(+), 22 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 3cd84ee3d7..2574e0f827 100644 --- a/guix/gnu-maintenance.scm +++ b/guix/gnu-maintenance.scm @@ -928,27 +928,40 @@ (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)) - (not (member 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)) + (not (member 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 @@ -956,6 +969,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)