From patchwork Fri Jan 26 17:25:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 59445 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 0DB6627BBE9; Fri, 26 Jan 2024 17:26:37 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, 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 D4E8D27BBE2 for ; Fri, 26 Jan 2024 17:26:35 +0000 (GMT) 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-di?= =?utf-8?q?rectory-by-nar-hash=E2=80=99=2E?= 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 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 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))))