summaryrefslogtreecommitdiff
path: root/tests/grafts.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2023-10-27 23:44:39 +0200
committerLudovic Courtès <ludo@gnu.org>2023-10-28 00:17:23 +0200
commit67effc1560fc175dfbcb58ef5b965b08b3942d6c (patch)
tree34b28ec16e7b968ab02dac4bb56a721273c4c126 /tests/grafts.scm
parent2de30042674197fe451c220745186e36465d06e2 (diff)
grafts: Fix corner case involving multiple-output derivations.
Fixes a bug that would occur with references to two outputs of the same derivation, with one of them referring to the other one. For example, the references of libreoffice include both mariadb:dev and mariadb:lib; additionally, mariadb:dev refers to mariadb:lib. In this case, the glibc graft would not be applied on one of the mariadb paths, and both the grafted and ungrafted glibc would end up in the closure of libreoffice. Fixes <https://issues.guix.gnu.org/66662>. * guix/grafts.scm (non-self-references): Simplify and include references to outputs of DRV other than OUTPUTS. (reference-origins): Simplify and possibly return outputs of DRV itself. (cumulative-grafts)[graft-origin?]: Add OUTPUT parameter and honor it. [dependency-grafts]: Adjust accordingly. * tests/grafts.scm ("graft-derivation, multiple outputs need to be replaced"): New test. Change-Id: Iac2005024ab7049037537b3af55298696ec90e3c
Diffstat (limited to 'tests/grafts.scm')
-rw-r--r--tests/grafts.scm50
1 files changed, 49 insertions, 1 deletions
diff --git a/tests/grafts.scm b/tests/grafts.scm
index 63dbb138302..24c4d243598 100644
--- a/tests/grafts.scm
+++ b/tests/grafts.scm
@@ -1,5 +1,5 @@
1;;; GNU Guix --- Functional package management for GNU 1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2014-2019, 2022 Ludovic Courtès <ludo@gnu.org> 2;;; Copyright © 2014-2019, 2022-2023 Ludovic Courtès <ludo@gnu.org>
3;;; Copyright © 2021 Mark H Weaver <mhw@netris.org> 3;;; Copyright © 2021 Mark H Weaver <mhw@netris.org>
4;;; 4;;;
5;;; This file is part of GNU Guix. 5;;; This file is part of GNU Guix.
@@ -268,6 +268,54 @@
268 (readlink (string-append out "/two"))) 268 (readlink (string-append out "/two")))
269 (file-exists? (string-append out "/one/replacement"))))))) 269 (file-exists? (string-append out "/one/replacement")))))))
270 270
271(test-assert "graft-derivation, multiple outputs need to be replaced"
272 ;; Build a reference graph like this:
273 ;;
274 ;; ,- p2:out --.
275 ;; v v
276 ;; p1:one <---- p1:two
277 ;; |
278 ;; `-> p0
279 ;;
280 ;; Graft p0r in lieu of p0, and make sure all the paths from the grafted p2
281 ;; lead to p0r. See <https://issues.guix.gnu.org/66662>.
282 (let* ((p0 (build-expression->derivation
283 %store "p0" '(mkdir (assoc-ref %outputs "out"))))
284 (p0r (build-expression->derivation
285 %store "P0"
286 '(let ((out (assoc-ref %outputs "out")))
287 (mkdir out)
288 (call-with-output-file (string-append out "/replacement")
289 (const #t)))))
290 (p1 (build-expression->derivation
291 %store "p1"
292 `(let ((one (assoc-ref %outputs "one"))
293 (two (assoc-ref %outputs "two"))
294 (p0 (assoc-ref %build-inputs "p0")))
295 (mkdir one)
296 (mkdir two)
297 (symlink p0 (string-append one "/p0"))
298 (symlink one (string-append two "/link")))
299 #:inputs `(("p0" ,p0))
300 #:outputs '("one" "two")))
301 (p2 (build-expression->derivation
302 %store "p2"
303 `(let ((out (assoc-ref %outputs "out")))
304 (mkdir out) (chdir out)
305 (symlink (assoc-ref %build-inputs "p1:one") "one")
306 (symlink (assoc-ref %build-inputs "p1:two") "two"))
307 #:inputs `(("p1:one" ,p1 "one")
308 ("p1:two" ,p1 "two"))))
309 (p0g (list (graft
310 (origin p0)
311 (replacement p0r))))
312 (p2d (graft-derivation %store p2 p0g)))
313
314 (build-derivations %store (list p2d))
315 (let ((out (derivation->output-path (pk 'p2d p2d))))
316 (equal? (stat (string-append out "/one/p0/replacement"))
317 (stat (string-append out "/two/link/p0/replacement"))))))
318
271(test-assert "graft-derivation with #:outputs" 319(test-assert "graft-derivation with #:outputs"
272 ;; Call 'graft-derivation' with a narrowed set of outputs passed as 320 ;; Call 'graft-derivation' with a narrowed set of outputs passed as
273 ;; #:outputs. 321 ;; #:outputs.