guix build: -S returns the replacement's source.

Reported by Mark H Weaver.

* guix/scripts/build.scm (options->derivations): When SRC and GRAFT? are
true, use the source of P's replacement.
* tests/guix-build.sh: Add test.
This commit is contained in:
Ludovic Courtès 2016-03-02 23:57:23 +01:00
parent 49c4fd2aab
commit 94d609aba8
2 changed files with 19 additions and 9 deletions

View file

@ -592,15 +592,16 @@ (define graft? (assoc-ref opts 'graft?))
(parameterize ((%graft? graft?)) (parameterize ((%graft? graft?))
(append-map (match-lambda (append-map (match-lambda
((? package? p) ((? package? p)
(match src (let ((p (or (and graft? (package-replacement p)) p)))
(#f (match src
(list (package->derivation store p system))) (#f
(#t (list (package->derivation store p system)))
(let ((s (package-source p))) (#t
(list (package-source-derivation store s)))) (let ((s (package-source p)))
(proc (list (package-source-derivation store s))))
(map (cut package-source-derivation store <>) (proc
(proc p))))) (map (cut package-source-derivation store <>)
(proc p))))))
((? derivation? drv) ((? derivation? drv)
(list drv)) (list drv))
((? procedure? proc) ((? procedure? proc)

View file

@ -43,6 +43,7 @@ trap "rm -rf $module_dir" EXIT
cat > "$module_dir/foo.scm"<<EOF cat > "$module_dir/foo.scm"<<EOF
(define-module (foo) (define-module (foo)
#:use-module (guix tests)
#:use-module (guix packages) #:use-module (guix packages)
#:use-module (guix download) #:use-module (guix download)
#:use-module (guix build-system trivial)) #:use-module (guix build-system trivial))
@ -88,6 +89,10 @@ cat > "$module_dir/foo.scm"<<EOF
(synopsis "Dummy package") (synopsis "Dummy package")
(description "bar is a dummy package for testing.") (description "bar is a dummy package for testing.")
(license #f))) (license #f)))
(define-public baz
(dummy-package "baz" (replacement foo)))
EOF EOF
GUIX_PACKAGE_PATH="$module_dir" GUIX_PACKAGE_PATH="$module_dir"
@ -97,6 +102,10 @@ export GUIX_PACKAGE_PATH
guix build -d -S foo guix build -d -S foo
guix build -d -S foo | grep -e 'foo\.tar\.gz' guix build -d -S foo | grep -e 'foo\.tar\.gz'
# 'baz' has a replacement so we should be getting the replacement's source.
(unset GUIX_BUILD_OPTIONS;
test "`guix build -d -S baz`" = "`guix build -d -S foo`")
guix build -d --sources=package foo guix build -d --sources=package foo
guix build -d --sources=package foo | grep -e 'foo\.tar\.gz' guix build -d --sources=package foo | grep -e 'foo\.tar\.gz'