From patchwork Mon Aug 21 18:06:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 53084 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 0E61327BBEC; Mon, 21 Aug 2023 19:12:21 +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 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 230BB27BBE2 for ; Mon, 21 Aug 2023 19:12:17 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qY9N3-0005nm-GE; Mon, 21 Aug 2023 14:11:21 -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 1qY9Ll-0005Mc-Mo for guix-patches@gnu.org; Mon, 21 Aug 2023 14:10:06 -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 1qY9Ll-0004nY-DB; Mon, 21 Aug 2023 14:10:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qY9Lm-0007VR-AK; Mon, 21 Aug 2023 14:10:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#65230] [PATCH v3 03/10] gnu-maintenance: Extract url->links procedure. 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:02 +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.169264134528643 (code B ref 65230); Mon, 21 Aug 2023 18:10:02 +0000 Received: (at 65230) by debbugs.gnu.org; 21 Aug 2023 18:09:05 +0000 Received: from localhost ([127.0.0.1]:57671 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qY9Kq-0007Rl-MI for submit@debbugs.gnu.org; Mon, 21 Aug 2023 14:09:05 -0400 Received: from mail-qt1-x836.google.com ([2607:f8b0:4864:20::836]:47196) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qY9Ko-0007Qg-Bf for 65230@debbugs.gnu.org; Mon, 21 Aug 2023 14:09:02 -0400 Received: by mail-qt1-x836.google.com with SMTP id d75a77b69052e-41095b84d8eso10020981cf.2 for <65230@debbugs.gnu.org>; Mon, 21 Aug 2023 11:08:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692641334; x=1693246134; 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=lVilgTs+co6otIBGSPy1QW/2lzqmpgq2oXWxpSWuqAA=; b=Ye64T8EWuk1U9w/9vcy84mzThlo9pF2ORdN6Z50hVssIMO5rSVIJcas1LHxaQIC6V0 NCeF6rIVP/6H5iTbczR5xpWbUNjg58szlx4UxjDuVOK3PdoUPGsrARPOxuYjh8jQCRcy Fm6+oMHf/ZM0WGqsr27PFy6NTLT/VtNGpvXZ26YVtBZ0UP2TH3ceKcHP5e0Jymbb1fYv RRgUTdmgU+P5v4+5LgQl768v4BQ99DIkkIcE8zhn4lddIsqx1a/5WBFEf95j5KRokl8c qpjrQzlogMRGia2onJ0LQTkoTe/0kM3GzDRkzqzagf2gTsoltB5+ydMPnwBlaEdOg5dw 2uTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692641334; x=1693246134; 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=lVilgTs+co6otIBGSPy1QW/2lzqmpgq2oXWxpSWuqAA=; b=e96cmA9cl2viygZpW4mMrKzQatkZnV5WJb7N5J/e7W3sqbRGsMOq0b+Hi2VT/+Fqza Vl8GXNobdj2NuPiCx0MAEuHmcjonjVsKMaLLrD59n/ig/E1ZxBU+ui4Vzj0JTv8ZQL5h REcRo6KiqvZsm9GFFDz5t3ee6f6+3jaDdI5rrZjclF1+/fms05TT9MOfMOqrNr9u7bJo AxEC3C4mWzFe+ceF0O9JKSk6g+vB5MhFfO/8cXb0FREHCsDxLH1l+ntT1UIl6CrqYk7T 5/lyDChcgq3EYAGoNkEvmXyoNxkmR7bNUwHJ1kUYJaJasb85+jUtoP1QvaIZSp3sTcSA QN0g== X-Gm-Message-State: AOJu0YzSeAJ3/9UlaFrxPDOoD0FqhjqmDHOaKNekbOU4in/KrLPN3drI X6EfuvkVTTGa+0NWCm6V4bESaeSPqgA= X-Google-Smtp-Source: AGHT+IFXlCRtohHJXzz29xxq9NiNjGYRveKG8vlnhzSFU74ngaQzTG2lYKaivD45wy7tGRqp7C/qFQ== X-Received: by 2002:ac8:7fc9:0:b0:410:60a4:ffbc with SMTP id b9-20020ac87fc9000000b0041060a4ffbcmr11036989qtk.66.1692641334321; Mon, 21 Aug 2023 11:08:54 -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.08.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Aug 2023 11:08:54 -0700 (PDT) From: Maxim Cournoyer Date: Mon, 21 Aug 2023 14:06:07 -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 (url->links): New procedure. (import-html-release): Use it. --- (no changes since v1) guix/gnu-maintenance.scm | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/guix/gnu-maintenance.scm b/guix/gnu-maintenance.scm index a314923d3b..2e0fc3e8ab 100644 --- a/guix/gnu-maintenance.scm +++ b/guix/gnu-maintenance.scm @@ -483,6 +483,14 @@ (define (html-links sxml) (_ links)))) +(define (url->links url) + "Return the unique links on the HTML page accessible at URL." + (let* ((uri (string->uri url)) + (port (http-fetch/cached uri #:ttl 3600)) + (sxml (html->sxml port))) + (close-port port) + (delete-duplicates (html-links sxml)))) + (define* (import-html-release base-url package #:key (version #f) @@ -499,12 +507,10 @@ (define* (import-html-release base-url package if any. Otherwise, FILE->SIGNATURE must be a procedure; it is passed a source file URL and must return the corresponding signature URL, or #f it signatures are unavailable." - (let* ((uri (string->uri (if (string-null? directory) - base-url - (string-append base-url directory "/")))) - (port (http-fetch/cached uri #:ttl 3600)) - (sxml (html->sxml port)) - (links (delete-duplicates (html-links sxml)))) + (let* ((url (if (string-null? directory) + base-url + (string-append base-url directory "/"))) + (links (url->links url))) (define (file->signature/guess url) (let ((base (basename url))) (any (lambda (link) @@ -562,7 +568,6 @@ (define* (import-html-release base-url package (define candidates (filter-map url->release links)) - (close-port port) (match candidates (() #f) ((first . _)