mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-25 20:34:52 +03:00
gnupdate: Make `nix-prefetch-url' memoizing.
* maintainers/scripts/gnu/gnupdate (memoize): New procedure. (nix-prefetch-url): Use it. svn path=/nixpkgs/trunk/; revision=30109
This commit is contained in:
parent
354b1a12c1
commit
573c9178b5
@ -328,9 +328,24 @@ replaced by the result of their application to DERIVATIONS, a vhash."
|
|||||||
status
|
status
|
||||||
#f)))
|
#f)))
|
||||||
|
|
||||||
(define (nix-prefetch-url url)
|
(define (memoize proc)
|
||||||
;; Download URL in the Nix store and return the base32-encoded SHA256 hash
|
"Return a memoizing version of PROC."
|
||||||
;; of the file at URL
|
(let ((cache (make-hash-table)))
|
||||||
|
(lambda args
|
||||||
|
(let ((results (hash-ref cache args)))
|
||||||
|
(if results
|
||||||
|
(apply values results)
|
||||||
|
(let ((results (call-with-values (lambda ()
|
||||||
|
(apply proc args))
|
||||||
|
list)))
|
||||||
|
(hash-set! cache args results)
|
||||||
|
(apply values results)))))))
|
||||||
|
|
||||||
|
(define nix-prefetch-url
|
||||||
|
(memoize
|
||||||
|
(lambda (url)
|
||||||
|
"Download URL in the Nix store and return the base32-encoded SHA256 hash of
|
||||||
|
the file at URL."
|
||||||
(let* ((pipe (open-pipe* OPEN_READ "nix-prefetch-url" url))
|
(let* ((pipe (open-pipe* OPEN_READ "nix-prefetch-url" url))
|
||||||
(hash (read-line pipe)))
|
(hash (read-line pipe)))
|
||||||
(if (or (pipe-failed? pipe)
|
(if (or (pipe-failed? pipe)
|
||||||
@ -342,7 +357,7 @@ replaced by the result of their application to DERIVATIONS, a vhash."
|
|||||||
(if (or (pipe-failed? pipe)
|
(if (or (pipe-failed? pipe)
|
||||||
(eof-object? path))
|
(eof-object? path))
|
||||||
(values #f #f)
|
(values #f #f)
|
||||||
(values (string-trim-both hash) (string-trim-both path)))))))
|
(values (string-trim-both hash) (string-trim-both path)))))))))
|
||||||
|
|
||||||
(define (update-nix-expression file
|
(define (update-nix-expression file
|
||||||
old-version old-hash
|
old-version old-hash
|
||||||
@ -926,6 +941,7 @@ pairs. Example: (\"mit-scheme-9.0.1\" . \"/gnu/mit-scheme/stable.pkg/9.0.1\").
|
|||||||
gnu-packages))
|
gnu-packages))
|
||||||
|
|
||||||
(define (fetch-gnu project directory version archive-type)
|
(define (fetch-gnu project directory version archive-type)
|
||||||
|
"Download PROJECT's tarball over FTP."
|
||||||
(let* ((server (ftp-server/directory project))
|
(let* ((server (ftp-server/directory project))
|
||||||
(base (string-append project "-" version ".tar." archive-type))
|
(base (string-append project "-" version ".tar." archive-type))
|
||||||
(url (string-append "ftp://" server "/" directory "/" base))
|
(url (string-append "ftp://" server "/" directory "/" base))
|
||||||
|
Loading…
Reference in New Issue
Block a user