packages: Mark the 'patches' field as delayed.
[jackhill/guix/guix.git] / tests / packages.scm
CommitLineData
233e7676 1;;; GNU Guix --- Functional package management for GNU
f220a838 2;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
e3ce5d70 3;;;
233e7676 4;;; This file is part of GNU Guix.
e3ce5d70 5;;;
233e7676 6;;; GNU Guix is free software; you can redistribute it and/or modify it
e3ce5d70
LC
7;;; under the terms of the GNU General Public License as published by
8;;; the Free Software Foundation; either version 3 of the License, or (at
9;;; your option) any later version.
10;;;
233e7676 11;;; GNU Guix is distributed in the hope that it will be useful, but
e3ce5d70
LC
12;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14;;; GNU General Public License for more details.
15;;;
16;;; You should have received a copy of the GNU General Public License
233e7676 17;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
e3ce5d70 18
e3ce5d70 19(define-module (test-packages)
c1bc358f 20 #:use-module (guix tests)
e3ce5d70 21 #:use-module (guix store)
cf81a236 22 #:use-module (guix monads)
2e1bafb0
LC
23 #:use-module ((guix utils)
24 ;; Rename the 'location' binding to allow proper syntax
25 ;; matching when setting the 'location' field of a package.
26 #:renamer (lambda (name)
27 (cond ((eq? name 'location) 'make-location)
28 (else name))))
f9cc8971 29 #:use-module (guix hash)
e3ce5d70
LC
30 #:use-module (guix derivations)
31 #:use-module (guix packages)
a18eda27 32 #:use-module (guix build-system)
be13fbfa 33 #:use-module (guix build-system trivial)
a3d73f59 34 #:use-module (guix build-system gnu)
cf81a236
LC
35 #:use-module (guix profiles)
36 #:use-module (guix scripts package)
59a43334 37 #:use-module (gnu packages)
1ffa7090 38 #:use-module (gnu packages base)
05962f29 39 #:use-module (gnu packages guile)
1ffa7090 40 #:use-module (gnu packages bootstrap)
cf81a236 41 #:use-module (gnu packages xml)
05962f29 42 #:use-module (srfi srfi-1)
6b1891b0 43 #:use-module (srfi srfi-26)
9b222abe 44 #:use-module (srfi srfi-34)
6b1891b0 45 #:use-module (srfi srfi-64)
860a6f1a 46 #:use-module (rnrs io ports)
2e1bafb0 47 #:use-module (ice-9 regex)
6b1891b0 48 #:use-module (ice-9 match))
e3ce5d70
LC
49
50;; Test the high-level packaging layer.
51
52(define %store
c1bc358f 53 (open-connection-for-tests))
e3ce5d70 54
05962f29
LC
55\f
56(test-begin "packages")
57
2e1bafb0
LC
58(test-assert "printer with location"
59 (string-match "^#<package foo-0 foo.scm:42 [[:xdigit:]]+>$"
60 (with-output-to-string
61 (lambda ()
62 (write
63 (dummy-package "foo"
64 (location (make-location "foo.scm" 42 7))))))))
65
66(test-assert "printer without location"
67 (string-match "^#<package foo-0 [[:xdigit:]]+>$"
68 (with-output-to-string
69 (lambda ()
70 (write
71 (dummy-package "foo" (location #f)))))))
72
d66c7096
LC
73(test-assert "package-field-location"
74 (let ()
75 (define (goto port line column)
76 (unless (and (= (port-column port) (- column 1))
77 (= (port-line port) (- line 1)))
78 (unless (eof-object? (get-char port))
79 (goto port line column))))
80
81 (define read-at
82 (match-lambda
83 (($ <location> file line column)
84 (call-with-input-file (search-path %load-path file)
85 (lambda (port)
86 (goto port line column)
87 (read port))))))
88
ee48b283
LC
89 ;; Until Guile 2.0.6 included, source properties were added only to pairs.
90 ;; Thus, check against both VALUE and (FIELD VALUE).
91 (and (member (read-at (package-field-location %bootstrap-guile 'name))
92 (let ((name (package-name %bootstrap-guile)))
93 (list name `(name ,name))))
94 (member (read-at (package-field-location %bootstrap-guile 'version))
95 (let ((version (package-version %bootstrap-guile)))
96 (list version `(version ,version))))
f903dc05 97 (not (package-field-location %bootstrap-guile 'does-not-exist)))))
d66c7096 98
0b8749b7
LC
99;; Make sure we don't change the file name to an absolute file name.
100(test-equal "package-field-location, relative file name"
101 (location-file (package-location %bootstrap-guile))
102 (with-fluids ((%file-port-name-canonicalization 'absolute))
103 (location-file (package-field-location %bootstrap-guile 'version))))
104
a3d73f59
LC
105(test-assert "package-transitive-inputs"
106 (let* ((a (dummy-package "a"))
107 (b (dummy-package "b"
108 (propagated-inputs `(("a" ,a)))))
109 (c (dummy-package "c"
110 (inputs `(("a" ,a)))))
111 (d (dummy-package "d"
112 (propagated-inputs `(("x" "something.drv")))))
113 (e (dummy-package "e"
114 (inputs `(("b" ,b) ("c" ,c) ("d" ,d))))))
115 (and (null? (package-transitive-inputs a))
116 (equal? `(("a" ,a)) (package-transitive-inputs b))
117 (equal? `(("a" ,a)) (package-transitive-inputs c))
118 (equal? (package-propagated-inputs d)
119 (package-transitive-inputs d))
120 (equal? `(("b" ,b) ("b/a" ,a) ("c" ,c)
121 ("d" ,d) ("d/x" "something.drv"))
122 (pk 'x (package-transitive-inputs e))))))
123
7c3c0374 124(test-equal "package-transitive-supported-systems"
c37a74bd
LC
125 '(("x" "y" "z") ;a
126 ("x" "y") ;b
127 ("y") ;c
128 ("y") ;d
129 ("y")) ;e
7c3c0374
LC
130 (let* ((a (dummy-package "a" (supported-systems '("x" "y" "z"))))
131 (b (dummy-package "b" (supported-systems '("x" "y"))
132 (inputs `(("a" ,a)))))
133 (c (dummy-package "c" (supported-systems '("y" "z"))
c37a74bd
LC
134 (inputs `(("b" ,b)))))
135 (d (dummy-package "d" (supported-systems '("x" "y" "z"))
136 (inputs `(("b" ,b) ("c" ,c)))))
137 (e (dummy-package "e" (supported-systems '("x" "y" "z"))
138 (inputs `(("d" ,d))))))
7c3c0374
LC
139 (list (package-transitive-supported-systems a)
140 (package-transitive-supported-systems b)
c37a74bd
LC
141 (package-transitive-supported-systems c)
142 (package-transitive-supported-systems d)
143 (package-transitive-supported-systems e))))
7c3c0374 144
7357138b
LC
145(test-skip (if (not %store) 8 0))
146
147(test-assert "package-source-derivation, file"
148 (let* ((file (search-path %load-path "guix.scm"))
149 (package (package (inherit (dummy-package "p"))
150 (source file)))
151 (source (package-source-derivation %store
152 (package-source package))))
153 (and (store-path? source)
154 (valid-path? %store source)
155 (equal? (call-with-input-file source get-bytevector-all)
156 (call-with-input-file file get-bytevector-all)))))
157
158(test-assert "package-source-derivation, store path"
159 (let* ((file (add-to-store %store "guix.scm" #t "sha256"
160 (search-path %load-path "guix.scm")))
161 (package (package (inherit (dummy-package "p"))
162 (source file)))
163 (source (package-source-derivation %store
164 (package-source package))))
165 (string=? file source)))
e509d152 166
f80594cc
LC
167(test-assert "package-source-derivation, indirect store path"
168 (let* ((dir (add-to-store %store "guix-build" #t "sha256"
169 (dirname (search-path %load-path
170 "guix/build/utils.scm"))))
171 (package (package (inherit (dummy-package "p"))
172 (source (string-append dir "/utils.scm"))))
173 (source (package-source-derivation %store
174 (package-source package))))
175 (and (direct-store-path? source)
176 (string-suffix? "utils.scm" source))))
177
b29f947d
LC
178(unless (false-if-exception (getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV))
179 (test-skip 1))
f9cc8971
LC
180(test-equal "package-source-derivation, snippet"
181 "OK"
127ed6a9 182 (let* ((file (search-bootstrap-binary "guile-2.0.9.tar.xz"
f9cc8971
LC
183 (%current-system)))
184 (sha256 (call-with-input-file file port-sha256))
f220a838 185 (fetch (lambda* (url hash-algo hash
f9cc8971
LC
186 #:optional name #:key system)
187 (pk 'fetch url hash-algo hash name system)
f220a838 188 (interned-file url)))
f9cc8971
LC
189 (source (bootstrap-origin
190 (origin
191 (method fetch)
192 (uri file)
193 (sha256 sha256)
194 (patch-inputs
195 `(("tar" ,%bootstrap-coreutils&co)
196 ("xz" ,%bootstrap-coreutils&co)
197 ("patch" ,%bootstrap-coreutils&co)))
7db9608d 198 (patch-guile %bootstrap-guile)
f9cc8971
LC
199 (modules '((guix build utils)))
200 (imported-modules modules)
201 (snippet '(begin
202 ;; We end up in 'bin', because it's the first
203 ;; directory, alphabetically. Not a very good
204 ;; example but hey.
205 (chmod "." #o777)
206 (symlink "guile" "guile-rocks")
207 (copy-recursively "../share/guile/2.0/scripts"
208 "scripts")
209
210 ;; These variables must exist.
211 (pk %build-inputs %outputs))))))
212 (package (package (inherit (dummy-package "with-snippet"))
213 (source source)
214 (build-system trivial-build-system)
215 (inputs
216 `(("tar" ,(search-bootstrap-binary "tar"
217 (%current-system)))
218 ("xz" ,(search-bootstrap-binary "xz"
219 (%current-system)))))
220 (arguments
221 `(#:guile ,%bootstrap-guile
222 #:builder
223 (let ((tar (assoc-ref %build-inputs "tar"))
224 (xz (assoc-ref %build-inputs "xz"))
225 (source (assoc-ref %build-inputs "source")))
226 (and (zero? (system* tar "xvf" source
227 "--use-compress-program" xz))
228 (string=? "guile" (readlink "bin/guile-rocks"))
229 (file-exists? "bin/scripts/compile.scm")
230 (let ((out (assoc-ref %outputs "out")))
231 (call-with-output-file out
232 (lambda (p)
233 (display "OK" p))))))))))
234 (drv (package-derivation %store package))
235 (out (derivation->output-path drv)))
236 (and (build-derivations %store (list (pk 'snippet-drv drv)))
237 (call-with-input-file out get-string-all))))
238
59688fc4
LC
239(test-assert "return value"
240 (let ((drv (package-derivation %store (dummy-package "p"))))
241 (and (derivation? drv)
242 (file-exists? (derivation-file-name drv)))))
be13fbfa 243
d510ab46
LC
244(test-assert "package-output"
245 (let* ((package (dummy-package "p"))
59688fc4
LC
246 (drv (package-derivation %store package)))
247 (and (derivation? drv)
248 (string=? (derivation->output-path drv)
d510ab46
LC
249 (package-output %store package "out")))))
250
be13fbfa
LC
251(test-assert "trivial"
252 (let* ((p (package (inherit (dummy-package "trivial"))
253 (build-system trivial-build-system)
254 (source #f)
255 (arguments
14da91e2
LC
256 `(#:guile ,%bootstrap-guile
257 #:builder
be13fbfa
LC
258 (begin
259 (mkdir %output)
260 (call-with-output-file (string-append %output "/test")
261 (lambda (p)
262 (display '(hello guix) p))))))))
263 (d (package-derivation %store p)))
264 (and (build-derivations %store (list d))
59688fc4 265 (let ((p (pk 'drv d (derivation->output-path d))))
be13fbfa
LC
266 (equal? '(hello guix)
267 (call-with-input-file (string-append p "/test") read))))))
e3ce5d70 268
860a6f1a
LC
269(test-assert "trivial with local file as input"
270 (let* ((i (search-path %load-path "ice-9/boot-9.scm"))
271 (p (package (inherit (dummy-package "trivial-with-input-file"))
272 (build-system trivial-build-system)
273 (source #f)
274 (arguments
275 `(#:guile ,%bootstrap-guile
276 #:builder (copy-file (assoc-ref %build-inputs "input")
277 %output)))
278 (inputs `(("input" ,i)))))
279 (d (package-derivation %store p)))
280 (and (build-derivations %store (list d))
59688fc4 281 (let ((p (pk 'drv d (derivation->output-path d))))
860a6f1a
LC
282 (equal? (call-with-input-file p get-bytevector-all)
283 (call-with-input-file i get-bytevector-all))))))
284
03761a44
LC
285(test-assert "trivial with source"
286 (let* ((i (search-path %load-path "ice-9/boot-9.scm"))
287 (p (package (inherit (dummy-package "trivial-with-source"))
288 (build-system trivial-build-system)
289 (source i)
290 (arguments
291 `(#:guile ,%bootstrap-guile
292 #:builder (copy-file (assoc-ref %build-inputs "source")
293 %output)))))
294 (d (package-derivation %store p)))
295 (and (build-derivations %store (list d))
296 (let ((p (derivation->output-path d)))
297 (equal? (call-with-input-file p get-bytevector-all)
298 (call-with-input-file i get-bytevector-all))))))
299
592ef6c8
LC
300(test-assert "trivial with system-dependent input"
301 (let* ((p (package (inherit (dummy-package "trivial-system-dependent-input"))
302 (build-system trivial-build-system)
303 (source #f)
304 (arguments
305 `(#:guile ,%bootstrap-guile
306 #:builder
307 (let ((out (assoc-ref %outputs "out"))
308 (bash (assoc-ref %build-inputs "bash")))
309 (zero? (system* bash "-c"
310 (format #f "echo hello > ~a" out))))))
dd6b9a37
LC
311 (inputs `(("bash" ,(search-bootstrap-binary "bash"
312 (%current-system)))))))
592ef6c8
LC
313 (d (package-derivation %store p)))
314 (and (build-derivations %store (list d))
59688fc4 315 (let ((p (pk 'drv d (derivation->output-path d))))
592ef6c8
LC
316 (eq? 'hello (call-with-input-file p read))))))
317
a18eda27
LC
318(test-assert "search paths"
319 (let* ((p (make-prompt-tag "return-search-paths"))
320 (s (build-system
0d5a559f 321 (name 'raw)
a18eda27 322 (description "Raw build system with direct store access")
d3d337d2
LC
323 (lower (lambda* (name #:key source inputs system target
324 #:allow-other-keys)
0d5a559f
LC
325 (bag
326 (name name)
d3d337d2 327 (system system) (target target)
0d5a559f
LC
328 (build-inputs inputs)
329 (build
330 (lambda* (store name inputs
331 #:key outputs system search-paths)
332 search-paths)))))))
a18eda27
LC
333 (x (list (search-path-specification
334 (variable "GUILE_LOAD_PATH")
af070955 335 (files '("share/guile/site/2.0")))
a18eda27
LC
336 (search-path-specification
337 (variable "GUILE_LOAD_COMPILED_PATH")
af070955 338 (files '("share/guile/site/2.0")))))
a18eda27
LC
339 (a (package (inherit (dummy-package "guile"))
340 (build-system s)
341 (native-search-paths x)))
342 (b (package (inherit (dummy-package "guile-foo"))
343 (build-system s)
344 (inputs `(("guile" ,a)))))
345 (c (package (inherit (dummy-package "guile-bar"))
346 (build-system s)
347 (inputs `(("guile" ,a)
348 ("guile-foo" ,b))))))
349 (let-syntax ((collect (syntax-rules ()
350 ((_ body ...)
351 (call-with-prompt p
352 (lambda ()
353 body ...)
354 (lambda (k search-paths)
355 search-paths))))))
356 (and (null? (collect (package-derivation %store a)))
357 (equal? x (collect (package-derivation %store b)))
358 (equal? x (collect (package-derivation %store c)))))))
359
9c1edabd 360(test-assert "package-cross-derivation"
59688fc4
LC
361 (let ((drv (package-cross-derivation %store (dummy-package "p")
362 "mips64el-linux-gnu")))
363 (and (derivation? drv)
364 (file-exists? (derivation-file-name drv)))))
9c1edabd 365
5dce8218
LC
366(test-assert "package-cross-derivation, trivial-build-system"
367 (let ((p (package (inherit (dummy-package "p"))
368 (build-system trivial-build-system)
369 (arguments '(#:builder (exit 1))))))
59688fc4
LC
370 (let ((drv (package-cross-derivation %store p "mips64el-linux-gnu")))
371 (derivation? drv))))
5dce8218 372
9b222abe
LC
373(test-assert "package-cross-derivation, no cross builder"
374 (let* ((b (build-system (inherit trivial-build-system)
0d5a559f 375 (lower (const #f))))
9b222abe
LC
376 (p (package (inherit (dummy-package "p"))
377 (build-system b))))
378 (guard (c ((package-cross-build-system-error? c)
379 (eq? (package-error-package c) p)))
380 (package-cross-derivation %store p "mips64el-linux-gnu")
381 #f)))
382
05962f29
LC
383(test-equal "package-derivation, direct graft"
384 (package-derivation %store gnu-make)
385 (let ((p (package (inherit coreutils)
386 (replacement gnu-make))))
387 (package-derivation %store p)))
388
389(test-equal "package-cross-derivation, direct graft"
390 (package-cross-derivation %store gnu-make "mips64el-linux-gnu")
391 (let ((p (package (inherit coreutils)
392 (replacement gnu-make))))
393 (package-cross-derivation %store p "mips64el-linux-gnu")))
394
395(test-assert "package-grafts, indirect grafts"
396 (let* ((new (dummy-package "dep"
397 (arguments '(#:implicit-inputs? #f))))
398 (dep (package (inherit new) (version "0.0")))
399 (dep* (package (inherit dep) (replacement new)))
400 (dummy (dummy-package "dummy"
401 (arguments '(#:implicit-inputs? #f))
402 (inputs `(("dep" ,dep*))))))
403 (equal? (package-grafts %store dummy)
404 (list (graft
405 (origin (package-derivation %store dep))
406 (replacement (package-derivation %store new)))))))
407
408(test-assert "package-grafts, indirect grafts, cross"
409 (let* ((new (dummy-package "dep"
410 (arguments '(#:implicit-inputs? #f))))
411 (dep (package (inherit new) (version "0.0")))
412 (dep* (package (inherit dep) (replacement new)))
413 (dummy (dummy-package "dummy"
414 (arguments '(#:implicit-inputs? #f))
415 (inputs `(("dep" ,dep*)))))
416 (target "mips64el-linux-gnu"))
417 (equal? (package-grafts %store dummy #:target target)
418 (list (graft
419 (origin (package-cross-derivation %store dep target))
420 (replacement
421 (package-cross-derivation %store new target)))))))
422
423(test-assert "package-grafts, indirect grafts, propagated inputs"
424 (let* ((new (dummy-package "dep"
425 (arguments '(#:implicit-inputs? #f))))
426 (dep (package (inherit new) (version "0.0")))
427 (dep* (package (inherit dep) (replacement new)))
428 (prop (dummy-package "propagated"
429 (propagated-inputs `(("dep" ,dep*)))
430 (arguments '(#:implicit-inputs? #f))))
431 (dummy (dummy-package "dummy"
432 (arguments '(#:implicit-inputs? #f))
433 (inputs `(("prop" ,prop))))))
434 (equal? (package-grafts %store dummy)
435 (list (graft
436 (origin (package-derivation %store dep))
437 (replacement (package-derivation %store new)))))))
438
439(test-assert "package-derivation, indirect grafts"
440 (let* ((new (dummy-package "dep"
441 (arguments '(#:implicit-inputs? #f))))
442 (dep (package (inherit new) (version "0.0")))
443 (dep* (package (inherit dep) (replacement new)))
444 (dummy (dummy-package "dummy"
445 (arguments '(#:implicit-inputs? #f))
446 (inputs `(("dep" ,dep*)))))
447 (guile (package-derivation %store (canonical-package guile-2.0)
448 #:graft? #f)))
449 (equal? (package-derivation %store dummy)
450 (graft-derivation %store "dummy-0"
451 (package-derivation %store dummy #:graft? #f)
452 (package-grafts %store dummy)
453
454 ;; Use the same Guile as 'package-derivation'.
455 #:guile guile))))
456
d3d337d2
LC
457(test-equal "package->bag"
458 `("foo86-hurd" #f (,(package-source gnu-make))
459 (,(canonical-package glibc)) (,(canonical-package coreutils)))
460 (let ((bag (package->bag gnu-make "foo86-hurd")))
461 (list (bag-system bag) (bag-target bag)
462 (assoc-ref (bag-build-inputs bag) "source")
463 (assoc-ref (bag-build-inputs bag) "libc")
464 (assoc-ref (bag-build-inputs bag) "coreutils"))))
465
466(test-equal "package->bag, cross-compilation"
467 `(,(%current-system) "foo86-hurd"
468 (,(package-source gnu-make))
469 (,(canonical-package glibc)) (,(canonical-package coreutils)))
470 (let ((bag (package->bag gnu-make (%current-system) "foo86-hurd")))
471 (list (bag-system bag) (bag-target bag)
472 (assoc-ref (bag-build-inputs bag) "source")
473 (assoc-ref (bag-build-inputs bag) "libc")
474 (assoc-ref (bag-build-inputs bag) "coreutils"))))
475
50373bab
LC
476(test-assert "package->bag, propagated inputs"
477 (let* ((dep (dummy-package "dep"))
478 (prop (dummy-package "prop"
479 (propagated-inputs `(("dep" ,dep)))))
480 (dummy (dummy-package "dummy"
481 (inputs `(("prop" ,prop)))))
482 (inputs (bag-transitive-inputs (package->bag dummy #:graft? #f))))
483 (match (assoc "prop/dep" inputs)
484 (("prop/dep" package)
485 (eq? package dep)))))
486
d3d337d2 487(test-assert "bag->derivation"
05962f29
LC
488 (parameterize ((%graft? #f))
489 (let ((bag (package->bag gnu-make))
490 (drv (package-derivation %store gnu-make)))
491 (parameterize ((%current-system "foox86-hurd")) ;should have no effect
492 (equal? drv (bag->derivation %store bag))))))
d3d337d2
LC
493
494(test-assert "bag->derivation, cross-compilation"
05962f29
LC
495 (parameterize ((%graft? #f))
496 (let* ((target "mips64el-linux-gnu")
497 (bag (package->bag gnu-make (%current-system) target))
498 (drv (package-cross-derivation %store gnu-make target)))
499 (parameterize ((%current-system "foox86-hurd") ;should have no effect
500 (%current-target-system "foo64-linux-gnu"))
501 (equal? drv (bag->derivation %store bag))))))
d3d337d2 502
ad1ebab3
LC
503(unless (false-if-exception (getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV))
504 (test-skip 1))
9e782349
LC
505(test-assert "GNU Make, bootstrap"
506 ;; GNU Make is the first program built during bootstrap; we choose it
507 ;; here so that the test doesn't last for too long.
bdb36958 508 (let ((gnu-make (@@ (gnu packages commencement) gnu-make-boot0)))
9e782349
LC
509 (and (package? gnu-make)
510 (or (location? (package-location gnu-make))
511 (not (package-location gnu-make)))
512 (let* ((drv (package-derivation %store gnu-make))
59688fc4 513 (out (derivation->output-path drv)))
14da91e2 514 (and (build-derivations %store (list drv))
9e782349 515 (file-exists? (string-append out "/bin/make")))))))
e3ce5d70 516
ba326ce4
LC
517(test-eq "fold-packages" hello
518 (fold-packages (lambda (p r)
519 (if (string=? (package-name p) "hello")
520 p
521 r))
522 #f))
523
6b1891b0
LC
524(test-assert "find-packages-by-name"
525 (match (find-packages-by-name "hello")
526 (((? (cut eq? hello <>))) #t)
527 (wrong (pk 'find-packages-by-name wrong #f))))
528
529(test-assert "find-packages-by-name with version"
530 (match (find-packages-by-name "hello" (package-version hello))
531 (((? (cut eq? hello <>))) #t)
532 (wrong (pk 'find-packages-by-name wrong #f))))
533
cf81a236
LC
534(test-assert "--search-paths with pattern"
535 ;; Make sure 'guix package --search-paths' correctly reports environment
536 ;; variables when file patterns are used (in particular, it must follow
537 ;; symlinks when looking for 'catalog.xml'.) To do that, we rely on the
538 ;; libxml2 package specification, which contains such a definition.
539 (let* ((p1 (package
540 (name "foo") (version "0") (source #f)
541 (build-system trivial-build-system)
542 (arguments
543 `(#:guile ,%bootstrap-guile
544 #:modules ((guix build utils))
545 #:builder (begin
546 (use-modules (guix build utils))
547 (let ((out (assoc-ref %outputs "out")))
548 (mkdir-p (string-append out "/xml/bar/baz"))
549 (call-with-output-file
550 (string-append out "/xml/bar/baz/catalog.xml")
551 (lambda (port)
552 (display "xml? wat?!" port)))))))
553 (synopsis #f) (description #f)
554 (home-page #f) (license #f)))
555 (p2 (package
556 ;; Provide a fake libxml2 to avoid building the real one. This
557 ;; is OK because 'guix package' gets search path specifications
558 ;; from the same-named package found in the distro.
559 (name "libxml2") (version "0.0.0") (source #f)
560 (build-system trivial-build-system)
561 (arguments
562 `(#:guile ,%bootstrap-guile
563 #:builder (mkdir (assoc-ref %outputs "out"))))
564 (native-search-paths (package-native-search-paths libxml2))
565 (synopsis #f) (description #f)
566 (home-page #f) (license #f)))
567 (prof (run-with-store %store
568 (profile-derivation
569 (manifest (map package->manifest-entry
570 (list p1 p2)))
571 #:info-dir? #f)
572 #:guile-for-build (%guile-for-build))))
573 (build-derivations %store (list prof))
574 (string-match (format #f "^export XML_CATALOG_FILES=\"~a/xml/+bar/baz/catalog\\.xml\"\n"
575 (derivation->output-path prof))
576 (with-output-to-string
577 (lambda ()
578 (guix-package "-p" (derivation->output-path prof)
579 "--search-paths"))))))
580
e3ce5d70
LC
581(test-end "packages")
582
583\f
584(exit (= (test-runner-fail-count (test-runner-current)) 0))
585
586;;; Local Variables:
a3d73f59 587;;; eval: (put 'dummy-package 'scheme-indent-function 1)
e3ce5d70 588;;; End: