guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Ludovic Courtès
Subject: 03/03: guix build: -S returns the replacement's source.
Date: Wed, 02 Mar 2016 23:18:47 +0000

civodul pushed a commit to branch master
in repository guix.

commit 94d609aba8e14963459c21863ab56da2b5f01517
Author: Ludovic Courtès <address@hidden>
Date:   Wed Mar 2 23:57:23 2016 +0100

    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.
---
 guix/scripts/build.scm |   19 ++++++++++---------
 tests/guix-build.sh    |    9 +++++++++
 2 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm
index d6bb35c..a8becea 100644
--- a/guix/scripts/build.scm
+++ b/guix/scripts/build.scm
@@ -592,15 +592,16 @@ build."
   (parameterize ((%graft? graft?))
     (append-map (match-lambda
                   ((? package? p)
-                   (match src
-                     (#f
-                      (list (package->derivation store p system)))
-                     (#t
-                      (let ((s (package-source p)))
-                        (list (package-source-derivation store s))))
-                     (proc
-                      (map (cut package-source-derivation store <>)
-                           (proc p)))))
+                   (let ((p (or (and graft? (package-replacement p)) p)))
+                     (match src
+                       (#f
+                        (list (package->derivation store p system)))
+                       (#t
+                        (let ((s (package-source p)))
+                          (list (package-source-derivation store s))))
+                       (proc
+                        (map (cut package-source-derivation store <>)
+                             (proc p))))))
                   ((? derivation? drv)
                    (list drv))
                   ((? procedure? proc)
diff --git a/tests/guix-build.sh b/tests/guix-build.sh
index 5821e50..ae75bcf 100644
--- a/tests/guix-build.sh
+++ b/tests/guix-build.sh
@@ -43,6 +43,7 @@ trap "rm -rf $module_dir" EXIT
 
 cat > "$module_dir/foo.scm"<<EOF
 (define-module (foo)
+  #:use-module (guix tests)
   #:use-module (guix packages)
   #:use-module (guix download)
   #:use-module (guix build-system trivial))
@@ -88,6 +89,10 @@ cat > "$module_dir/foo.scm"<<EOF
     (synopsis "Dummy package")
     (description "bar is a dummy package for testing.")
     (license #f)))
+
+(define-public baz
+  (dummy-package "baz" (replacement foo)))
+
 EOF
 
 GUIX_PACKAGE_PATH="$module_dir"
@@ -97,6 +102,10 @@ export GUIX_PACKAGE_PATH
 guix build -d -S foo
 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 | grep -e 'foo\.tar\.gz'
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]