download: Add Software Heritage as a content-addressed mirror.

* guix/download.scm (%content-addressed-mirrors): Add Software
Heritage.
This commit is contained in:
Ludovic Courtès 2018-11-13 22:26:07 +01:00
parent e921993c25
commit ee2cfdfe86
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 22 additions and 12 deletions

View File

@ -373,18 +373,28 @@
;; procedure that takes a file name, an algorithm (symbol) and a hash ;; procedure that takes a file name, an algorithm (symbol) and a hash
;; (bytevector), and returns a URL or #f. ;; (bytevector), and returns a URL or #f.
;; Note: Avoid 'https' to mitigate <http://bugs.gnu.org/22774>. ;; Note: Avoid 'https' to mitigate <http://bugs.gnu.org/22774>.
;; TODO: Add more. '(begin
'(list (lambda (file algo hash) (use-modules (guix base32) (guix base16))
;; Files served by 'guix publish' are accessible under a single
;; hash algorithm. (list (lambda (file algo hash)
(string-append "http://mirror.hydra.gnu.org/file/" ;; Files served by 'guix publish' are accessible under a single
file "/" (symbol->string algo) "/" ;; hash algorithm.
(bytevector->nix-base32-string hash))) (string-append "http://mirror.hydra.gnu.org/file/"
(lambda (file algo hash) file "/" (symbol->string algo) "/"
;; 'tarballs.nixos.org' supports several algorithms. (bytevector->nix-base32-string hash)))
(string-append "http://tarballs.nixos.org/" (lambda (file algo hash)
(symbol->string algo) "/" ;; 'tarballs.nixos.org' supports several algorithms.
(bytevector->nix-base32-string hash))))) (string-append "http://tarballs.nixos.org/"
(symbol->string algo) "/"
(bytevector->nix-base32-string hash)))
(lambda (file algo hash)
;; Software Heritage usually archives VCS history rather than
;; tarballs, but tarballs are sometimes available (and can be
;; explicitly stored there.) For example, see
;; <https://archive.softwareheritage.org/api/1/content/sha256:92d0fa1c311cacefa89853bdb53c62f4110cdfda3820346b59cbd098f40f955e/>.
(string-append "http://archive.softwareheritage.org/api/1/content/"
(symbol->string algo) ":"
(bytevector->base16-string hash) "/raw/")))))
(define %content-addressed-mirror-file (define %content-addressed-mirror-file
;; Content-addressed mirrors stored in a file. ;; Content-addressed mirrors stored in a file.