From 4a6aeb670f74ef895878631bc3d832d08e1cb321 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 3 Jul 2015 00:05:16 +0200 Subject: derivations: Add #:substitutable?, distinguished from #:local-build?. Fixes . * guix/derivations.scm (substitutable-derivation?): Rewrite to check for "allowSubstitutes". (derivation): Add #:substitutable? parameter. [user+system-env-vars]: Honor it. (build-expression->derivation): Add #:substitutable? and honor it. * guix/gexp.scm (gexp->derivation): Likewise. * tests/derivations.scm ("derivation-prerequisites-to-build and substitutes, non-substitutable build"): Use #:substitutable? instead of #:local-build?. ("substitutable-derivation?", "derivation-prerequisites-to-build and substitutes, local build"): New tests. * guix/download.scm (url-fetch): Adjust comment. * guix/git-download.scm (git-fetch): Likewise. * guix/build-system/gnu.scm (gnu-build, gnu-cross-build): Use #:substitutable? instead of #:local-build?. * doc/guix.texi (Derivations, G-Expressions): Adjust accordingly. --- tests/derivations.scm | 44 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) (limited to 'tests/derivations.scm') diff --git a/tests/derivations.scm b/tests/derivations.scm index df5f07d117..f66ef5cdd7 100644 --- a/tests/derivations.scm +++ b/tests/derivations.scm @@ -188,10 +188,22 @@ (define prefix-len (string-length dir)) (test-assert "offloadable-derivation?" (and (offloadable-derivation? (derivation %store "foo" %bash '())) + (offloadable-derivation? ;see + (derivation %store "foo" %bash '() + #:substitutable? #f)) (not (offloadable-derivation? (derivation %store "foo" %bash '() #:local-build? #t))))) +(test-assert "substitutable-derivation?" + (and (substitutable-derivation? (derivation %store "foo" %bash '())) + (substitutable-derivation? ;see + (derivation %store "foo" %bash '() + #:local-build? #f)) + (not (substitutable-derivation? + (derivation %store "foo" %bash '() + #:substitutable? #f))))) + (test-assert "fixed-output-derivation?" (let* ((builder (add-text-to-store %store "my-fixed-builder.sh" "echo -n hello > $out" '())) @@ -614,14 +626,11 @@ (define %coreutils (null? download*) (null? build*)))))) -(test-assert "derivation-prerequisites-to-build and substitutes, local build" +(test-assert "derivation-prerequisites-to-build and substitutes, non-substitutable build" (let* ((store (open-connection)) - (drv (build-expression->derivation store "prereq-subst-local" + (drv (build-expression->derivation store "prereq-no-subst" (random 1000) - ;; XXX: Adjust once - ;; - ;; is fixed. - #:local-build? #t)) + #:substitutable? #f)) (output (derivation->output-path drv))) ;; Make sure substitutes are usable. @@ -631,13 +640,34 @@ (define %coreutils (let-values (((build download) (derivation-prerequisites-to-build store drv))) ;; Despite being available as a substitute, DRV will be built locally - ;; due to #:local-build?. + ;; due to #:substitutable? #f. (and (null? download) (match build (((? derivation-input? input)) (string=? (derivation-input-path input) (derivation-file-name drv))))))))) +(test-assert "derivation-prerequisites-to-build and substitutes, local build" + (with-store store + (let* ((drv (build-expression->derivation store "prereq-subst-local" + (random 1000) + #:local-build? #t)) + (output (derivation->output-path drv))) + + ;; Make sure substitutes are usable. + (set-build-options store #:use-substitutes? #t) + + (with-derivation-narinfo drv + (let-values (((build download) + (derivation-prerequisites-to-build store drv))) + ;; #:local-build? is not be synonymous with #:substitutable?, so we + ;; must be able to substitute DRV's output. + ;; See . + (and (null? build) + (match download + (((? string? item)) + (string=? item (derivation->output-path drv)))))))))) + (test-assert "build-expression->derivation with expression returning #f" (let* ((builder '(begin (mkdir %output) -- cgit v1.2.3