From patchwork Mon Aug 21 18:06:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 53078 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 8F17327BBE9; Mon, 21 Aug 2023 19:11:24 +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 0B57427BBE2 for ; Mon, 21 Aug 2023 19:11:22 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qY9Md-0005gD-B4; Mon, 21 Aug 2023 14:10:55 -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 1qY9Ln-0005Mp-U4 for guix-patches@gnu.org; Mon, 21 Aug 2023 14:10:08 -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 1qY9Lm-0004sv-OW; Mon, 21 Aug 2023 14:10:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qY9Lp-0007WY-0P; Mon, 21 Aug 2023 14:10:05 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#65230] [PATCH v3 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: Mon, 21 Aug 2023 18:10:04 +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.169264136128756 (code B ref 65230); Mon, 21 Aug 2023 18:10:04 +0000 Received: (at 65230) by debbugs.gnu.org; 21 Aug 2023 18:09:21 +0000 Received: from localhost ([127.0.0.1]:57694 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qY9L6-0007Tc-97 for submit@debbugs.gnu.org; Mon, 21 Aug 2023 14:09:20 -0400 Received: from mail-qt1-x82c.google.com ([2607:f8b0:4864:20::82c]:57396) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qY9L0-0007SR-Nc for 65230@debbugs.gnu.org; Mon, 21 Aug 2023 14:09:16 -0400 Received: by mail-qt1-x82c.google.com with SMTP id d75a77b69052e-40fd276621aso23901731cf.2 for <65230@debbugs.gnu.org>; Mon, 21 Aug 2023 11:09:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692641346; x=1693246146; 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=mrcr7qd3HJBLWUbh5Y66xNjCZ58YmhSyEVgbiO1yMd8=; b=k4qXqDxXk36L0l1tjoNIOuvsuGKX2RzJOK2Z50rJNUibvfkk1AoGqVqdS42kmLfYSV +aHU1NNjUEhwSTLFItBM3wNGsKbUf/bdBpaM3wAjKND/saCbYlasi8dzwiYIEUpxxc8K BfizPCODkx+5727hzdmZQg/NDCRyC+3c63DG1YZrH1DqAadksglF7+AuMTICIgYVtimf K+XxKgXgjDkER2dgJPj2+R7tHAaiUkP4OEkz/0KedHp4WyYPKswbNNIRClUqldvloBr3 w6u8sWPj6xdYdjzY5NygJ+TIXxwXhFt88eg/SsCqPEba9W5bHW4PuOvO7d2hSA76xXX2 4W9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692641346; x=1693246146; 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=mrcr7qd3HJBLWUbh5Y66xNjCZ58YmhSyEVgbiO1yMd8=; b=L/IGywyHMaMM1fhKJuBMGl/GkA5wu24O2PJUF6SvQTpwQbiaEEP7JEdcmeIEfnjQlG lBASWY86IE1q2dM1kN1xk2fEeBT8nzVAiJORF/oLmUAmxNJSIaeQ1YeLk0uyuTYLJ2B3 bB14syJ3DvK75Lf0txW/IEHMPxLSQ9vYBix+TRtYK07YyDYIYerRIVXjgRu/Ypf1Hd1n bNfWFiMkKQNDhNgGs0brjm4dHbgzrFueepSIuPLy9oC5f1LK9z4bmozVN1vwScMbcy0q L7H+srLzXPVLcKmN21TV7cYJ404vKbmhQBWhbMWZuyJkx3qHHd60ZNdZ4r+vh2nAZCHZ h+Tg== X-Gm-Message-State: AOJu0Yy/OxScMGBafI4PyJUrBo1ptSnB71ys6J4vioILfxvxFGllwAfV DrZSwvD17b8gLJrZmfG0EHSHnoKXlow= X-Google-Smtp-Source: AGHT+IEQsbqhIg1K02RS+C5Xt1l2DRsuS4MbM7H6fCeW2ZhpPuNlD/nh2XR4+sVYPDqaeeOylH3f1w== X-Received: by 2002:ac8:570a:0:b0:409:f273:e28d with SMTP id 10-20020ac8570a000000b00409f273e28dmr7536750qtw.62.1692641346535; Mon, 21 Aug 2023 11:09:06 -0700 (PDT) Received: from localhost.localdomain (dsl-10-148-105.b2b2c.ca. [72.10.148.105]) by smtp.gmail.com with ESMTPSA id t16-20020a05620a035000b00767303dc070sm2635523qkm.8.2023.08.21.11.09.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Aug 2023 11:09:06 -0700 (PDT) From: Maxim Cournoyer Date: Mon, 21 Aug 2023 14:06:13 -0400 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: <5465490ad96f27fecbb69f9bd6f1607d29af6c23.1692641173.git.maxim.cournoyer@gmail.com> References: <5465490ad96f27fecbb69f9bd6f1607d29af6c23.1692641173.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. --- (no changes since v2) 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 30d7c5a86e..334290c7fb 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)