pack: Docker backend now honors '--localstatedir'.
[jackhill/guix/guix.git] / tests / pack.scm
CommitLineData
850edd77 1;;; GNU Guix --- Functional package management for GNU
ccc951ca 2;;; Copyright © 2017, 2018 Ludovic Courtès <ludo@gnu.org>
44057a46 3;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
850edd77
LC
4;;;
5;;; This file is part of GNU Guix.
6;;;
7;;; GNU Guix is free software; you can redistribute it and/or modify it
8;;; under the terms of the GNU General Public License as published by
9;;; the Free Software Foundation; either version 3 of the License, or (at
10;;; your option) any later version.
11;;;
12;;; GNU Guix is distributed in the hope that it will be useful, but
13;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;;; GNU General Public License for more details.
16;;;
17;;; You should have received a copy of the GNU General Public License
18;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19
20(define-module (test-pack)
21 #:use-module (guix scripts pack)
22 #:use-module (guix store)
23 #:use-module (guix derivations)
24 #:use-module (guix profiles)
f5a2fb1b 25 #:use-module (guix packages)
850edd77
LC
26 #:use-module (guix monads)
27 #:use-module (guix grafts)
28 #:use-module (guix tests)
29 #:use-module (guix gexp)
30 #:use-module (gnu packages bootstrap)
31 #:use-module (srfi srfi-64))
32
b27ef1d4
LC
33(define %store
34 (open-connection-for-tests))
35
850edd77
LC
36;; Globally disable grafts because they can trigger early builds.
37(%graft? #f)
38
19c924af 39(define-syntax-rule (test-assertm name store exp)
850edd77 40 (test-assert name
f5a2fb1b
LC
41 (let ((guile (package-derivation store %bootstrap-guile)))
42 (run-with-store store exp
43 #:guile-for-build guile))))
850edd77
LC
44
45(define %gzip-compressor
46 ;; Compressor that uses the bootstrap 'gzip'.
47 ((@ (guix scripts pack) compressor) "gzip"
48b44430
LC
48 "gz"
49 #~(#+(file-append %bootstrap-coreutils&co "/bin/gzip") "-6n")))
850edd77
LC
50
51(define %tar-bootstrap %bootstrap-coreutils&co)
52
53\f
54(test-begin "pack")
55
b27ef1d4
LC
56(unless (network-reachable?) (test-skip 1))
57(test-assertm "self-contained-tarball" %store
58 (mlet* %store-monad
59 ((profile (profile-derivation (packages->manifest
60 (list %bootstrap-guile))
61 #:hooks '()
62 #:locales? #f))
63 (tarball (self-contained-tarball "pack" profile
64 #:symlinks '(("/bin/Guile"
65 -> "bin/guile"))
66 #:compressor %gzip-compressor
67 #:archiver %tar-bootstrap))
68 (check (gexp->derivation
69 "check-tarball"
70 #~(let ((bin (string-append "." #$profile "/bin")))
71 (setenv "PATH"
72 (string-append #$%tar-bootstrap "/bin"))
73 (system* "tar" "xvf" #$tarball)
74 (mkdir #$output)
75 (exit
76 (and (file-exists? (string-append bin "/guile"))
77 (string=? (string-append #$%bootstrap-guile "/bin")
78 (readlink bin))
79 (string=? (string-append ".." #$profile
80 "/bin/guile")
81 (readlink "bin/Guile"))))))))
82 (built-derivations (list check))))
850edd77 83
f5a2fb1b
LC
84;; The following test needs guile-sqlite3, libgcrypt, etc. as a consequence of
85;; commit c45477d2a1a651485feede20fe0f3d15aec48b39 and related changes. Thus,
86;; run it on the user's store, if it's available, on the grounds that these
87;; dependencies may be already there, or we can get substitutes or build them
88;; quite inexpensively; see <https://bugs.gnu.org/32184>.
89
90(with-external-store store
91 (unless store (test-skip 1))
92 (test-assertm "docker-image + localstatedir" store
93 (mlet* %store-monad
94 ((guile (set-guile-for-build (default-guile)))
95 (profile (profile-derivation (packages->manifest
96 (list %bootstrap-guile))
97 #:hooks '()
98 #:locales? #f))
99 (tarball (docker-image "docker-pack" profile
100 #:symlinks '(("/bin/Guile" -> "bin/guile"))
101 #:localstatedir? #t))
102 (check (gexp->derivation
103 "check-tarball"
104 (with-imported-modules '((guix build utils))
105 #~(begin
106 (use-modules (guix build utils)
107 (ice-9 match))
108
109 (define bin
110 (string-append "." #$profile "/bin"))
111
112 (setenv "PATH" (string-append #$%tar-bootstrap "/bin"))
113 (mkdir "base")
114 (with-directory-excursion "base"
115 (invoke "tar" "xvf" #$tarball))
116
117 (match (find-files "base" "layer.tar")
118 ((layer)
119 (invoke "tar" "xvf" layer)))
120
121 (when
122 (and (file-exists? (string-append bin "/guile"))
123 (file-exists? "var/guix/db/db.sqlite")
124 (string=? (string-append #$%bootstrap-guile "/bin")
125 (pk 'binlink (readlink bin)))
126 (string=? (string-append #$profile "/bin/guile")
127 (pk 'guilelink (readlink "bin/Guile"))))
128 (mkdir #$output)))))))
129 (built-derivations (list check)))))
130
850edd77 131(test-end)
19c924af
LC
132
133;; Local Variables:
134;; eval: (put 'test-assertm 'scheme-indent-function 2)
135;; End: