~ruther/guix-local

6211223021cdb477e93d7ba789d5a0119ffb4bd4 — Ludovic Courtès 13 years ago 44ce77f
union: Delete duplicates when passed the same input several times.

* guix/build/union.scm (union-build): Prepend "." to the result of
  `union-tree', to match the expectations of `delete-duplicate-leaves'.
  Don't do mkdir when SUBDIR is ".".
* tests/union.scm ("union-build"): Keep duplicates in %BOOTSTRAP-INPUTS.
2 files changed, 10 insertions(+), 7 deletions(-)

M guix/build/union.scm
M tests/union.scm
M guix/build/union.scm => guix/build/union.scm +6 -4
@@ 150,8 150,9 @@ the DIRECTORIES."

  (mkdir output)
  (let loop ((tree (delete-duplicate-leaves
                    (tree-union (append-map (compose tree-leaves file-tree)
                                            directories))
                    (cons "."
                          (tree-union (append-map (compose tree-leaves file-tree)
                                                  directories)))
                    leaf=?
                    resolve-collision))
             (dir  '()))


@@ 165,8 166,9 @@ the DIRECTORIES."
         (symlink tree target)))
      (((? string? subdir) leaves ...)
       ;; A sub-directory: create it in OUTPUT, and iterate over LEAVES.
       (let ((dir (string-join dir "/")))
         (mkdir (string-append output "/" dir "/" subdir)))
       (unless (string=? subdir ".")
         (let ((dir (string-join dir "/")))
           (mkdir (string-append output "/" dir "/" subdir))))
       (for-each (cute loop <> `(,@dir ,subdir))
                 leaves))
      ((leaves ...)

M tests/union.scm => tests/union.scm +4 -3
@@ 94,9 94,10 @@
  (let* ((inputs  (map (match-lambda
                        ((name package)
                         `(,name ,(package-derivation %store package))))
                       (delete-duplicates %bootstrap-inputs
                                          (lambda (i1 i2)
                                            (eq? (second i1) (second i2))))))

                       ;; Purposefully leave duplicate entries.
                       (append %bootstrap-inputs
                               (take %bootstrap-inputs 3))))
         (builder `(begin
                     (use-modules (guix build union))
                     (union-build (assoc-ref %outputs "out")