From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id EMz5Bkzrs2WNwwAAqHPOHw:P1 (envelope-from ) for ; Fri, 26 Jan 2024 18:26:36 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id EMz5Bkzrs2WNwwAAqHPOHw (envelope-from ) for ; Fri, 26 Jan 2024 18:26:36 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=FOaueB01; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1706289996; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=U5yArds2yjafEJvvwVaCX8GTZi2fDqN3Z/ThSwp+MTs=; b=qliXAdy4Pi72W0Y73LGsHE3QPSCIOFjuMHQ4HAfGkyBm1w7vhuam3KSjyi2ap2VbszSXwe NdpFaTiGuKBf+w9dgSCIpsEISKM8lJeH5l3yQ4G1ATxFgr6ZaL7Kfjz4JrtzFZ/LE08CG1 SPsgBD8dCyWXFe7MQKMtbpJqMTtVMfAp4AF69QHKkM8FAkhX97xobeg3zRT6NPZ0hqVANJ EuYQ0NPcs7m5ISkp1ETgWCflshCwLGgOCe6mtFZXmZwgMrzax0wHlMcrmE/a6J9WPUdotc jnGMQbpo9FQkizlfkn96H51EqMNtkIu5GlRhOL3mL0k+d5YjAJqYibeCJOSsMA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=FOaueB01; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Seal: i=1; s=key1; d=yhetil.org; t=1706289996; a=rsa-sha256; cv=none; b=Dq7tCOMKZG9ul+ytuAmqGMDutERrn+m0MCoYVTTuKqPoz4wd7zIyzmb2y8yqN+fFZXGMui uQKG8NKZt5cWjyi6De0qmSVRDIfiR1pgeOs19+ES7terqi+KrH01e6dXAVImzwl4gdFCxD pMwLRGx34/o9HvOY54FPfRQl2IKbKU5E8p24RoQ7EiVBFEn+YaVAWfYRaQ9FSgcxQA1Q65 /RnWUr4KpRe/8HFsEZddh7nQVydZst4aGhrePLcREJoYxIKiWlOY3AVWrN/GW3QZTPpajl 4dj4LiEPBvMSb5wiuzz1rw0PS1WxS9S3gQK56GZ/d4Bu08/uw5n/PAy+IHvt4g== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id CD6213E3C7 for ; Fri, 26 Jan 2024 18:26:35 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rTPxp-0005gp-E7; Fri, 26 Jan 2024 12:26:01 -0500 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 1rTPxn-0005fy-Ks for guix-patches@gnu.org; Fri, 26 Jan 2024 12:25:59 -0500 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 1rTPxm-00007H-NV; Fri, 26 Jan 2024 12:25:59 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rTPxr-0004h7-6c; Fri, 26 Jan 2024 12:26:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#68741] [PATCH 3/6] swh: Add =?UTF-8?Q?=E2=80=98swh-download-directory-by-nar-hash=E2=80=99.?= Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= 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, 26 Jan 2024 17:26:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68741 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 68741@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= , 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 68741-submit@debbugs.gnu.org id=B68741.170628994517970 (code B ref 68741); Fri, 26 Jan 2024 17:26:03 +0000 Received: (at 68741) by debbugs.gnu.org; 26 Jan 2024 17:25:45 +0000 Received: from localhost ([127.0.0.1]:52656 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rTPxZ-0004fi-AR for submit@debbugs.gnu.org; Fri, 26 Jan 2024 12:25:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47882) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rTPxV-0004eh-79 for 68741@debbugs.gnu.org; Fri, 26 Jan 2024 12:25:41 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rTPxJ-0008Sc-C1; Fri, 26 Jan 2024 12:25:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=U5yArds2yjafEJvvwVaCX8GTZi2fDqN3Z/ThSwp+MTs=; b=FOaueB01BzBYRcKhDd6a 5XQC6qrCI9D81ISfM71EH/D7E7HzDWu7s82JsD9DSvF9fOdTq2adLLxVKtncnLETqqZv9bX5dKJfA yNFEU5iYFMbvSoW2IzARyaJD9ZLvp/Lbb8W+vOOyFPB0Zc1beVvqZ4Mtiw9GQaQC6LUe6qUQl0bik KVzRaKm7wO36sbrLX96Q3Ez6U/raRHDRYqsv/Qv88yRE/mi808s59MN3O4wGzSc4xtoBEoDDqqhcq Vriwy661KMQmUFxOBvUeIuGCrXeDt/hL5tBJ/QZVGWon7sAeW0cBIA/ENKQSZvd1DH1iaYs1HOFOn JgMDBEGowIlDeg==; From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Fri, 26 Jan 2024 18:25:03 +0100 Message-ID: <4b8ebf96980377ae0a83b2702d6fc93600da8a74.1706287537.git.ludo@gnu.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -4.86 X-Migadu-Queue-Id: CD6213E3C7 X-Spam-Score: -4.86 X-Migadu-Scanner: mx11.migadu.com X-TUID: 3sR5HoyMpbGb This allows us to take advantage of content addressing by giving SWH the expected nar hash. * guix/swh.scm (swh-download-directory-by-nar-hash): New procedure. Change-Id: I0494ee15a3cde390a22552de7c2246e0314ba7b5 --- guix/swh.scm | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/guix/swh.scm b/guix/swh.scm index 60e97c6d38..be1eb7d151 100644 --- a/guix/swh.scm +++ b/guix/swh.scm @@ -123,6 +123,7 @@ (define-module (guix swh) commit-id? swh-download-directory + swh-download-directory-by-nar-hash swh-download)) ;;; Commentary: @@ -805,3 +806,26 @@ (define* (swh-download url reference output "SWH: revision ~s originating from ~a could not be found~%" reference url) #f))) + +(define* (swh-download-directory-by-nar-hash hash algorithm output + #:key + (log-port (current-error-port))) + "Download from Software Heritage the directory with the given nar HASH for +ALGORITHM (a symbol such as 'sha256), and unpack it in OUTPUT. Return #t on +success and #f on failure. + +This procedure uses the \"vault\", which contains \"cooked\" directories in +the form of tarballs. If the requested directory is not cooked yet, it will +wait until it becomes available, which could take several minutes." + (match (lookup-directory-by-nar-hash hash algorithm) + (#f + (format log-port + "SWH: directory with nar-~a hash ~a not found~%" + algorithm (bytevector->base16-string hash)) + #f) + (swhid + (format log-port "SWH: found directory with nar-~a hash ~a at '~a'~%" + algorithm (bytevector->base16-string hash) swhid) + (swh-download-archive swhid output + #:archive-type 'flat ;SWHID denotes a directory + #:log-port log-port)))) -- 2.41.0