Commit | Line | Data |
---|---|---|
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) | |
598a6b87 | 31 | #:use-module ((gnu packages compression) #:select (squashfs-tools-next)) |
850edd77 LC |
32 | #:use-module (srfi srfi-64)) |
33 | ||
b27ef1d4 LC |
34 | (define %store |
35 | (open-connection-for-tests)) | |
36 | ||
850edd77 LC |
37 | ;; Globally disable grafts because they can trigger early builds. |
38 | (%graft? #f) | |
39 | ||
19c924af | 40 | (define-syntax-rule (test-assertm name store exp) |
850edd77 | 41 | (test-assert name |
f5a2fb1b LC |
42 | (let ((guile (package-derivation store %bootstrap-guile))) |
43 | (run-with-store store exp | |
44 | #:guile-for-build guile)))) | |
850edd77 LC |
45 | |
46 | (define %gzip-compressor | |
47 | ;; Compressor that uses the bootstrap 'gzip'. | |
48 | ((@ (guix scripts pack) compressor) "gzip" | |
48b44430 LC |
49 | "gz" |
50 | #~(#+(file-append %bootstrap-coreutils&co "/bin/gzip") "-6n"))) | |
850edd77 LC |
51 | |
52 | (define %tar-bootstrap %bootstrap-coreutils&co) | |
53 | ||
54 | \f | |
55 | (test-begin "pack") | |
56 | ||
b27ef1d4 LC |
57 | (unless (network-reachable?) (test-skip 1)) |
58 | (test-assertm "self-contained-tarball" %store | |
59 | (mlet* %store-monad | |
60 | ((profile (profile-derivation (packages->manifest | |
61 | (list %bootstrap-guile)) | |
62 | #:hooks '() | |
63 | #:locales? #f)) | |
64 | (tarball (self-contained-tarball "pack" profile | |
65 | #:symlinks '(("/bin/Guile" | |
66 | -> "bin/guile")) | |
67 | #:compressor %gzip-compressor | |
68 | #:archiver %tar-bootstrap)) | |
69 | (check (gexp->derivation | |
70 | "check-tarball" | |
71 | #~(let ((bin (string-append "." #$profile "/bin"))) | |
72 | (setenv "PATH" | |
73 | (string-append #$%tar-bootstrap "/bin")) | |
74 | (system* "tar" "xvf" #$tarball) | |
75 | (mkdir #$output) | |
76 | (exit | |
77 | (and (file-exists? (string-append bin "/guile")) | |
78 | (string=? (string-append #$%bootstrap-guile "/bin") | |
79 | (readlink bin)) | |
80 | (string=? (string-append ".." #$profile | |
81 | "/bin/guile") | |
82 | (readlink "bin/Guile")))))))) | |
83 | (built-derivations (list check)))) | |
850edd77 | 84 | |
f5a2fb1b LC |
85 | ;; The following test needs guile-sqlite3, libgcrypt, etc. as a consequence of |
86 | ;; commit c45477d2a1a651485feede20fe0f3d15aec48b39 and related changes. Thus, | |
87 | ;; run it on the user's store, if it's available, on the grounds that these | |
88 | ;; dependencies may be already there, or we can get substitutes or build them | |
89 | ;; quite inexpensively; see <https://bugs.gnu.org/32184>. | |
90 | ||
91 | (with-external-store store | |
92 | (unless store (test-skip 1)) | |
93 | (test-assertm "docker-image + localstatedir" store | |
94 | (mlet* %store-monad | |
95 | ((guile (set-guile-for-build (default-guile))) | |
96 | (profile (profile-derivation (packages->manifest | |
97 | (list %bootstrap-guile)) | |
98 | #:hooks '() | |
99 | #:locales? #f)) | |
100 | (tarball (docker-image "docker-pack" profile | |
101 | #:symlinks '(("/bin/Guile" -> "bin/guile")) | |
102 | #:localstatedir? #t)) | |
103 | (check (gexp->derivation | |
104 | "check-tarball" | |
105 | (with-imported-modules '((guix build utils)) | |
106 | #~(begin | |
107 | (use-modules (guix build utils) | |
108 | (ice-9 match)) | |
109 | ||
110 | (define bin | |
111 | (string-append "." #$profile "/bin")) | |
112 | ||
113 | (setenv "PATH" (string-append #$%tar-bootstrap "/bin")) | |
114 | (mkdir "base") | |
115 | (with-directory-excursion "base" | |
116 | (invoke "tar" "xvf" #$tarball)) | |
117 | ||
118 | (match (find-files "base" "layer.tar") | |
119 | ((layer) | |
120 | (invoke "tar" "xvf" layer))) | |
121 | ||
122 | (when | |
123 | (and (file-exists? (string-append bin "/guile")) | |
124 | (file-exists? "var/guix/db/db.sqlite") | |
125 | (string=? (string-append #$%bootstrap-guile "/bin") | |
126 | (pk 'binlink (readlink bin))) | |
127 | (string=? (string-append #$profile "/bin/guile") | |
128 | (pk 'guilelink (readlink "bin/Guile")))) | |
129 | (mkdir #$output))))))) | |
598a6b87 LC |
130 | (built-derivations (list check)))) |
131 | ||
132 | (unless store (test-skip 1)) | |
133 | (test-assertm "squashfs-image + localstatedir" store | |
134 | (mlet* %store-monad | |
135 | ((guile (set-guile-for-build (default-guile))) | |
136 | (profile (profile-derivation (packages->manifest | |
137 | (list %bootstrap-guile)) | |
138 | #:hooks '() | |
139 | #:locales? #f)) | |
140 | (image (squashfs-image "squashfs-pack" profile | |
141 | #:symlinks '(("/bin" -> "bin")) | |
142 | #:localstatedir? #t)) | |
143 | (check (gexp->derivation | |
144 | "check-tarball" | |
145 | (with-imported-modules '((guix build utils)) | |
146 | #~(begin | |
147 | (use-modules (guix build utils) | |
148 | (ice-9 match)) | |
149 | ||
150 | (define bin | |
151 | (string-append "." #$profile "/bin")) | |
152 | ||
153 | (setenv "PATH" | |
154 | (string-append #$squashfs-tools-next "/bin")) | |
155 | (invoke "unsquashfs" #$image) | |
156 | (with-directory-excursion "squashfs-root" | |
157 | (when (and (file-exists? (string-append bin | |
158 | "/guile")) | |
159 | (file-exists? "var/guix/db/db.sqlite") | |
160 | (string=? (string-append #$%bootstrap-guile "/bin") | |
161 | (pk 'binlink (readlink bin))) | |
162 | (string=? (string-append #$profile "/bin") | |
163 | (pk 'guilelink (readlink "bin")))) | |
164 | (mkdir #$output)))))))) | |
f5a2fb1b LC |
165 | (built-derivations (list check))))) |
166 | ||
850edd77 | 167 | (test-end) |
19c924af LC |
168 | |
169 | ;; Local Variables: | |
170 | ;; eval: (put 'test-assertm 'scheme-indent-function 2) | |
171 | ;; End: |