summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2021-09-24 23:00:11 +0200
committerLudovic Courtès <ludo@gnu.org>2021-09-25 00:41:32 +0200
commitdf46bef48eaa43c502fa9193371692c039b460c1 (patch)
treebe496d3a0e8ff150ff8fc48c53f29c73e8f23867
parent9fbe4b88c2369166733bc039fb261839846011d3 (diff)
gexp: Leave grafting as is when lowering allowed/disallowed references.
Fixes <https://issues.guix.gnu.org/50676>. Reported by Mathieu Othacehe <othacehe@gnu.org>. Commit a779363b6aa581e88eda21f9f35530962d54ac25 was partially incorrect: references passed to #:allowed-references or #:references-graphs *can* be lowered as references to grafted elements. This is for example the case when doing: (computed-file "partition.img" exp #:options `(#:references-graphs ,inputs)) Here INPUTS must be lowered as a reference to suitably grafted elements. Failing to do that, the reference graph will not match the actual INPUTS. However, when building a package, those references must indeed refer only to ungrafted packages. This commit preserves that by having build systems pass #:graft? #f. * guix/gexp.scm (lower-reference-graphs, lower-references): Remove uses of 'without-grafting'. This reverts a779363b6aa581e88eda21f9f35530962d54ac25. * guix/build-system/cmake.scm (cmake-build, cmake-cross-build): Pass #:graft? #f. * guix/build-system/glib-or-gtk.scm (glib-or-gtk-build) (glib-or-gtk-cross-build): Likewise. * guix/build-system/gnu.scm (gnu-build, gnu-cross-build): Likewise. * guix/build-system/meson.scm (meson-build, meson-cross-build): Likewise. * guix/build-system/trivial.scm (trivial-build, trivial-cross-build): Likewise. * tests/gexp.scm ("lower-object, computed-file + grafts"): New test. * tests/packages.scm ("trivial with #:allowed-references + grafts"): New test.
-rw-r--r--guix/build-system/cmake.scm2
-rw-r--r--guix/build-system/glib-or-gtk.scm2
-rw-r--r--guix/build-system/gnu.scm4
-rw-r--r--guix/build-system/meson.scm2
-rw-r--r--guix/build-system/trivial.scm2
-rw-r--r--guix/gexp.scm17
-rw-r--r--tests/gexp.scm36
-rw-r--r--tests/packages.scm22
8 files changed, 77 insertions, 10 deletions
diff --git a/guix/build-system/cmake.scm b/guix/build-system/cmake.scm
index d500eccfdec..2056c04153b 100644
--- a/guix/build-system/cmake.scm
+++ b/guix/build-system/cmake.scm
@@ -158,6 +158,7 @@ provides a 'CMakeLists.txt' file as its build system."
158 (gexp->derivation name build 158 (gexp->derivation name build
159 #:system system 159 #:system system
160 #:target #f 160 #:target #f
161 #:graft? #f
161 #:substitutable? substitutable? 162 #:substitutable? substitutable?
162 #:guile-for-build guile))) 163 #:guile-for-build guile)))
163 164
@@ -248,6 +249,7 @@ build system."
248 (gexp->derivation name builder 249 (gexp->derivation name builder
249 #:system system 250 #:system system
250 #:target target 251 #:target target
252 #:graft? #f
251 #:substitutable? substitutable? 253 #:substitutable? substitutable?
252 #:guile-for-build guile))) 254 #:guile-for-build guile)))
253 255
diff --git a/guix/build-system/glib-or-gtk.scm b/guix/build-system/glib-or-gtk.scm
index ec491ff0bd0..0c88f039d22 100644
--- a/guix/build-system/glib-or-gtk.scm
+++ b/guix/build-system/glib-or-gtk.scm
@@ -186,6 +186,7 @@
186 (gexp->derivation name build 186 (gexp->derivation name build
187 #:system system 187 #:system system
188 #:target #f 188 #:target #f
189 #:graft? #f
189 #:allowed-references allowed-references 190 #:allowed-references allowed-references
190 #:disallowed-references disallowed-references 191 #:disallowed-references disallowed-references
191 #:guile-for-build guile))) 192 #:guile-for-build guile)))
@@ -279,6 +280,7 @@
279 (gexp->derivation name builder 280 (gexp->derivation name builder
280 #:system system 281 #:system system
281 #:target target 282 #:target target
283 #:graft? #f
282 #:modules imported-modules 284 #:modules imported-modules
283 #:allowed-references allowed-references 285 #:allowed-references allowed-references
284 #:disallowed-references disallowed-references 286 #:disallowed-references disallowed-references
diff --git a/guix/build-system/gnu.scm b/guix/build-system/gnu.scm
index ea91be5bcd0..651415098ee 100644
--- a/guix/build-system/gnu.scm
+++ b/guix/build-system/gnu.scm
@@ -423,9 +423,12 @@ are allowed to refer to."
423 423
424 (mlet %store-monad ((guile (package->derivation (or guile (default-guile)) 424 (mlet %store-monad ((guile (package->derivation (or guile (default-guile))
425 system #:graft? #f))) 425 system #:graft? #f)))
426 ;; Note: Always pass #:graft? #f. Without it, ALLOWED-REFERENCES &
427 ;; co. would be interpreted as referring to grafted packages.
426 (gexp->derivation name builder 428 (gexp->derivation name builder
427 #:system system 429 #:system system
428 #:target #f 430 #:target #f
431 #:graft? #f
429 #:substitutable? substitutable? 432 #:substitutable? substitutable?
430 #:allowed-references allowed-references 433 #:allowed-references allowed-references
431 #:disallowed-references disallowed-references 434 #:disallowed-references disallowed-references
@@ -560,6 +563,7 @@ platform."
560 (gexp->derivation name builder 563 (gexp->derivation name builder
561 #:system system 564 #:system system
562 #:target target 565 #:target target
566 #:graft? #f
563 #:modules imported-modules 567 #:modules imported-modules
564 #:substitutable? substitutable? 568 #:substitutable? substitutable?
565 #:allowed-references allowed-references 569 #:allowed-references allowed-references
diff --git a/guix/build-system/meson.scm b/guix/build-system/meson.scm
index dcad3f322d0..198aa08729a 100644
--- a/guix/build-system/meson.scm
+++ b/guix/build-system/meson.scm
@@ -233,6 +233,7 @@ has a 'meson.build' file."
233 (gexp->derivation name builder 233 (gexp->derivation name builder
234 #:system system 234 #:system system
235 #:target #f 235 #:target #f
236 #:graft? #f
236 #:substitutable? substitutable? 237 #:substitutable? substitutable?
237 #:allowed-references allowed-references 238 #:allowed-references allowed-references
238 #:disallowed-references disallowed-references 239 #:disallowed-references disallowed-references
@@ -332,6 +333,7 @@ SOURCE has a 'meson.build' file."
332 (gexp->derivation name builder 333 (gexp->derivation name builder
333 #:system system 334 #:system system
334 #:target target 335 #:target target
336 #:graft? #f
335 #:substitutable? substitutable? 337 #:substitutable? substitutable?
336 #:allowed-references allowed-references 338 #:allowed-references allowed-references
337 #:disallowed-references disallowed-references 339 #:disallowed-references disallowed-references
diff --git a/guix/build-system/trivial.scm b/guix/build-system/trivial.scm
index cd35c846cee..378ae481b9c 100644
--- a/guix/build-system/trivial.scm
+++ b/guix/build-system/trivial.scm
@@ -61,6 +61,7 @@ ignored."
61 (gexp->derivation name (with-build-variables inputs outputs builder) 61 (gexp->derivation name (with-build-variables inputs outputs builder)
62 #:system system 62 #:system system
63 #:target #f 63 #:target #f
64 #:graft? #f
64 #:modules modules 65 #:modules modules
65 #:allowed-references allowed-references 66 #:allowed-references allowed-references
66 #:guile-for-build guile))) 67 #:guile-for-build guile)))
@@ -85,6 +86,7 @@ ignored."
85 builder) 86 builder)
86 #:system system 87 #:system system
87 #:target target 88 #:target target
89 #:graft? #f
88 #:modules modules 90 #:modules modules
89 #:allowed-references allowed-references 91 #:allowed-references allowed-references
90 #:guile-for-build guile))) 92 #:guile-for-build guile)))
diff --git a/guix/gexp.scm b/guix/gexp.scm
index ff5ede28572..56b1bb4951e 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -923,9 +923,8 @@ corresponding <derivation-input> or store item."
923 923
924 (match graphs 924 (match graphs
925 (((file-names . inputs) ...) 925 (((file-names . inputs) ...)
926 (mlet %store-monad ((inputs (without-grafting 926 (mlet %store-monad ((inputs (lower-inputs (map tuple->gexp-input inputs)
927 (lower-inputs (map tuple->gexp-input inputs) 927 system target)))
928 system target))))
929 (return (map cons file-names inputs)))))) 928 (return (map cons file-names inputs))))))
930 929
931(define* (lower-references lst #:key system target) 930(define* (lower-references lst #:key system target)
@@ -938,15 +937,13 @@ names and file names suitable for the #:allowed-references argument to
938 ((? string? output) 937 ((? string? output)
939 (return output)) 938 (return output))
940 (($ <gexp-input> thing output native?) 939 (($ <gexp-input> thing output native?)
941 (mlet %store-monad ((drv (without-grafting 940 (mlet %store-monad ((drv (lower-object thing system
942 (lower-object thing system 941 #:target (if native?
943 #:target (if native? 942 #f target))))
944 #f target)))))
945 (return (derivation->output-path drv output)))) 943 (return (derivation->output-path drv output))))
946 (thing 944 (thing
947 (mlet %store-monad ((drv (without-grafting 945 (mlet %store-monad ((drv (lower-object thing system
948 (lower-object thing system 946 #:target target)))
949 #:target target))))
950 (return (derivation->output-path drv)))))) 947 (return (derivation->output-path drv))))))
951 948
952 (mapm/accumulate-builds lower lst))) 949 (mapm/accumulate-builds lower lst)))
diff --git a/tests/gexp.scm b/tests/gexp.scm
index 709a198e1ea..28d09f5a6d1 100644
--- a/tests/gexp.scm
+++ b/tests/gexp.scm
@@ -1475,6 +1475,42 @@ importing.* \\(guix config\\) from the host"
1475 (string=? (readlink (string-append comp "/text")) 1475 (string=? (readlink (string-append comp "/text"))
1476 text))))))) 1476 text)))))))
1477 1477
1478(test-assert "lower-object, computed-file + grafts"
1479 ;; The reference graph should refer to grafted packages when grafts are
1480 ;; enabled. See <https://issues.guix.gnu.org/50676>.
1481 (let* ((base (package
1482 (inherit (dummy-package "trivial"))
1483 (build-system trivial-build-system)
1484 (arguments
1485 `(#:guile ,%bootstrap-guile
1486 #:builder (mkdir %output)))))
1487 (pkg (package
1488 (inherit base)
1489 (version "1.1")
1490 (replacement (package
1491 (inherit base)
1492 (version "9.9")))))
1493 (exp #~(begin
1494 (use-modules (ice-9 rdelim))
1495 (let ((item (call-with-input-file "graph" read-line)))
1496 (call-with-output-file #$output
1497 (lambda (port)
1498 (display item port))))))
1499 (computed (computed-file "computed" exp
1500 #:options
1501 `(#:references-graphs (("graph" ,pkg)))))
1502 (drv0 (package-derivation %store pkg #:graft? #t))
1503 (drv1 (parameterize ((%graft? #t))
1504 (run-with-store %store
1505 (lower-object computed)))))
1506 (build-derivations %store (list drv1))
1507
1508 ;; The graph obtained in COMPUTED should refer to the grafted version of
1509 ;; PKG, not to PKG itself.
1510 (string=? (call-with-input-file (derivation->output-path drv1)
1511 get-string-all)
1512 (derivation->output-path drv0))))
1513
1478(test-equal "lower-object, computed-file, #:system" 1514(test-equal "lower-object, computed-file, #:system"
1479 '("mips64el-linux") 1515 '("mips64el-linux")
1480 (run-with-store %store 1516 (run-with-store %store
diff --git a/tests/packages.scm b/tests/packages.scm
index 46f4da1494b..a9494b5c0eb 100644
--- a/tests/packages.scm
+++ b/tests/packages.scm
@@ -882,6 +882,28 @@
882 (build-derivations %store (list d)) 882 (build-derivations %store (list d))
883 #f))) 883 #f)))
884 884
885(test-assert "trivial with #:allowed-references + grafts"
886 (let* ((g (package
887 (inherit %bootstrap-guile)
888 (replacement (package
889 (inherit %bootstrap-guile)
890 (version "9.9")))))
891 (p (package
892 (inherit (dummy-package "trivial"))
893 (build-system trivial-build-system)
894 (inputs (list g))
895 (arguments
896 `(#:guile ,g
897 #:allowed-references (,g)
898 #:builder (mkdir %output)))))
899 (d0 (package-derivation %store p #:graft? #f))
900 (d1 (parameterize ((%graft? #t))
901 (package-derivation %store p #:graft? #t))))
902 ;; D1 should be equal to D2 because there's nothing to graft. In
903 ;; particular, its #:disallowed-references should be lowered in the same
904 ;; way (ungrafted) whether or not #:graft? is true.
905 (string=? (derivation-file-name d1) (derivation-file-name d0))))
906
885(test-assert "search paths" 907(test-assert "search paths"
886 (let* ((p (make-prompt-tag "return-search-paths")) 908 (let* ((p (make-prompt-tag "return-search-paths"))
887 (t (make-parameter "guile-0")) 909 (t (make-parameter "guile-0"))