[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
06/09: swh: Add ‘swh-download-directory-by-nar-hash’.
From: |
guix-commits |
Subject: |
06/09: swh: Add ‘swh-download-directory-by-nar-hash’. |
Date: |
Mon, 12 Feb 2024 06:21:30 -0500 (EST) |
civodul pushed a commit to branch master
in repository guix.
commit 1b72e1430794fd09bb2be1d72f482a40c0f9196e
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Thu Jan 25 23:27:51 2024 +0100
swh: Add ‘swh-download-directory-by-nar-hash’.
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 @@
commit-id?
swh-download-directory
+ swh-download-directory-by-nar-hash
swh-download))
;;; Commentary:
@@ -805,3 +806,26 @@ wait until it becomes available, which could take several
minutes."
"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))))
- branch master updated (faeae5114c -> 5a61ce6bcf), guix-commits, 2024/02/12
- 03/09: git authenticate: Gracefully handle invalid fingerprints., guix-commits, 2024/02/12
- 01/09: services: virtual-build-machine: Add base file systems to default OS., guix-commits, 2024/02/12
- 05/09: swh: Add bindings for the “ExtID” API., guix-commits, 2024/02/12
- 06/09: swh: Add ‘swh-download-directory-by-nar-hash’.,
guix-commits <=
- 04/09: swh: ‘vault-fetch’ follows redirects., guix-commits, 2024/02/12
- 02/09: services: virtual-build-machine: Use a larger partition by default., guix-commits, 2024/02/12
- 07/09: lint: archival: Check with ‘lookup-directory-by-nar-hash’., guix-commits, 2024/02/12
- 08/09: git-download: Download from SWH by nar hash when possible., guix-commits, 2024/02/12
- 09/09: swh: Fix docstring of ‘lookup-directory’., guix-commits, 2024/02/12