diff options
| -rw-r--r-- | guix/grafts.scm | 15 | ||||
| -rw-r--r-- | tests/grafts.scm | 48 |
2 files changed, 61 insertions, 2 deletions
diff --git a/guix/grafts.scm b/guix/grafts.scm index 80ae27e9b0c..dda7c1d2352 100644 --- a/guix/grafts.scm +++ b/guix/grafts.scm | |||
| @@ -280,8 +280,19 @@ derivations to the corresponding set of grafts." | |||
| 280 | (let* ((new (graft-derivation/shallow store drv applicable | 280 | (let* ((new (graft-derivation/shallow store drv applicable |
| 281 | #:guile guile | 281 | #:guile guile |
| 282 | #:system system)) | 282 | #:system system)) |
| 283 | (grafts (cons (graft (origin drv) (replacement new)) | 283 | |
| 284 | grafts))) | 284 | ;; Replace references to any of the outputs of DRV, |
| 285 | ;; even if that's more than needed. This is so that | ||
| 286 | ;; the result refers only to the outputs of NEW and | ||
| 287 | ;; not to those of DRV. | ||
| 288 | (grafts (append (map (lambda (output) | ||
| 289 | (graft | ||
| 290 | (origin drv) | ||
| 291 | (origin-output output) | ||
| 292 | (replacement new) | ||
| 293 | (replacement-output output))) | ||
| 294 | (derivation-output-names drv)) | ||
| 295 | grafts))) | ||
| 285 | (return/cache cache grafts)))))))))))) | 296 | (return/cache cache grafts)))))))))))) |
| 286 | 297 | ||
| 287 | (define* (graft-derivation store drv grafts | 298 | (define* (graft-derivation store drv grafts |
diff --git a/tests/grafts.scm b/tests/grafts.scm index 4eff06b4b3c..6454a03b1f5 100644 --- a/tests/grafts.scm +++ b/tests/grafts.scm | |||
| @@ -201,6 +201,54 @@ | |||
| 201 | (and (string=? (readlink one) repl) | 201 | (and (string=? (readlink one) repl) |
| 202 | (string=? (readlink two) one)))))) | 202 | (string=? (readlink two) one)))))) |
| 203 | 203 | ||
| 204 | (test-assert "graft-derivation, replaced derivation has multiple outputs" | ||
| 205 | ;; Here we have a replacement just for output "one" of P1 and not for the | ||
| 206 | ;; other output. Make sure the graft for P1:one correctly applies to the | ||
| 207 | ;; dependents of P1. See <http://bugs.gnu.org/24712>. | ||
| 208 | (let* ((p1 (build-expression->derivation | ||
| 209 | %store "p1" | ||
| 210 | `(let ((one (assoc-ref %outputs "one")) | ||
| 211 | (two (assoc-ref %outputs "two"))) | ||
| 212 | (mkdir one) | ||
| 213 | (mkdir two)) | ||
| 214 | #:outputs '("one" "two"))) | ||
| 215 | (p1r (build-expression->derivation | ||
| 216 | %store "P1" | ||
| 217 | `(let ((other (assoc-ref %outputs "ONE"))) | ||
| 218 | (mkdir other) | ||
| 219 | (call-with-output-file (string-append other "/replacement") | ||
| 220 | (const #t))) | ||
| 221 | #:outputs '("ONE"))) | ||
| 222 | (p2 (build-expression->derivation | ||
| 223 | %store "p2" | ||
| 224 | `(let ((out (assoc-ref %outputs "aaa"))) | ||
| 225 | (mkdir (assoc-ref %outputs "zzz")) | ||
| 226 | (mkdir out) (chdir out) | ||
| 227 | (symlink (assoc-ref %build-inputs "p1:one") "one") | ||
| 228 | (symlink (assoc-ref %build-inputs "p1:two") "two")) | ||
| 229 | #:outputs '("aaa" "zzz") | ||
| 230 | #:inputs `(("p1:one" ,p1 "one") | ||
| 231 | ("p1:two" ,p1 "two")))) | ||
| 232 | (p3 (build-expression->derivation | ||
| 233 | %store "p3" | ||
| 234 | `(symlink (assoc-ref %build-inputs "p2:aaa") | ||
| 235 | (assoc-ref %outputs "out")) | ||
| 236 | #:inputs `(("p2:aaa" ,p2 "aaa") | ||
| 237 | ("p2:zzz" ,p2 "zzz")))) | ||
| 238 | (p1g (graft | ||
| 239 | (origin p1) | ||
| 240 | (origin-output "one") | ||
| 241 | (replacement p1r) | ||
| 242 | (replacement-output "ONE"))) | ||
| 243 | (p3d (graft-derivation %store p3 (list p1g)))) | ||
| 244 | (and (build-derivations %store (list p3d)) | ||
| 245 | (let ((out (derivation->output-path (pk 'p2d p3d)))) | ||
| 246 | (and (not (string=? (readlink out) | ||
| 247 | (derivation->output-path p2 "aaa"))) | ||
| 248 | (string=? (derivation->output-path p1 "two") | ||
| 249 | (readlink (string-append out "/two"))) | ||
| 250 | (file-exists? (string-append out "/one/replacement"))))))) | ||
| 251 | |||
| 204 | (test-assert "graft-derivation, renaming" ;<http://bugs.gnu.org/23132> | 252 | (test-assert "graft-derivation, renaming" ;<http://bugs.gnu.org/23132> |
| 205 | (let* ((build `(begin | 253 | (let* ((build `(begin |
| 206 | (use-modules (guix build utils)) | 254 | (use-modules (guix build utils)) |
