guix-commits
[Top][All Lists]
Advanced

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

02/03: profiles: Build union of inputs in the right order.


From: guix-commits
Subject: 02/03: profiles: Build union of inputs in the right order.
Date: Tue, 22 Jun 2021 11:55:53 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit b9a95420abdf4ae7fe9a347031278a44ad6a1cce
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Tue Jun 22 16:42:06 2021 +0200

    profiles: Build union of inputs in the right order.
    
    Fixes <https://bugs.gnu.org/49102>.
    Reported by Mathieu Othacehe <othacehe@gnu.org>
    and Tobias Geerinckx-Rice <me@tobias.gr>.
    
    Fixes a regression introduced in
    8cef92d0633850d97c1a1d4521812268f56672be, whereby in case of file
    collisions, the "wrong" one would take precedence.
    
    * guix/build/profiles.scm (manifest-sexp->inputs+search-paths): Perform
    a breadth-first traversal.  Reverse INPUTS and SEARCH-PATHS in the base
    case.
    * tests/profiles.scm ("profile-derivation, ordering & collisions"):
    New test.
---
 guix/build/profiles.scm |  6 +++---
 tests/profiles.scm      | 30 ++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/guix/build/profiles.scm b/guix/build/profiles.scm
index 9249977..f9875ca 100644
--- a/guix/build/profiles.scm
+++ b/guix/build/profiles.scm
@@ -159,15 +159,15 @@ search path specifications."
          (((name version output item
                  ('propagated-inputs deps)
                  ('search-paths paths) _ ...) . rest)
-          (loop (append deps rest)
+          (loop (append rest deps)                ;breadth-first traversal
                 (cons item inputs)
                 (append paths search-paths)))
          (()
-          (values inputs
+          (values (reverse inputs)
                   (delete-duplicates
                    (cons $PATH
                          (map sexp->search-path-specification
-                              search-paths))))))))))
+                              (reverse search-paths)))))))))))
 
 (define* (build-profile output manifest
                         #:key (extra-inputs '()) (symlink symlink))
diff --git a/tests/profiles.scm b/tests/profiles.scm
index 1a06ff8..06a0387 100644
--- a/tests/profiles.scm
+++ b/tests/profiles.scm
@@ -279,6 +279,36 @@
                  (string=? (dirname (readlink bindir))
                            (derivation->output-path guile))))))
 
+(test-assertm "profile-derivation, ordering & collisions"
+  ;; ENTRY1 and ENTRY2 both provide 'bin/guile'--a collision.  Make sure
+  ;; ENTRY1 "wins" over ENTRY2.  See <https://bugs.gnu.org/49102>.
+  (mlet* %store-monad
+      ((entry1 ->  (package->manifest-entry %bootstrap-guile))
+       (entry2 ->  (manifest-entry
+                     (name "fake-guile")
+                     (version "0")
+                     (item (computed-file
+                            "fake-guile"
+                            #~(begin
+                                (mkdir #$output)
+                                (mkdir (string-append #$output "/bin"))
+                                (call-with-output-file
+                                    (string-append #$output "/bin/guile")
+                                  (lambda (port)
+                                    (display "Fake!\n" port))))))))
+       (guile      (package->derivation %bootstrap-guile))
+       (drv        (profile-derivation (manifest (list entry1 entry2))
+                                       #:hooks '()
+                                       #:locales? #f))
+       (profile -> (derivation->output-path drv))
+       (bindir ->  (string-append profile "/bin"))
+       (file ->    (string-append bindir "/guile"))
+       (_          (built-derivations (list drv))))
+    (return (string=? (readlink file)
+                      (string-append
+                       (derivation->output-path guile)
+                       "/bin/guile")))))
+
 (test-assertm "load-profile"
   (mlet* %store-monad
       ((entry ->   (package->manifest-entry %bootstrap-guile))



reply via email to

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