[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
02/10: derivations: Delete duplicate inputs when computing derivation ha
From: |
guix-commits |
Subject: |
02/10: derivations: Delete duplicate inputs when computing derivation hash. |
Date: |
Fri, 16 Aug 2019 17:00:39 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit 268896444bed7b958add74b2e1e86ff802c5f5cb
Author: Ludovic Courtès <address@hidden>
Date: Fri Aug 16 18:41:55 2019 +0200
derivations: Delete duplicate inputs when computing derivation hash.
Fixes <https://bugs.gnu.org/36777>.
Reported by Carl Dong <address@hidden>.
* guix/derivations.scm (derivation/masked-inputs): Call
'delete-duplicates' on INPUTS.
* tests/derivations.scm ("derivation with duplicate fixed-output inputs"):
New test.
---
guix/derivations.scm | 2 +-
tests/derivations.scm | 32 ++++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/guix/derivations.scm b/guix/derivations.scm
index 92d5050..b392892 100644
--- a/guix/derivations.scm
+++ b/guix/derivations.scm
@@ -685,7 +685,7 @@ name of each input with that input's hash."
(make-derivation-input hash sub-drvs))))
inputs)))
(make-derivation outputs
- (sort inputs
+ (sort (delete-duplicates inputs)
(lambda (drv1 drv2)
(string<? (derivation-input-derivation drv1)
(derivation-input-derivation drv2))))
diff --git a/tests/derivations.scm b/tests/derivations.scm
index 368012d..db73d19 100644
--- a/tests/derivations.scm
+++ b/tests/derivations.scm
@@ -410,6 +410,38 @@
(equal? (derivation->output-path final1)
(derivation->output-path final2)))))
+(test-assert "derivation with duplicate fixed-output inputs"
+ ;; Here we create a derivation that has two inputs, both of which are
+ ;; fixed-output leading to the same result. This test ensures the hash of
+ ;; that derivation is correctly computed, namely that duplicate inputs are
+ ;; coalesced. See <https://bugs.gnu.org/36777>.
+ (let* ((builder1 (add-text-to-store %store "fixed-builder1.sh"
+ "echo -n hello > $out" '()))
+ (builder2 (add-text-to-store %store "fixed-builder2.sh"
+ "echo hey; echo -n hello > $out" '()))
+ (hash (sha256 (string->utf8 "hello")))
+ (fixed1 (derivation %store "fixed"
+ %bash `(,builder1)
+ #:hash hash #:hash-algo 'sha256))
+ (fixed2 (derivation %store "fixed"
+ %bash `(,builder2)
+ #:hash hash #:hash-algo 'sha256))
+ (builder3 (add-text-to-store %store "builder.sh"
+ "echo fake builder"))
+ (final (derivation %store "final"
+ %bash `(,builder3)
+ #:sources (list %bash builder3)
+ #:inputs (list (derivation-input fixed1)
+ (derivation-input fixed2)))))
+ (and (derivation? final)
+ (match (derivation-inputs final)
+ (((= derivation-input-derivation one)
+ (= derivation-input-derivation two))
+ (and (not (string=? (derivation-file-name one)
+ (derivation-file-name two)))
+ (string=? (derivation->output-path one)
+ (derivation->output-path two))))))))
+
(test-assert "multiple-output derivation"
(let* ((builder (add-text-to-store %store "my-fixed-builder.sh"
"echo one > $out ; echo two > $second"
- branch master updated (b65bd33 -> a830d14), guix-commits, 2019/08/16
- 02/10: derivations: Delete duplicate inputs when computing derivation hash.,
guix-commits <=
- 03/10: linux-modules: Add "modules.alias" writer., guix-commits, 2019/08/16
- 10/10: gnu: Add libgit2-glib., guix-commits, 2019/08/16
- 01/10: channels: Add 'profile-channels'., guix-commits, 2019/08/16
- 04/10: linux-modules: Add "modules.devname" writer., guix-commits, 2019/08/16
- 08/10: gnu: txr: Update to 223., guix-commits, 2019/08/16
- 06/10: linux-modules: Define and use a module name database., guix-commits, 2019/08/16
- 05/10: linux-modules: Add 'load-linux-modules-from-directory'., guix-commits, 2019/08/16
- 09/10: gnu: gramps: Update to 5.0.2., guix-commits, 2019/08/16
- 07/10: gnu: wpa-supplicant: install documentation., guix-commits, 2019/08/16