diff options
author | Ludovic Courtès <ludo@gnu.org> | 2023-01-09 15:33:16 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2023-01-09 17:40:53 +0100 |
commit | 5d24e57a611b43ff68700379338b899f62d198cc (patch) | |
tree | 657406ccba276795546ee3273efe2db3b230a10e /guix | |
parent | 007e69756087234de4d9ea896e013e5d0232bd25 (diff) |
derivations: 'read-derivation' correctly handles case with empty hash.
Reported by Stephen Paul Weber <singpolyma@singpolyma.net> at
<https://lists.gnu.org/archive/html/guix-devel/2023-01/msg00035.html>.
* guix/derivations.scm (read-derivation)[outputs->alist]: Treat the
empty hash case as non-fixed-output whether or not the hash algorithm is
the empty string, and preserve the hash algorithm in <derivation-output>.
* tests/derivations.scm ("'download' built-in builder, no fixed-output hash")
("fixed-output-derivation?, no hash", "read-derivation with hash = #f"): New tests.
Diffstat (limited to 'guix')
-rw-r--r-- | guix/derivations.scm | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/guix/derivations.scm b/guix/derivations.scm index 354ec20e3f..0bb6a28147 100644 --- a/guix/derivations.scm +++ b/guix/derivations.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2012-2021 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2012-2021, 2023 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2016, 2017 Mathieu Lirzin <mthl@gnu.org> ;;; ;;; This file is part of GNU Guix. @@ -484,17 +484,21 @@ things as appropriate and is thus more efficient." (fold-right (lambda (output result) (match output ((name path "" "") + ;; Regular derivation. (alist-cons name (make-derivation-output path #f #f #f) result)) ((name path hash-algo hash) - ;; fixed-output + ;; Fixed-output, unless HASH is the empty string (in that + ;; case, HASH-ALGO must be preserved despite being + ;; unused). (let* ((rec? (string-prefix? "r:" hash-algo)) (algo (string->symbol (if rec? (string-drop hash-algo 2) hash-algo))) - (hash (base16-string->bytevector hash))) + (hash (and (not (string-null? hash)) + (base16-string->bytevector hash)))) (alist-cons name (make-derivation-output path algo hash rec?) |