From patchwork Tue Aug 15 20:29:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 52867 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 4E4FC27BBE2; Tue, 15 Aug 2023 21:32:54 +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 2BE7327BBEA for ; Tue, 15 Aug 2023 21:32:51 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qW0i0-00054l-W5; Tue, 15 Aug 2023 16:32:09 -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 1qW0hy-00053x-6P for guix-patches@gnu.org; Tue, 15 Aug 2023 16:32: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 1qW0hx-0008L8-US; Tue, 15 Aug 2023 16:32:05 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qW0hw-0005fv-0z; Tue, 15 Aug 2023 16:32:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#65230] [PATCH v2 06/13] 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: Tue, 15 Aug 2023 20:32: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.169213147021649 (code B ref 65230); Tue, 15 Aug 2023 20:32:03 +0000 Received: (at 65230) by debbugs.gnu.org; 15 Aug 2023 20:31:10 +0000 Received: from localhost ([127.0.0.1]:36794 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qW0h3-0005d1-Iq for submit@debbugs.gnu.org; Tue, 15 Aug 2023 16:31:09 -0400 Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]:54477) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qW0gy-0005ar-91 for 65230@debbugs.gnu.org; Tue, 15 Aug 2023 16:31:04 -0400 Received: by mail-qt1-x82f.google.com with SMTP id d75a77b69052e-410450b3f55so20341351cf.0 for <65230@debbugs.gnu.org>; Tue, 15 Aug 2023 13:31:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692131458; x=1692736258; 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=OEfTIQ6JyhwumDMLex/EmN74cBsgjVRcy6dedM/1G5IRmLNmHp/YgEVusIte9pCnKv 8LrRnVEAZ1oYOgXTZIpuTfNDej9xM95CE/vuHWbjXG7s/JEmuvsmYHKmsYMz832JJJMg jiXlq0h2zD5VGSRWp/6gfS9CsqjGIIjyhPaxXWpgmcQRK64pb7/7eFuVIH+pzZVwW8Hm nIIPamaVidpCrUfdAmIIFsNv5DQtIvth74n40gI7nyAm4t3g/KNOiL12A/VfZGwUNzbo m8FjOt5/Tk+S33bSLIyfOrx+dV9jRbaOMsERka03RBEHyNMF5GZQ4s4a39Zcf/ip9gGq IK8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692131458; x=1692736258; 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=TRZ0gCIdbcPtN6Lbj6Jvoiu0CrVnKkDpWUmltfnUL6pYbyJsR2++amYZ2+Kn/btboY BXf3ojaVz/N021/NgFgLiCYB2FyFE1S1XLS9fWPnL/j53cGJH3yqezcZPpApJhw0g6+3 QQTUTaOX30Ces3Ug6/UgqqagbdR+7zZI/1gg9is/K3lglnnv8rHDrYA5YqfS3Yc9tEwo h+F7nSvXtTSYsmBgP53k3fGxd6VQ5EOK4NE/WYcv40C476dpZvq245vqv1Eg7q1m2TTf 1uevxFOsmwj2HvXd4mgVeBkz+C2JrGeHYpPrfuq+GmtILx3vKIQ6NVjCNwXW5vKzpmit G89g== X-Gm-Message-State: AOJu0Yx2DKymIJQVlDeT+MEXq8op5qPYgXY6X0L7FEuyTyBO1SIC3HU4 f3/GmQggcuQYAWMtC29pGTGy2VA3x9RWOA== X-Google-Smtp-Source: AGHT+IFjXkiOPHVTzX0W3Nz+1QlvbmzpTN/w5rKo5fQ8V+3BNac92RqkXvMzqxxsC8YeMhCYdE/rxQ== X-Received: by 2002:a05:622a:1103:b0:404:e64:f5ad with SMTP id e3-20020a05622a110300b004040e64f5admr19077558qty.47.1692131458510; Tue, 15 Aug 2023 13:30:58 -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.30.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Aug 2023 13:30:58 -0700 (PDT) From: Maxim Cournoyer Date: Tue, 15 Aug 2023 16:29:30 -0400 Message-ID: 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 (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 . _)