From patchwork Fri Aug 11 18:44:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 52758 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 C5E3027BBE9; Fri, 11 Aug 2023 19:51:18 +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 746F427BBE9 for ; Fri, 11 Aug 2023 19:51:15 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qUXDD-0003di-Cn; Fri, 11 Aug 2023 14:50:15 -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 1qUXD8-0003cr-E8 for guix-patches@gnu.org; Fri, 11 Aug 2023 14:50:10 -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 1qUXD7-0000AR-TT; Fri, 11 Aug 2023 14:50:10 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qUXD6-0007si-VW; Fri, 11 Aug 2023 14:50:08 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#65230] [PATCH 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: Fri, 11 Aug 2023 18:50:08 +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.169177979930146 (code B ref 65230); Fri, 11 Aug 2023 18:50:08 +0000 Received: (at 65230) by debbugs.gnu.org; 11 Aug 2023 18:49:59 +0000 Received: from localhost ([127.0.0.1]:48004 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qUXCw-0007q4-Gv for submit@debbugs.gnu.org; Fri, 11 Aug 2023 14:49:59 -0400 Received: from mail-qt1-x830.google.com ([2607:f8b0:4864:20::830]:58551) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qUXCs-0007p4-LR for 65230@debbugs.gnu.org; Fri, 11 Aug 2023 14:49:56 -0400 Received: by mail-qt1-x830.google.com with SMTP id d75a77b69052e-40ffc70e740so14748271cf.0 for <65230@debbugs.gnu.org>; Fri, 11 Aug 2023 11:49:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691779789; x=1692384589; 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=8zda/LFJy2MCKDfhB5aN39WP1zFDBKdo3JV4vlknS0E=; b=gOkHqED52dbyCCZrwQshw4ZHwpRFET5WsOQDUkSkQdTA1FkMALeQTbiQIYykk4HLqJ DmM3iFQsBOydBtkDriKtVRX3YiCkb1JsPqRIn9bM03IfvyZfJBP3B5rN1bVnBbxe3iWp aWCUQHDXCalpxF6+UGCg4FdPciJClxIkk8gsxDJ/Wutf0iHtI4ODAcFs2ryZOkZj8sJc y6dqgmp9o1dLrD9pVTLlOVZE+c9YQFMbDIXHFpopduaKUo+jIWYGgtjbkjN8iE5uM65O 8Qr+kcCuZtwe2aCr5XmbkUumDZAw/oKuSTnM24rxFtc6bAscg6H+eGhdpmxRW1AO3LRo corw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691779789; x=1692384589; 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=8zda/LFJy2MCKDfhB5aN39WP1zFDBKdo3JV4vlknS0E=; b=e/dxjhOzEoW2HLsxsej325jIZMe/6/Ub7GqV5Ktp6SuKljqJpuYHnuv6nHFYmUL9tX kkjClxd27vESRvbBfVy6TrefAImWBMXVEzdV9RhHsCL+BNS8ST89TR3ueHuhmoFn95UR UFeT4A6HErPXqp9eyknQQEnWQkswVSzF0BKQcH+J7MeSz8IOhvmddMpAaxS2l8X7L951 z+KjmBVAYgRFX+NaXVXemo1tf8LbWnoIPftrl/YwejVmJ+1wed5ctvIIm5Ovmc81zEIP r607iLoMjp/vPmF2oKey/X3Ff8Vk86ZlqnfZ9vCB7bToazTneXlGlp3iCGCmXJmTxRFC 0A2w== X-Gm-Message-State: AOJu0YzYO7QtiRDY7MC6Gdhyw/ZBKajzdjnvXClwWMWLrdJiwUfJvqR5 lHUwGV+VsjIjcoryZVSSJSuGEMD9VqMANA== X-Google-Smtp-Source: AGHT+IGcGAvtRKq6ANNKQCwbsEXsjYLd3ksy+JC+YX9uEShiFI3/RXYlcGAvMrdIiYobX2b+uPu9ig== X-Received: by 2002:ac8:7d43:0:b0:40f:f45c:742a with SMTP id h3-20020ac87d43000000b0040ff45c742amr3309688qtb.56.1691779788890; Fri, 11 Aug 2023 11:49:48 -0700 (PDT) Received: from localhost.localdomain (dsl-205-236-230-92.b2b2c.ca. [205.236.230.92]) by smtp.gmail.com with ESMTPSA id e29-20020ac8011d000000b00405553305casm1366398qtg.86.2023.08.11.11.49.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Aug 2023 11:49:48 -0700 (PDT) From: Maxim Cournoyer Date: Fri, 11 Aug 2023 14:44:59 -0400 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: <4f0ffa940ca39719ffa9719a9593190620855769.1691779500.git.maxim.cournoyer@gmail.com> References: <4f0ffa940ca39719ffa9719a9593190620855769.1691779500.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. --- guix/download.scm | 4 ++- guix/gnu-maintenance.scm | 58 +++++++++++++++++++++++++--------------- 2 files changed, 40 insertions(+), 22 deletions(-) diff --git a/guix/download.scm b/guix/download.scm index d5da866179..accffae9c8 100644 --- a/guix/download.scm +++ b/guix/download.scm @@ -51,7 +51,9 @@ (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. (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)