diff options
| -rw-r--r-- | guix/packages.scm | 63 | ||||
| -rw-r--r-- | tests/guix-build.sh | 6 | ||||
| -rw-r--r-- | tests/packages.scm | 43 |
3 files changed, 88 insertions, 24 deletions
diff --git a/guix/packages.scm b/guix/packages.scm index 24d64170653..6fa761f569c 100644 --- a/guix/packages.scm +++ b/guix/packages.scm | |||
| @@ -1015,8 +1015,7 @@ applied to implicit inputs as well." | |||
| 1015 | (define (rewrite input) | 1015 | (define (rewrite input) |
| 1016 | (match input | 1016 | (match input |
| 1017 | ((label (? package? package) outputs ...) | 1017 | ((label (? package? package) outputs ...) |
| 1018 | (let ((proc (if (cut? package) proc replace))) | 1018 | (cons* label (replace package) outputs)) |
| 1019 | (cons* label (proc package) outputs))) | ||
| 1020 | (_ | 1019 | (_ |
| 1021 | input))) | 1020 | input))) |
| 1022 | 1021 | ||
| @@ -1027,28 +1026,44 @@ applied to implicit inputs as well." | |||
| 1027 | (define replace | 1026 | (define replace |
| 1028 | (mlambdaq (p) | 1027 | (mlambdaq (p) |
| 1029 | ;; If P is the result of a previous call, return it. | 1028 | ;; If P is the result of a previous call, return it. |
| 1030 | (if (assq-ref (package-properties p) mapping-property) | 1029 | (cond ((assq-ref (package-properties p) mapping-property) |
| 1031 | p | 1030 | p) |
| 1032 | 1031 | ||
| 1033 | ;; Return a variant of P with PROC applied to P and its explicit | 1032 | ((cut? p) |
| 1034 | ;; dependencies, recursively. Memoize the transformations. Failing | 1033 | ;; Since P's propagated inputs are really inputs of its dependents, |
| 1035 | ;; to do that, we would build a huge object graph with lots of | 1034 | ;; rewrite them as well, unless we're doing a "shallow" rewrite. |
| 1036 | ;; duplicates, which in turns prevents us from benefiting from | 1035 | (let ((p (proc p))) |
| 1037 | ;; memoization in 'package-derivation'. | 1036 | (if (or (not deep?) |
| 1038 | (let ((p (proc p))) | 1037 | (null? (package-propagated-inputs p))) |
| 1039 | (package | 1038 | p |
| 1040 | (inherit p) | 1039 | (package |
| 1041 | (location (package-location p)) | 1040 | (inherit p) |
| 1042 | (build-system (if deep? | 1041 | (location (package-location p)) |
| 1043 | (build-system-with-package-mapping | 1042 | (replacement (package-replacement p)) |
| 1044 | (package-build-system p) rewrite) | 1043 | (propagated-inputs (map rewrite (package-propagated-inputs p))) |
| 1045 | (package-build-system p))) | 1044 | (properties `((,mapping-property . #t) |
| 1046 | (inputs (map rewrite (package-inputs p))) | 1045 | ,@(package-properties p))))))) |
| 1047 | (native-inputs (map rewrite (package-native-inputs p))) | 1046 | |
| 1048 | (propagated-inputs (map rewrite (package-propagated-inputs p))) | 1047 | (else |
| 1049 | (replacement (and=> (package-replacement p) replace)) | 1048 | ;; Return a variant of P with PROC applied to P and its explicit |
| 1050 | (properties `((,mapping-property . #t) | 1049 | ;; dependencies, recursively. Memoize the transformations. Failing |
| 1051 | ,@(package-properties p)))))))) | 1050 | ;; to do that, we would build a huge object graph with lots of |
| 1051 | ;; duplicates, which in turns prevents us from benefiting from | ||
| 1052 | ;; memoization in 'package-derivation'. | ||
| 1053 | (let ((p (proc p))) | ||
| 1054 | (package | ||
| 1055 | (inherit p) | ||
| 1056 | (location (package-location p)) | ||
| 1057 | (build-system (if deep? | ||
| 1058 | (build-system-with-package-mapping | ||
| 1059 | (package-build-system p) rewrite) | ||
| 1060 | (package-build-system p))) | ||
| 1061 | (inputs (map rewrite (package-inputs p))) | ||
| 1062 | (native-inputs (map rewrite (package-native-inputs p))) | ||
| 1063 | (propagated-inputs (map rewrite (package-propagated-inputs p))) | ||
| 1064 | (replacement (and=> (package-replacement p) replace)) | ||
| 1065 | (properties `((,mapping-property . #t) | ||
| 1066 | ,@(package-properties p))))))))) | ||
| 1052 | 1067 | ||
| 1053 | replace) | 1068 | replace) |
| 1054 | 1069 | ||
diff --git a/tests/guix-build.sh b/tests/guix-build.sh index 4a58ea1476c..b7602e668c4 100644 --- a/tests/guix-build.sh +++ b/tests/guix-build.sh | |||
| @@ -289,6 +289,12 @@ drv1=`guix build glib -d` | |||
| 289 | drv2=`guix build glib -d --with-input=libreoffice=inkscape` | 289 | drv2=`guix build glib -d --with-input=libreoffice=inkscape` |
| 290 | test "$drv1" = "$drv2" | 290 | test "$drv1" = "$drv2" |
| 291 | 291 | ||
| 292 | # '--with-graft' should have no effect when using '--no-grafts'. | ||
| 293 | # See <https://bugs.gnu.org/43890>. | ||
| 294 | drv1=`guix build inkscape -d --no-grafts` | ||
| 295 | drv2=`guix build inkscape -d --no-grafts --with-graft=glib=glib-networking` | ||
| 296 | test "$drv1" = "$drv2" | ||
| 297 | |||
| 292 | # Rewriting implicit inputs. | 298 | # Rewriting implicit inputs. |
| 293 | drv1=`guix build hello -d` | 299 | drv1=`guix build hello -d` |
| 294 | drv2=`guix build hello -d --with-input=gcc=gcc-toolchain` | 300 | drv2=`guix build hello -d --with-input=gcc=gcc-toolchain` |
diff --git a/tests/packages.scm b/tests/packages.scm index 2d13d913442..18e8e16e745 100644 --- a/tests/packages.scm +++ b/tests/packages.scm | |||
| @@ -1450,6 +1450,49 @@ | |||
| 1450 | (eq? foo grep) | 1450 | (eq? foo grep) |
| 1451 | (eq? bar dep)))))) | 1451 | (eq? bar dep)))))) |
| 1452 | 1452 | ||
| 1453 | (test-assert "package-input-rewriting/spec, identity" | ||
| 1454 | ;; Make sure that 'package-input-rewriting/spec' doesn't gratuitously | ||
| 1455 | ;; introduce variants. In this case, the LIBFFI propagated input should not | ||
| 1456 | ;; be duplicated when passing GOBJECT through REWRITE. | ||
| 1457 | ;; See <https://issues.guix.gnu.org/43890>. | ||
| 1458 | (let* ((libffi (dummy-package "libffi" | ||
| 1459 | (build-system trivial-build-system))) | ||
| 1460 | (glib (dummy-package "glib" | ||
| 1461 | (build-system trivial-build-system) | ||
| 1462 | (propagated-inputs `(("libffi" ,libffi))))) | ||
| 1463 | (gobject (dummy-package "gobject-introspection" | ||
| 1464 | (build-system trivial-build-system) | ||
| 1465 | (inputs `(("glib" ,glib))) | ||
| 1466 | (propagated-inputs `(("libffi" ,libffi))))) | ||
| 1467 | (rewrite (package-input-rewriting/spec | ||
| 1468 | `(("glib" . ,identity))))) | ||
| 1469 | (and (= (length (package-transitive-inputs gobject)) | ||
| 1470 | (length (package-transitive-inputs (rewrite gobject)))) | ||
| 1471 | (string=? (derivation-file-name | ||
| 1472 | (package-derivation %store (rewrite gobject))) | ||
| 1473 | (derivation-file-name | ||
| 1474 | (package-derivation %store gobject)))))) | ||
| 1475 | |||
| 1476 | (test-assert "package-input-rewriting, identity" | ||
| 1477 | ;; Similar to the test above, but with 'package-input-rewriting'. | ||
| 1478 | ;; See <https://issues.guix.gnu.org/43890>. | ||
| 1479 | (let* ((libffi (dummy-package "libffi" | ||
| 1480 | (build-system trivial-build-system))) | ||
| 1481 | (glib (dummy-package "glib" | ||
| 1482 | (build-system trivial-build-system) | ||
| 1483 | (propagated-inputs `(("libffi" ,libffi))))) | ||
| 1484 | (gobject (dummy-package "gobject-introspection" | ||
| 1485 | (build-system trivial-build-system) | ||
| 1486 | (inputs `(("glib" ,glib))) | ||
| 1487 | (propagated-inputs `(("libffi" ,libffi))))) | ||
| 1488 | (rewrite (package-input-rewriting `((,glib . ,glib))))) | ||
| 1489 | (and (= (length (package-transitive-inputs gobject)) | ||
| 1490 | (length (package-transitive-inputs (rewrite gobject)))) | ||
| 1491 | (string=? (derivation-file-name | ||
| 1492 | (package-derivation %store (rewrite gobject))) | ||
| 1493 | (derivation-file-name | ||
| 1494 | (package-derivation %store gobject)))))) | ||
| 1495 | |||
| 1453 | (test-equal "package-patched-vulnerabilities" | 1496 | (test-equal "package-patched-vulnerabilities" |
| 1454 | '(("CVE-2015-1234") | 1497 | '(("CVE-2015-1234") |
| 1455 | ("CVE-2016-1234" "CVE-2018-4567") | 1498 | ("CVE-2016-1234" "CVE-2018-4567") |
