Commit | Line | Data |
---|---|---|
94b4274d | 1 | ;;; GNU Guix --- Functional package management for GNU |
3adf320e | 2 | ;;; Copyright © 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org> |
4f51fdba | 3 | ;;; Copyright © 2017, 2019 Tobias Geerinckx-Rice <me@tobias.gr> |
1550db6f | 4 | ;;; Copyright © 2020 Mathieu Othacehe <m.othacehe@gmail.com> |
af7a8e71 | 5 | ;;; Copyright © 2020 Danny Milosavljevic <dannym@scratchpost.org> |
7ca533c7 | 6 | ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> |
886302fc | 7 | ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com> |
94b4274d LC |
8 | ;;; |
9 | ;;; This file is part of GNU Guix. | |
10 | ;;; | |
11 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
12 | ;;; under the terms of the GNU General Public License as published by | |
13 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
14 | ;;; your option) any later version. | |
15 | ;;; | |
16 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
17 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | ;;; GNU General Public License for more details. | |
20 | ;;; | |
21 | ;;; You should have received a copy of the GNU General Public License | |
22 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
23 | ||
24 | (define-module (gnu tests install) | |
25 | #:use-module (gnu) | |
a48a20fb | 26 | #:use-module (gnu bootloader extlinux) |
f19cf27c | 27 | #:use-module (gnu image) |
94b4274d LC |
28 | #:use-module (gnu tests) |
29 | #:use-module (gnu tests base) | |
30 | #:use-module (gnu system) | |
f19cf27c | 31 | #:use-module (gnu system image) |
94b4274d LC |
32 | #:use-module (gnu system install) |
33 | #:use-module (gnu system vm) | |
34 | #:use-module ((gnu build vm) #:select (qemu-command)) | |
ccb1a8c4 | 35 | #:use-module (gnu packages admin) |
a48a20fb | 36 | #:use-module (gnu packages bootloaders) |
0e72d49e | 37 | #:use-module (gnu packages commencement) ;for 'guile-final' |
ccb1a8c4 | 38 | #:use-module (gnu packages cryptsetup) |
95b3fc12 | 39 | #:use-module (gnu packages disk) |
1197b8b2 JN |
40 | #:use-module (gnu packages emacs) |
41 | #:use-module (gnu packages emacs-xyz) | |
95b3fc12 | 42 | #:use-module (gnu packages firmware) |
ccb1a8c4 | 43 | #:use-module (gnu packages linux) |
f7f292d3 | 44 | #:use-module (gnu packages ocr) |
b03ebdbc | 45 | #:use-module (gnu packages openbox) |
94b4274d | 46 | #:use-module (gnu packages package-management) |
b03ebdbc MO |
47 | #:use-module (gnu packages ratpoison) |
48 | #:use-module (gnu packages suckless) | |
59132b80 | 49 | #:use-module (gnu packages virtualization) |
b03ebdbc MO |
50 | #:use-module (gnu packages wm) |
51 | #:use-module (gnu packages xorg) | |
52 | #:use-module (gnu services desktop) | |
ccb1a8c4 | 53 | #:use-module (gnu services networking) |
b03ebdbc | 54 | #:use-module (gnu services xorg) |
94b4274d LC |
55 | #:use-module (guix store) |
56 | #:use-module (guix monads) | |
57 | #:use-module (guix packages) | |
58 | #:use-module (guix grafts) | |
59 | #:use-module (guix gexp) | |
60 | #:use-module (guix utils) | |
b03ebdbc | 61 | #:use-module (srfi srfi-1) |
b1bf155f | 62 | #:export (%test-installed-os |
a48a20fb | 63 | %test-installed-extlinux-os |
fbc7b1f1 | 64 | %test-iso-image-installer |
5479aa2b | 65 | %test-separate-store-os |
ae763b5b | 66 | %test-separate-home-os |
245cc5f5 | 67 | %test-raid-root-os |
4f83afd2 | 68 | %test-encrypted-root-os |
f00e68ac | 69 | %test-encrypted-root-not-boot-os |
4f51fdba | 70 | %test-btrfs-root-os |
b460ba79 | 71 | %test-btrfs-root-on-subvolume-os |
886302fc | 72 | %test-btrfs-raid-root-os |
ccb1a8c4 | 73 | %test-jfs-root-os |
af7a8e71 | 74 | %test-f2fs-root-os |
a9a2fdaa | 75 | %test-lvm-separate-home-os |
ccb1a8c4 | 76 | |
e666a923 | 77 | %test-gui-installed-os |
95b3fc12 | 78 | %test-gui-uefi-installed-os |
b03ebdbc MO |
79 | %test-gui-installed-os-encrypted |
80 | %test-gui-installed-desktop-os-encrypted)) | |
94b4274d LC |
81 | |
82 | ;;; Commentary: | |
83 | ;;; | |
59e80445 | 84 | ;;; Test the installation of Guix using the documented approach at the |
94b4274d LC |
85 | ;;; command line. |
86 | ;;; | |
87 | ;;; Code: | |
88 | ||
89 | (define-os-with-source (%minimal-os %minimal-os-source) | |
90 | ;; The OS we want to install. | |
91 | (use-modules (gnu) (gnu tests) (srfi srfi-1)) | |
92 | ||
93 | (operating-system | |
94 | (host-name "liberigilo") | |
95 | (timezone "Europe/Paris") | |
96 | (locale "en_US.UTF-8") | |
97 | ||
fdfdecdb TGR |
98 | (bootloader (bootloader-configuration |
99 | (bootloader grub-bootloader) | |
100 | (target "/dev/vdb"))) | |
94b4274d LC |
101 | (kernel-arguments '("console=ttyS0")) |
102 | (file-systems (cons (file-system | |
9ceeca08 | 103 | (device (file-system-label "my-root")) |
94b4274d LC |
104 | (mount-point "/") |
105 | (type "ext4")) | |
106 | %base-file-systems)) | |
107 | (users (cons (user-account | |
108 | (name "alice") | |
109 | (comment "Bob's sister") | |
110 | (group "users") | |
cf848cc0 | 111 | (supplementary-groups '("wheel" "audio" "video"))) |
94b4274d LC |
112 | %base-user-accounts)) |
113 | (services (cons (service marionette-service-type | |
a4bbf41b LC |
114 | (marionette-configuration |
115 | (imported-modules '((gnu services herd) | |
f9d55c49 | 116 | (guix build utils) |
a4bbf41b | 117 | (guix combinators))))) |
94b4274d LC |
118 | %base-services)))) |
119 | ||
a48a20fb MO |
120 | (define (operating-system-add-packages os packages) |
121 | "Append PACKAGES to OS packages list." | |
122 | (operating-system | |
123 | (inherit os) | |
124 | (packages (append packages (operating-system-packages os))))) | |
125 | ||
126 | (define-os-with-source (%minimal-extlinux-os | |
127 | %minimal-extlinux-os-source) | |
128 | (use-modules (gnu) (gnu tests) (gnu bootloader extlinux) | |
129 | (srfi srfi-1)) | |
130 | ||
131 | (operating-system | |
132 | (host-name "liberigilo") | |
133 | (timezone "Europe/Paris") | |
134 | (locale "en_US.UTF-8") | |
135 | ||
136 | (bootloader (bootloader-configuration | |
137 | (bootloader extlinux-bootloader-gpt) | |
045ebb3e | 138 | (target "/dev/vdb"))) |
a48a20fb MO |
139 | (kernel-arguments '("console=ttyS0")) |
140 | (file-systems (cons (file-system | |
9ceeca08 | 141 | (device (file-system-label "my-root")) |
a48a20fb MO |
142 | (mount-point "/") |
143 | (type "ext4")) | |
144 | %base-file-systems)) | |
145 | (services (cons (service marionette-service-type | |
146 | (marionette-configuration | |
147 | (imported-modules '((gnu services herd) | |
148 | (guix combinators))))) | |
149 | %base-services)))) | |
150 | ||
94b4274d LC |
151 | (define (operating-system-with-current-guix os) |
152 | "Return a variant of OS that uses the current Guix." | |
153 | (operating-system | |
154 | (inherit os) | |
155 | (services (modify-services (operating-system-user-services os) | |
156 | (guix-service-type config => | |
157 | (guix-configuration | |
158 | (inherit config) | |
159 | (guix (current-guix)))))))) | |
160 | ||
94b4274d LC |
161 | \f |
162 | (define MiB (expt 2 20)) | |
163 | ||
b1bf155f LC |
164 | (define %simple-installation-script |
165 | ;; Shell script of a simple installation. | |
166 | "\ | |
167 | . /etc/profile | |
168 | set -e -x | |
169 | guix --version | |
170 | ||
171 | export GUIX_BUILD_OPTIONS=--no-grafts | |
172 | guix build isc-dhcp | |
173 | parted --script /dev/vdb mklabel gpt \\ | |
174 | mkpart primary ext2 1M 3M \\ | |
5e766fe5 | 175 | mkpart primary ext2 3M 1.6G \\ |
b1bf155f LC |
176 | set 1 boot on \\ |
177 | set 1 bios_grub on | |
178 | mkfs.ext4 -L my-root /dev/vdb2 | |
179 | mount /dev/vdb2 /mnt | |
180 | df -h /mnt | |
181 | herd start cow-store /mnt | |
182 | mkdir /mnt/etc | |
183 | cp /etc/target-config.scm /mnt/etc/config.scm | |
184 | guix system init /mnt/etc/config.scm /mnt --no-substitutes | |
185 | sync | |
186 | reboot\n") | |
187 | ||
a48a20fb MO |
188 | (define %extlinux-gpt-installation-script |
189 | ;; Shell script of a simple installation. | |
190 | ;; As syslinux 6.0.3 does not handle 64bits ext4 partitions, | |
191 | ;; we make sure to pass -O '^64bit' to mkfs. | |
192 | "\ | |
193 | . /etc/profile | |
194 | set -e -x | |
195 | guix --version | |
196 | ||
197 | export GUIX_BUILD_OPTIONS=--no-grafts | |
198 | guix build isc-dhcp | |
199 | parted --script /dev/vdb mklabel gpt \\ | |
5e766fe5 | 200 | mkpart ext2 1M 1.6G \\ |
a48a20fb MO |
201 | set 1 legacy_boot on |
202 | mkfs.ext4 -L my-root -O '^64bit' /dev/vdb1 | |
203 | mount /dev/vdb1 /mnt | |
204 | df -h /mnt | |
205 | herd start cow-store /mnt | |
206 | mkdir /mnt/etc | |
207 | cp /etc/target-config.scm /mnt/etc/config.scm | |
208 | guix system init /mnt/etc/config.scm /mnt --no-substitutes | |
209 | sync | |
210 | reboot\n") | |
211 | ||
95b3fc12 MO |
212 | (define (uefi-firmware system) |
213 | "Return the appropriate QEMU OVMF UEFI firmware for the given SYSTEM." | |
214 | (cond | |
215 | ((string-prefix? "x86_64" system) | |
216 | (file-append ovmf "/share/firmware/ovmf_x64.bin")) | |
217 | ((string-prefix? "i686" system) | |
218 | (file-append ovmf "/share/firmware/ovmf_ia32.bin")) | |
219 | (else #f))) | |
220 | ||
b1bf155f LC |
221 | (define* (run-install target-os target-os-source |
222 | #:key | |
223 | (script %simple-installation-script) | |
ccb1a8c4 | 224 | (gui-test #f) |
a48a20fb | 225 | (packages '()) |
94b4274d | 226 | (os (marionette-operating-system |
94b4274d | 227 | (operating-system |
a48a20fb MO |
228 | ;; Since the image has no network access, use the |
229 | ;; current Guix so the store items we need are in | |
230 | ;; the image and add packages provided. | |
231 | (inherit (operating-system-add-packages | |
232 | (operating-system-with-current-guix | |
233 | installation-os) | |
234 | packages)) | |
94b4274d LC |
235 | (kernel-arguments '("console=ttyS0"))) |
236 | #:imported-modules '((gnu services herd) | |
ccb1a8c4 | 237 | (gnu installer tests) |
94b4274d | 238 | (guix combinators)))) |
95b3fc12 | 239 | (uefi-support? #f) |
c64adff4 | 240 | (installation-image-type 'efi-raw) |
b03ebdbc | 241 | (install-size 'guess) |
5724a14e | 242 | (target-size (* 2200 MiB))) |
59e80445 | 243 | "Run SCRIPT (a shell script following the system installation procedure) in |
b1bf155f | 244 | OS to install TARGET-OS. Return a VM image of TARGET-SIZE bytes containing |
a48a20fb MO |
245 | the installed system. The packages specified in PACKAGES will be appended to |
246 | packages defined in installation-os." | |
94b4274d LC |
247 | |
248 | (mlet* %store-monad ((_ (set-grafting #f)) | |
249 | (system (current-system)) | |
94b4274d | 250 | |
95b3fc12 MO |
251 | (uefi-firmware -> (and uefi-support? |
252 | (uefi-firmware system))) | |
94b4274d LC |
253 | ;; Since the installation system has no network access, |
254 | ;; we cheat a little bit by adding TARGET to its GC | |
255 | ;; roots. This way, we know 'guix system init' will | |
0e72d49e MB |
256 | ;; succeed. Also add guile-final, which is pulled in |
257 | ;; through provenance.drv and may not always be present. | |
7ca533c7 | 258 | (target (operating-system-derivation target-os)) |
10b135ce MO |
259 | (base-image -> |
260 | (os->image | |
261 | (operating-system-with-gc-roots | |
262 | os (list target guile-final)) | |
263 | #:type (lookup-image-type-by-name | |
264 | installation-image-type))) | |
e3f0155c | 265 | (image -> |
10b135ce MO |
266 | (system-image |
267 | (image | |
268 | (inherit base-image) | |
269 | (size install-size) | |
270 | ||
271 | ;; Don't provide substitutes; too big. | |
272 | (substitutable? #f))))) | |
94b4274d | 273 | (define install |
4ee96a79 LC |
274 | (with-imported-modules '((guix build utils) |
275 | (gnu build marionette)) | |
276 | #~(begin | |
277 | (use-modules (guix build utils) | |
278 | (gnu build marionette)) | |
279 | ||
280 | (set-path-environment-variable "PATH" '("bin") | |
281 | (list #$qemu-minimal)) | |
282 | ||
283 | (system* "qemu-img" "create" "-f" "qcow2" | |
284 | #$output #$(number->string target-size)) | |
285 | ||
286 | (define marionette | |
287 | (make-marionette | |
fbc7b1f1 CB |
288 | `(,(which #$(qemu-command system)) |
289 | "-no-reboot" | |
ae1a0f75 | 290 | "-m" "1200" |
95b3fc12 MO |
291 | ,@(if #$uefi-firmware |
292 | '("-bios" #$uefi-firmware) | |
293 | '()) | |
fbc7b1f1 | 294 | #$@(cond |
c64adff4 | 295 | ((eq? 'efi-raw installation-image-type) |
4e396041 LC |
296 | #~("-drive" |
297 | ,(string-append "file=" #$image | |
298 | ",if=virtio,readonly"))) | |
10b135ce | 299 | ((eq? 'uncompressed-iso9660 installation-image-type) |
4e396041 | 300 | #~("-cdrom" #$image)) |
fbc7b1f1 CB |
301 | (else |
302 | (error | |
10b135ce MO |
303 | "unsupported installation-image-type:" |
304 | installation-image-type))) | |
fbc7b1f1 CB |
305 | "-drive" |
306 | ,(string-append "file=" #$output ",if=virtio") | |
307 | ,@(if (file-exists? "/dev/kvm") | |
308 | '("-enable-kvm") | |
309 | '())))) | |
4ee96a79 LC |
310 | |
311 | (pk 'uname (marionette-eval '(uname) marionette)) | |
312 | ||
313 | ;; Wait for tty1. | |
314 | (marionette-eval '(begin | |
315 | (use-modules (gnu services herd)) | |
316 | (start 'term-tty1)) | |
317 | marionette) | |
318 | ||
ccb1a8c4 LC |
319 | (when #$(->bool script) |
320 | (marionette-eval '(call-with-output-file "/etc/target-config.scm" | |
321 | (lambda (port) | |
322 | (write '#$target-os-source port))) | |
323 | marionette) | |
be0a672c LC |
324 | |
325 | ;; Run SCRIPT. It typically invokes 'reboot' as a last step and | |
326 | ;; thus normally gets killed with SIGTERM by PID 1. | |
327 | (let ((status (marionette-eval '(system #$script) marionette))) | |
1da69145 MO |
328 | (exit (or (eof-object? status) |
329 | (equal? (status:term-sig status) SIGTERM) | |
be0a672c | 330 | (equal? (status:exit-val status) 0))))) |
ccb1a8c4 LC |
331 | |
332 | (when #$(->bool gui-test) | |
333 | (wait-for-unix-socket "/var/guix/installer-socket" | |
334 | marionette) | |
335 | (format #t "installer socket ready~%") | |
336 | (force-output) | |
337 | (exit #$(and gui-test | |
338 | (gui-test #~marionette))))))) | |
b1bf155f | 339 | |
9cfd889f LC |
340 | (gexp->derivation "installation" install |
341 | #:substitutable? #f))) ;too big | |
b1bf155f | 342 | |
95b3fc12 MO |
343 | (define* (qemu-command/writable-image image |
344 | #:key | |
345 | (uefi-support? #f) | |
346 | (memory-size 256)) | |
b1bf155f | 347 | "Return as a monadic value the command to run QEMU on a writable copy of |
1a034f04 | 348 | IMAGE, a disk image. The QEMU VM has access to MEMORY-SIZE MiB of RAM." |
95b3fc12 MO |
349 | (mlet* %store-monad ((system (current-system)) |
350 | (uefi-firmware -> (and uefi-support? | |
351 | (uefi-firmware system)))) | |
b1bf155f LC |
352 | (return #~(let ((image #$image)) |
353 | ;; First we need a writable copy of the image. | |
130079ae LC |
354 | (format #t "creating writable image from '~a'...~%" image) |
355 | (unless (zero? (system* #+(file-append qemu-minimal | |
356 | "/bin/qemu-img") | |
357 | "create" "-f" "qcow2" | |
358 | "-o" | |
359 | (string-append "backing_file=" image) | |
360 | "disk.img")) | |
361 | (error "failed to create writable QEMU image" image)) | |
362 | ||
b1bf155f LC |
363 | (chmod "disk.img" #o644) |
364 | `(,(string-append #$qemu-minimal "/bin/" | |
365 | #$(qemu-command system)) | |
366 | ,@(if (file-exists? "/dev/kvm") | |
367 | '("-enable-kvm") | |
368 | '()) | |
95b3fc12 MO |
369 | ,@(if #$uefi-firmware |
370 | '("-bios" #$uefi-firmware) | |
371 | '()) | |
b800b8da | 372 | "-no-reboot" "-m" #$(number->string memory-size) |
b1bf155f LC |
373 | "-drive" "file=disk.img,if=virtio"))))) |
374 | ||
b1bf155f LC |
375 | (define %test-installed-os |
376 | (system-test | |
377 | (name "installed-os") | |
378 | (description | |
379 | "Test basic functionality of an OS installed like one would do by hand. | |
380 | This test is expensive in terms of CPU and storage usage since we need to | |
381 | build (current-guix) and then store a couple of full system images.") | |
382 | (value | |
383 | (mlet* %store-monad ((image (run-install %minimal-os %minimal-os-source)) | |
384 | (command (qemu-command/writable-image image))) | |
385 | (run-basic-test %minimal-os command | |
386 | "installed-os"))))) | |
387 | ||
a48a20fb MO |
388 | (define %test-installed-extlinux-os |
389 | (system-test | |
390 | (name "installed-extlinux-os") | |
391 | (description | |
392 | "Test basic functionality of an OS booted with an extlinux bootloader. As | |
393 | per %test-installed-os, this test is expensive in terms of CPU and storage.") | |
394 | (value | |
395 | (mlet* %store-monad ((image (run-install %minimal-extlinux-os | |
396 | %minimal-extlinux-os-source | |
397 | #:packages | |
398 | (list syslinux) | |
399 | #:script | |
400 | %extlinux-gpt-installation-script)) | |
401 | (command (qemu-command/writable-image image))) | |
402 | (run-basic-test %minimal-extlinux-os command | |
403 | "installed-extlinux-os"))))) | |
404 | ||
b1bf155f | 405 | \f |
fbc7b1f1 CB |
406 | ;;; |
407 | ;;; Installation through an ISO image. | |
408 | ;;; | |
409 | ||
410 | (define-os-with-source (%minimal-os-on-vda %minimal-os-on-vda-source) | |
411 | ;; The OS we want to install. | |
412 | (use-modules (gnu) (gnu tests) (srfi srfi-1)) | |
413 | ||
414 | (operating-system | |
415 | (host-name "liberigilo") | |
416 | (timezone "Europe/Paris") | |
417 | (locale "en_US.UTF-8") | |
418 | ||
fdfdecdb TGR |
419 | (bootloader (bootloader-configuration |
420 | (bootloader grub-bootloader) | |
421 | (target "/dev/vda"))) | |
fbc7b1f1 CB |
422 | (kernel-arguments '("console=ttyS0")) |
423 | (file-systems (cons (file-system | |
9ceeca08 | 424 | (device (file-system-label "my-root")) |
fbc7b1f1 CB |
425 | (mount-point "/") |
426 | (type "ext4")) | |
427 | %base-file-systems)) | |
428 | (users (cons (user-account | |
429 | (name "alice") | |
430 | (comment "Bob's sister") | |
431 | (group "users") | |
cf848cc0 | 432 | (supplementary-groups '("wheel" "audio" "video"))) |
fbc7b1f1 CB |
433 | %base-user-accounts)) |
434 | (services (cons (service marionette-service-type | |
435 | (marionette-configuration | |
436 | (imported-modules '((gnu services herd) | |
c537d2bc | 437 | (guix build utils) |
fbc7b1f1 CB |
438 | (guix combinators))))) |
439 | %base-services)))) | |
440 | ||
441 | (define %simple-installation-script-for-/dev/vda | |
442 | ;; Shell script of a simple installation. | |
443 | "\ | |
444 | . /etc/profile | |
445 | set -e -x | |
446 | guix --version | |
447 | ||
448 | export GUIX_BUILD_OPTIONS=--no-grafts | |
449 | guix build isc-dhcp | |
450 | parted --script /dev/vda mklabel gpt \\ | |
451 | mkpart primary ext2 1M 3M \\ | |
5e766fe5 | 452 | mkpart primary ext2 3M 1.6G \\ |
fbc7b1f1 CB |
453 | set 1 boot on \\ |
454 | set 1 bios_grub on | |
455 | mkfs.ext4 -L my-root /dev/vda2 | |
456 | mount /dev/vda2 /mnt | |
457 | df -h /mnt | |
458 | herd start cow-store /mnt | |
459 | mkdir /mnt/etc | |
460 | cp /etc/target-config.scm /mnt/etc/config.scm | |
461 | guix system init /mnt/etc/config.scm /mnt --no-substitutes | |
462 | sync | |
463 | reboot\n") | |
464 | ||
465 | (define %test-iso-image-installer | |
466 | (system-test | |
467 | (name "iso-image-installer") | |
468 | (description | |
469 | "") | |
470 | (value | |
471 | (mlet* %store-monad ((image (run-install | |
472 | %minimal-os-on-vda | |
473 | %minimal-os-on-vda-source | |
474 | #:script | |
475 | %simple-installation-script-for-/dev/vda | |
10b135ce MO |
476 | #:installation-image-type |
477 | 'uncompressed-iso9660)) | |
fbc7b1f1 CB |
478 | (command (qemu-command/writable-image image))) |
479 | (run-basic-test %minimal-os-on-vda command name))))) | |
480 | ||
481 | \f | |
ae763b5b LC |
482 | ;;; |
483 | ;;; Separate /home. | |
484 | ;;; | |
485 | ||
486 | (define-os-with-source (%separate-home-os %separate-home-os-source) | |
487 | ;; The OS we want to install. | |
488 | (use-modules (gnu) (gnu tests) (srfi srfi-1)) | |
489 | ||
490 | (operating-system | |
491 | (host-name "liberigilo") | |
492 | (timezone "Europe/Paris") | |
493 | (locale "en_US.utf8") | |
494 | ||
fdfdecdb TGR |
495 | (bootloader (bootloader-configuration |
496 | (bootloader grub-bootloader) | |
497 | (target "/dev/vdb"))) | |
ae763b5b LC |
498 | (kernel-arguments '("console=ttyS0")) |
499 | (file-systems (cons* (file-system | |
9ceeca08 | 500 | (device (file-system-label "my-root")) |
ae763b5b LC |
501 | (mount-point "/") |
502 | (type "ext4")) | |
503 | (file-system | |
504 | (device "none") | |
ae763b5b LC |
505 | (mount-point "/home") |
506 | (type "tmpfs")) | |
507 | %base-file-systems)) | |
508 | (users (cons* (user-account | |
509 | (name "alice") | |
cf848cc0 | 510 | (group "users")) |
ae763b5b LC |
511 | (user-account |
512 | (name "charlie") | |
cf848cc0 | 513 | (group "users")) |
ae763b5b LC |
514 | %base-user-accounts)) |
515 | (services (cons (service marionette-service-type | |
516 | (marionette-configuration | |
517 | (imported-modules '((gnu services herd) | |
518 | (guix combinators))))) | |
519 | %base-services)))) | |
520 | ||
521 | (define %test-separate-home-os | |
522 | (system-test | |
523 | (name "separate-home-os") | |
524 | (description | |
525 | "Test basic functionality of an installed OS with a separate /home | |
526 | partition. In particular, home directories must be correctly created (see | |
527 | <https://bugs.gnu.org/21108>).") | |
528 | (value | |
529 | (mlet* %store-monad ((image (run-install %separate-home-os | |
530 | %separate-home-os-source | |
531 | #:script | |
532 | %simple-installation-script)) | |
533 | (command (qemu-command/writable-image image))) | |
534 | (run-basic-test %separate-home-os command "separate-home-os"))))) | |
535 | ||
536 | \f | |
5479aa2b LC |
537 | ;;; |
538 | ;;; Separate /gnu/store partition. | |
539 | ;;; | |
540 | ||
541 | (define-os-with-source (%separate-store-os %separate-store-os-source) | |
542 | ;; The OS we want to install. | |
543 | (use-modules (gnu) (gnu tests) (srfi srfi-1)) | |
544 | ||
545 | (operating-system | |
546 | (host-name "liberigilo") | |
547 | (timezone "Europe/Paris") | |
548 | (locale "en_US.UTF-8") | |
549 | ||
fdfdecdb TGR |
550 | (bootloader (bootloader-configuration |
551 | (bootloader grub-bootloader) | |
552 | (target "/dev/vdb"))) | |
5479aa2b LC |
553 | (kernel-arguments '("console=ttyS0")) |
554 | (file-systems (cons* (file-system | |
9ceeca08 | 555 | (device (file-system-label "root-fs")) |
5479aa2b LC |
556 | (mount-point "/") |
557 | (type "ext4")) | |
558 | (file-system | |
9ceeca08 | 559 | (device (file-system-label "store-fs")) |
5479aa2b | 560 | (mount-point "/gnu") |
38434419 | 561 | (type "ext4")) |
5479aa2b LC |
562 | %base-file-systems)) |
563 | (users %base-user-accounts) | |
564 | (services (cons (service marionette-service-type | |
565 | (marionette-configuration | |
566 | (imported-modules '((gnu services herd) | |
567 | (guix combinators))))) | |
568 | %base-services)))) | |
569 | ||
570 | (define %separate-store-installation-script | |
571 | ;; Installation with a separate /gnu partition. | |
572 | "\ | |
573 | . /etc/profile | |
574 | set -e -x | |
575 | guix --version | |
576 | ||
577 | export GUIX_BUILD_OPTIONS=--no-grafts | |
578 | guix build isc-dhcp | |
579 | parted --script /dev/vdb mklabel gpt \\ | |
580 | mkpart primary ext2 1M 3M \\ | |
307ec732 LC |
581 | mkpart primary ext2 3M 400M \\ |
582 | mkpart primary ext2 400M 2.1G \\ | |
5479aa2b LC |
583 | set 1 boot on \\ |
584 | set 1 bios_grub on | |
585 | mkfs.ext4 -L root-fs /dev/vdb2 | |
586 | mkfs.ext4 -L store-fs /dev/vdb3 | |
587 | mount /dev/vdb2 /mnt | |
588 | mkdir /mnt/gnu | |
589 | mount /dev/vdb3 /mnt/gnu | |
590 | df -h /mnt | |
307ec732 | 591 | df -h /mnt/gnu |
5479aa2b LC |
592 | herd start cow-store /mnt |
593 | mkdir /mnt/etc | |
594 | cp /etc/target-config.scm /mnt/etc/config.scm | |
595 | guix system init /mnt/etc/config.scm /mnt --no-substitutes | |
596 | sync | |
597 | reboot\n") | |
598 | ||
599 | (define %test-separate-store-os | |
600 | (system-test | |
601 | (name "separate-store-os") | |
602 | (description | |
603 | "Test basic functionality of an OS installed like one would do by hand, | |
604 | where /gnu lives on a separate partition.") | |
605 | (value | |
606 | (mlet* %store-monad ((image (run-install %separate-store-os | |
607 | %separate-store-os-source | |
608 | #:script | |
609 | %separate-store-installation-script)) | |
610 | (command (qemu-command/writable-image image))) | |
611 | (run-basic-test %separate-store-os command "separate-store-os"))))) | |
612 | ||
613 | \f | |
245cc5f5 LC |
614 | ;;; |
615 | ;;; RAID root device. | |
616 | ;;; | |
617 | ||
618 | (define-os-with-source (%raid-root-os %raid-root-os-source) | |
619 | ;; An OS whose root partition is a RAID partition. | |
620 | (use-modules (gnu) (gnu tests)) | |
621 | ||
622 | (operating-system | |
623 | (host-name "raidified") | |
624 | (timezone "Europe/Paris") | |
625 | (locale "en_US.utf8") | |
626 | ||
fdfdecdb TGR |
627 | (bootloader (bootloader-configuration |
628 | (bootloader grub-bootloader) | |
629 | (target "/dev/vdb"))) | |
245cc5f5 | 630 | (kernel-arguments '("console=ttyS0")) |
bc499b11 | 631 | |
3adf320e LC |
632 | ;; Add a kernel module for RAID-1 (aka. "mirror"). |
633 | (initrd-modules (cons "raid1" %base-initrd-modules)) | |
bc499b11 | 634 | |
245cc5f5 LC |
635 | (mapped-devices (list (mapped-device |
636 | (source (list "/dev/vda2" "/dev/vda3")) | |
637 | (target "/dev/md0") | |
638 | (type raid-device-mapping)))) | |
639 | (file-systems (cons (file-system | |
9ceeca08 | 640 | (device (file-system-label "root-fs")) |
245cc5f5 LC |
641 | (mount-point "/") |
642 | (type "ext4") | |
643 | (dependencies mapped-devices)) | |
644 | %base-file-systems)) | |
645 | (users %base-user-accounts) | |
646 | (services (cons (service marionette-service-type | |
647 | (marionette-configuration | |
648 | (imported-modules '((gnu services herd) | |
649 | (guix combinators))))) | |
650 | %base-services)))) | |
651 | ||
652 | (define %raid-root-installation-script | |
653 | ;; Installation with a separate /gnu partition. See | |
654 | ;; <https://raid.wiki.kernel.org/index.php/RAID_setup> for more on RAID and | |
655 | ;; mdadm. | |
656 | "\ | |
657 | . /etc/profile | |
658 | set -e -x | |
659 | guix --version | |
660 | ||
661 | export GUIX_BUILD_OPTIONS=--no-grafts | |
662 | parted --script /dev/vdb mklabel gpt \\ | |
663 | mkpart primary ext2 1M 3M \\ | |
5e766fe5 MO |
664 | mkpart primary ext2 3M 1.6G \\ |
665 | mkpart primary ext2 1.6G 3.2G \\ | |
245cc5f5 LC |
666 | set 1 boot on \\ |
667 | set 1 bios_grub on | |
3adf320e | 668 | yes | mdadm --create /dev/md0 --verbose --level=mirror --raid-devices=2 \\ |
245cc5f5 LC |
669 | /dev/vdb2 /dev/vdb3 |
670 | mkfs.ext4 -L root-fs /dev/md0 | |
671 | mount /dev/md0 /mnt | |
672 | df -h /mnt | |
673 | herd start cow-store /mnt | |
674 | mkdir /mnt/etc | |
675 | cp /etc/target-config.scm /mnt/etc/config.scm | |
676 | guix system init /mnt/etc/config.scm /mnt --no-substitutes | |
677 | sync | |
678 | reboot\n") | |
679 | ||
680 | (define %test-raid-root-os | |
681 | (system-test | |
682 | (name "raid-root-os") | |
683 | (description | |
684 | "Test functionality of an OS installed with a RAID root partition managed | |
685 | by 'mdadm'.") | |
686 | (value | |
687 | (mlet* %store-monad ((image (run-install %raid-root-os | |
688 | %raid-root-os-source | |
689 | #:script | |
690 | %raid-root-installation-script | |
5e766fe5 | 691 | #:target-size (* 3200 MiB))) |
245cc5f5 LC |
692 | (command (qemu-command/writable-image image))) |
693 | (run-basic-test %raid-root-os | |
694 | `(,@command) "raid-root-os"))))) | |
695 | ||
696 | \f | |
5479aa2b LC |
697 | ;;; |
698 | ;;; LUKS-encrypted root file system. | |
699 | ;;; | |
700 | ||
b1bf155f LC |
701 | (define-os-with-source (%encrypted-root-os %encrypted-root-os-source) |
702 | ;; The OS we want to install. | |
703 | (use-modules (gnu) (gnu tests) (srfi srfi-1)) | |
704 | ||
705 | (operating-system | |
706 | (host-name "liberigilo") | |
707 | (timezone "Europe/Paris") | |
708 | (locale "en_US.UTF-8") | |
709 | ||
fdfdecdb TGR |
710 | (bootloader (bootloader-configuration |
711 | (bootloader grub-bootloader) | |
712 | (target "/dev/vdb"))) | |
f7f292d3 LC |
713 | |
714 | ;; Note: Do not pass "console=ttyS0" so we can use our passphrase prompt | |
715 | ;; detection logic in 'enter-luks-passphrase'. | |
716 | ||
717 | (mapped-devices (list (mapped-device | |
718 | (source (uuid "12345678-1234-1234-1234-123456789abc")) | |
719 | (target "the-root-device") | |
720 | (type luks-device-mapping)))) | |
b1bf155f LC |
721 | (file-systems (cons (file-system |
722 | (device "/dev/mapper/the-root-device") | |
b1bf155f LC |
723 | (mount-point "/") |
724 | (type "ext4")) | |
725 | %base-file-systems)) | |
b1bf155f LC |
726 | (users (cons (user-account |
727 | (name "charlie") | |
728 | (group "users") | |
b1bf155f LC |
729 | (supplementary-groups '("wheel" "audio" "video"))) |
730 | %base-user-accounts)) | |
731 | (services (cons (service marionette-service-type | |
732 | (marionette-configuration | |
733 | (imported-modules '((gnu services herd) | |
734 | (guix combinators))))) | |
735 | %base-services)))) | |
736 | ||
43e282ac LC |
737 | (define %luks-passphrase |
738 | ;; LUKS encryption passphrase used in tests. | |
739 | "thepassphrase") | |
740 | ||
b1bf155f LC |
741 | (define %encrypted-root-installation-script |
742 | ;; Shell script of a simple installation. | |
43e282ac | 743 | (string-append "\ |
94b4274d | 744 | . /etc/profile |
b1bf155f | 745 | set -e -x |
94b4274d | 746 | guix --version |
94b4274d LC |
747 | |
748 | export GUIX_BUILD_OPTIONS=--no-grafts | |
b1bf155f | 749 | ls -l /run/current-system/gc-roots |
94b4274d LC |
750 | parted --script /dev/vdb mklabel gpt \\ |
751 | mkpart primary ext2 1M 3M \\ | |
5e766fe5 | 752 | mkpart primary ext2 3M 1.6G \\ |
94b4274d LC |
753 | set 1 boot on \\ |
754 | set 1 bios_grub on | |
43e282ac | 755 | echo -n " %luks-passphrase " | \\ |
f7f292d3 | 756 | cryptsetup luksFormat --uuid=12345678-1234-1234-1234-123456789abc -q /dev/vdb2 - |
43e282ac | 757 | echo -n " %luks-passphrase " | \\ |
b1bf155f LC |
758 | cryptsetup open --type luks --key-file - /dev/vdb2 the-root-device |
759 | mkfs.ext4 -L my-root /dev/mapper/the-root-device | |
760 | mount LABEL=my-root /mnt | |
94b4274d LC |
761 | herd start cow-store /mnt |
762 | mkdir /mnt/etc | |
b1bf155f | 763 | cp /etc/target-config.scm /mnt/etc/config.scm |
b1bf155f | 764 | guix system build /mnt/etc/config.scm |
94b4274d LC |
765 | guix system init /mnt/etc/config.scm /mnt --no-substitutes |
766 | sync | |
43e282ac | 767 | reboot\n")) |
94b4274d | 768 | |
f7f292d3 LC |
769 | (define (enter-luks-passphrase marionette) |
770 | "Return a gexp to be inserted in the basic system test running on MARIONETTE | |
771 | to enter the LUKS passphrase." | |
772 | (let ((ocrad (file-append ocrad "/bin/ocrad"))) | |
773 | #~(begin | |
774 | (define (passphrase-prompt? text) | |
775 | (string-contains (pk 'screen-text text) "Enter pass")) | |
776 | ||
777 | (define (bios-boot-screen? text) | |
778 | ;; Return true if TEXT corresponds to the boot screen, before GRUB's | |
779 | ;; menu. | |
780 | (string-prefix? "SeaBIOS" text)) | |
781 | ||
782 | (test-assert "enter LUKS passphrase for GRUB" | |
783 | (begin | |
784 | ;; At this point we have no choice but to use OCR to determine | |
785 | ;; when the passphrase should be entered. | |
786 | (wait-for-screen-text #$marionette passphrase-prompt? | |
787 | #:ocrad #$ocrad) | |
43e282ac LC |
788 | (marionette-type #$(string-append %luks-passphrase "\n") |
789 | #$marionette) | |
f7f292d3 LC |
790 | |
791 | ;; Now wait until we leave the boot screen. This is necessary so | |
792 | ;; we can then be sure we match the "Enter passphrase" prompt from | |
793 | ;; 'cryptsetup', in the initrd. | |
794 | (wait-for-screen-text #$marionette (negate bios-boot-screen?) | |
795 | #:ocrad #$ocrad | |
796 | #:timeout 20))) | |
797 | ||
798 | (test-assert "enter LUKS passphrase for the initrd" | |
799 | (begin | |
800 | ;; XXX: Here we use OCR as well but we could instead use QEMU | |
801 | ;; '-serial stdio' and run it in an input pipe, | |
802 | (wait-for-screen-text #$marionette passphrase-prompt? | |
803 | #:ocrad #$ocrad | |
804 | #:timeout 60) | |
43e282ac LC |
805 | (marionette-type #$(string-append %luks-passphrase "\n") |
806 | #$marionette) | |
f7f292d3 LC |
807 | |
808 | ;; Take a screenshot for debugging purposes. | |
809 | (marionette-control (string-append "screendump " #$output | |
810 | "/post-initrd-passphrase.ppm") | |
811 | #$marionette)))))) | |
812 | ||
4f83afd2 | 813 | (define %test-encrypted-root-os |
98b65b5f | 814 | (system-test |
b1bf155f | 815 | (name "encrypted-root-os") |
98b65b5f LC |
816 | (description |
817 | "Test basic functionality of an OS installed like one would do by hand. | |
818 | This test is expensive in terms of CPU and storage usage since we need to | |
819 | build (current-guix) and then store a couple of full system images.") | |
820 | (value | |
b1bf155f LC |
821 | (mlet* %store-monad ((image (run-install %encrypted-root-os |
822 | %encrypted-root-os-source | |
823 | #:script | |
824 | %encrypted-root-installation-script)) | |
825 | (command (qemu-command/writable-image image))) | |
f7f292d3 LC |
826 | (run-basic-test %encrypted-root-os command "encrypted-root-os" |
827 | #:initialization enter-luks-passphrase))))) | |
94b4274d | 828 | |
b1a505ba | 829 | \f |
a9a2fdaa MT |
830 | ;;; |
831 | ;;; Separate /home on LVM | |
832 | ;;; | |
833 | ||
834 | ;; Since LVM support in guix currently doesn't allow root-on-LVM we use /home on LVM | |
835 | (define-os-with-source (%lvm-separate-home-os %lvm-separate-home-os-source) | |
836 | (use-modules (gnu) (gnu tests)) | |
837 | ||
838 | (operating-system | |
839 | (host-name "separate-home-on-lvm") | |
840 | (timezone "Europe/Paris") | |
841 | (locale "en_US.utf8") | |
842 | ||
843 | (bootloader (bootloader-configuration | |
844 | (bootloader grub-bootloader) | |
845 | (target "/dev/vdb"))) | |
846 | (kernel-arguments '("console=ttyS0")) | |
847 | ||
848 | (mapped-devices (list (mapped-device | |
849 | (source "vg0") | |
850 | (target "vg0-home") | |
851 | (type lvm-device-mapping)))) | |
852 | (file-systems (cons* (file-system | |
853 | (device (file-system-label "root-fs")) | |
854 | (mount-point "/") | |
855 | (type "ext4")) | |
856 | (file-system | |
857 | (device "/dev/mapper/vg0-home") | |
858 | (mount-point "/home") | |
859 | (type "ext4") | |
860 | (dependencies mapped-devices)) | |
861 | %base-file-systems)) | |
862 | (users %base-user-accounts) | |
863 | (services (cons (service marionette-service-type | |
864 | (marionette-configuration | |
865 | (imported-modules '((gnu services herd) | |
866 | (guix combinators))))) | |
867 | %base-services)))) | |
868 | ||
869 | (define %lvm-separate-home-installation-script | |
870 | "\ | |
871 | . /etc/profile | |
872 | set -e -x | |
873 | guix --version | |
874 | ||
875 | export GUIX_BUILD_OPTIONS=--no-grafts | |
876 | parted --script /dev/vdb mklabel gpt \\ | |
877 | mkpart primary ext2 1M 3M \\ | |
878 | mkpart primary ext2 3M 1.6G \\ | |
879 | mkpart primary 1.6G 3.2G \\ | |
880 | set 1 boot on \\ | |
881 | set 1 bios_grub on | |
882 | pvcreate /dev/vdb3 | |
883 | vgcreate vg0 /dev/vdb3 | |
884 | lvcreate -L 1.6G -n home vg0 | |
885 | vgchange -ay | |
886 | mkfs.ext4 -L root-fs /dev/vdb2 | |
887 | mkfs.ext4 /dev/mapper/vg0-home | |
888 | mount /dev/vdb2 /mnt | |
889 | mkdir /mnt/home | |
890 | mount /dev/mapper/vg0-home /mnt/home | |
891 | df -h /mnt /mnt/home | |
892 | herd start cow-store /mnt | |
893 | mkdir /mnt/etc | |
894 | cp /etc/target-config.scm /mnt/etc/config.scm | |
895 | guix system init /mnt/etc/config.scm /mnt --no-substitutes | |
896 | sync | |
897 | reboot\n") | |
898 | ||
899 | (define %test-lvm-separate-home-os | |
900 | (system-test | |
901 | (name "lvm-separate-home-os") | |
902 | (description | |
903 | "Test functionality of an OS installed with a LVM /home partition") | |
904 | (value | |
905 | (mlet* %store-monad ((image (run-install %lvm-separate-home-os | |
906 | %lvm-separate-home-os-source | |
907 | #:script | |
908 | %lvm-separate-home-installation-script | |
909 | #:packages (list lvm2-static) | |
910 | #:target-size (* 3200 MiB))) | |
911 | (command (qemu-command/writable-image image))) | |
912 | (run-basic-test %lvm-separate-home-os | |
913 | `(,@command) "lvm-separate-home-os"))))) | |
914 | ||
915 | \f | |
f00e68ac MÁAV |
916 | ;;; |
917 | ;;; LUKS-encrypted root file system and /boot in a non-encrypted partition. | |
918 | ;;; | |
919 | ||
920 | (define-os-with-source (%encrypted-root-not-boot-os | |
921 | %encrypted-root-not-boot-os-source) | |
922 | ;; The OS we want to install. | |
923 | (use-modules (gnu) (gnu tests) (srfi srfi-1)) | |
924 | ||
925 | (operating-system | |
926 | (host-name "bootroot") | |
927 | (timezone "Europe/Madrid") | |
928 | (locale "en_US.UTF-8") | |
929 | ||
930 | (bootloader (bootloader-configuration | |
931 | (bootloader grub-bootloader) | |
932 | (target "/dev/vdb"))) | |
933 | ||
934 | (mapped-devices (list (mapped-device | |
935 | (source | |
936 | (uuid "12345678-1234-1234-1234-123456789abc")) | |
937 | (target "root") | |
938 | (type luks-device-mapping)))) | |
939 | (file-systems (cons* (file-system | |
940 | (device (file-system-label "my-boot")) | |
941 | (mount-point "/boot") | |
942 | (type "ext4")) | |
943 | (file-system | |
944 | (device "/dev/mapper/root") | |
945 | (mount-point "/") | |
946 | (type "ext4")) | |
947 | %base-file-systems)) | |
948 | (users (cons (user-account | |
949 | (name "alice") | |
950 | (group "users") | |
951 | (supplementary-groups '("wheel" "audio" "video"))) | |
952 | %base-user-accounts)) | |
953 | (services (cons (service marionette-service-type | |
954 | (marionette-configuration | |
955 | (imported-modules '((gnu services herd) | |
956 | (guix combinators))))) | |
957 | %base-services)))) | |
958 | ||
959 | (define %encrypted-root-not-boot-installation-script | |
960 | ;; Shell script for an installation with boot not encrypted but root | |
961 | ;; encrypted. | |
962 | (format #f "\ | |
963 | . /etc/profile | |
964 | set -e -x | |
965 | guix --version | |
966 | ||
967 | export GUIX_BUILD_OPTIONS=--no-grafts | |
968 | ls -l /run/current-system/gc-roots | |
969 | parted --script /dev/vdb mklabel gpt \\ | |
970 | mkpart primary ext2 1M 3M \\ | |
971 | mkpart primary ext2 3M 50M \\ | |
972 | mkpart primary ext2 50M 1.6G \\ | |
973 | set 1 boot on \\ | |
974 | set 1 bios_grub on | |
975 | echo -n \"~a\" | cryptsetup luksFormat --uuid=\"~a\" -q /dev/vdb3 - | |
976 | echo -n \"~a\" | cryptsetup open --type luks --key-file - /dev/vdb3 root | |
977 | mkfs.ext4 -L my-root /dev/mapper/root | |
978 | mkfs.ext4 -L my-boot /dev/vdb2 | |
979 | mount LABEL=my-root /mnt | |
980 | mkdir /mnt/boot | |
981 | mount LABEL=my-boot /mnt/boot | |
982 | echo \"Checking mounts\" | |
983 | mount | |
984 | herd start cow-store /mnt | |
985 | mkdir /mnt/etc | |
986 | cp /etc/target-config.scm /mnt/etc/config.scm | |
987 | guix system build /mnt/etc/config.scm | |
988 | guix system init /mnt/etc/config.scm /mnt --no-substitutes | |
989 | sync | |
990 | echo \"Debugging info\" | |
991 | blkid | |
992 | cat /mnt/boot/grub/grub.cfg | |
993 | reboot\n" | |
994 | %luks-passphrase "12345678-1234-1234-1234-123456789abc" | |
995 | %luks-passphrase)) | |
996 | ||
997 | (define %test-encrypted-root-not-boot-os | |
998 | (system-test | |
999 | (name "encrypted-root-not-boot-os") | |
1000 | (description | |
1001 | "Test the manual installation on an OS with / in an encrypted partition | |
1002 | but /boot on a different, non-encrypted partition. This test is expensive in | |
1003 | terms of CPU and storage usage since we need to build (current-guix) and then | |
1004 | store a couple of full system images.") | |
1005 | (value | |
1006 | (mlet* %store-monad | |
1007 | ((image (run-install %encrypted-root-not-boot-os | |
1008 | %encrypted-root-not-boot-os-source | |
1009 | #:script | |
1010 | %encrypted-root-not-boot-installation-script)) | |
1011 | (command (qemu-command/writable-image image))) | |
1012 | (run-basic-test %encrypted-root-not-boot-os command | |
1013 | "encrypted-root-not-boot-os" | |
1014 | #:initialization enter-luks-passphrase))))) | |
1015 | ||
1016 | \f | |
b1a505ba DC |
1017 | ;;; |
1018 | ;;; Btrfs root file system. | |
1019 | ;;; | |
1020 | ||
1021 | (define-os-with-source (%btrfs-root-os %btrfs-root-os-source) | |
1022 | ;; The OS we want to install. | |
1023 | (use-modules (gnu) (gnu tests) (srfi srfi-1)) | |
1024 | ||
1025 | (operating-system | |
1026 | (host-name "liberigilo") | |
1027 | (timezone "Europe/Paris") | |
1028 | (locale "en_US.UTF-8") | |
1029 | ||
fdfdecdb TGR |
1030 | (bootloader (bootloader-configuration |
1031 | (bootloader grub-bootloader) | |
1032 | (target "/dev/vdb"))) | |
b1a505ba DC |
1033 | (kernel-arguments '("console=ttyS0")) |
1034 | (file-systems (cons (file-system | |
9ceeca08 | 1035 | (device (file-system-label "my-root")) |
b1a505ba DC |
1036 | (mount-point "/") |
1037 | (type "btrfs")) | |
1038 | %base-file-systems)) | |
1039 | (users (cons (user-account | |
1040 | (name "charlie") | |
1041 | (group "users") | |
b1a505ba DC |
1042 | (supplementary-groups '("wheel" "audio" "video"))) |
1043 | %base-user-accounts)) | |
1044 | (services (cons (service marionette-service-type | |
1045 | (marionette-configuration | |
1046 | (imported-modules '((gnu services herd) | |
1047 | (guix combinators))))) | |
1048 | %base-services)))) | |
1049 | ||
1050 | (define %btrfs-root-installation-script | |
1051 | ;; Shell script of a simple installation. | |
1052 | "\ | |
1053 | . /etc/profile | |
1054 | set -e -x | |
1055 | guix --version | |
1056 | ||
1057 | export GUIX_BUILD_OPTIONS=--no-grafts | |
1058 | ls -l /run/current-system/gc-roots | |
1059 | parted --script /dev/vdb mklabel gpt \\ | |
1060 | mkpart primary ext2 1M 3M \\ | |
5724a14e | 1061 | mkpart primary ext2 3M 2G \\ |
b1a505ba DC |
1062 | set 1 boot on \\ |
1063 | set 1 bios_grub on | |
1064 | mkfs.btrfs -L my-root /dev/vdb2 | |
1065 | mount /dev/vdb2 /mnt | |
1066 | btrfs subvolume create /mnt/home | |
1067 | herd start cow-store /mnt | |
1068 | mkdir /mnt/etc | |
1069 | cp /etc/target-config.scm /mnt/etc/config.scm | |
1070 | guix system build /mnt/etc/config.scm | |
1071 | guix system init /mnt/etc/config.scm /mnt --no-substitutes | |
1072 | sync | |
1073 | reboot\n") | |
1074 | ||
1075 | (define %test-btrfs-root-os | |
1076 | (system-test | |
1077 | (name "btrfs-root-os") | |
1078 | (description | |
1079 | "Test basic functionality of an OS installed like one would do by hand. | |
1080 | This test is expensive in terms of CPU and storage usage since we need to | |
1081 | build (current-guix) and then store a couple of full system images.") | |
1082 | (value | |
1083 | (mlet* %store-monad ((image (run-install %btrfs-root-os | |
1084 | %btrfs-root-os-source | |
1085 | #:script | |
1086 | %btrfs-root-installation-script)) | |
1087 | (command (qemu-command/writable-image image))) | |
1088 | (run-basic-test %btrfs-root-os command "btrfs-root-os"))))) | |
1089 | ||
886302fc MC |
1090 | |
1091 | \f | |
1092 | ;;; | |
1093 | ;;; Btrfs RAID-0 root file system. | |
1094 | ;;; | |
1095 | (define-os-with-source (%btrfs-raid-root-os %btrfs-raid-root-os-source) | |
1096 | ;; An OS whose root partition is a RAID partition. | |
1097 | (use-modules (gnu) (gnu tests)) | |
1098 | ||
1099 | (operating-system | |
1100 | (host-name "liberigilo") | |
1101 | (timezone "Europe/Paris") | |
1102 | (locale "en_US.utf8") | |
1103 | ||
1104 | (bootloader (bootloader-configuration | |
1105 | (bootloader grub-bootloader) | |
1106 | (target "/dev/vdb"))) | |
1107 | (kernel-arguments '("console=ttyS0")) | |
1108 | ||
1109 | (file-systems (cons (file-system | |
1110 | (device (file-system-label "root-fs")) | |
1111 | (mount-point "/") | |
1112 | (type "btrfs")) | |
1113 | %base-file-systems)) | |
1114 | (users %base-user-accounts) | |
1115 | (services (cons (service marionette-service-type | |
1116 | (marionette-configuration | |
1117 | (imported-modules '((gnu services herd) | |
1118 | (guix combinators))))) | |
1119 | %base-services)))) | |
1120 | ||
1121 | (define %btrfs-raid-root-installation-script | |
1122 | "\ | |
1123 | . /etc/profile | |
1124 | set -e -x | |
1125 | guix --version | |
1126 | ||
1127 | export GUIX_BUILD_OPTIONS=--no-grafts | |
1128 | parted --script /dev/vdb mklabel gpt \\ | |
1129 | mkpart primary ext2 1M 3M \\ | |
1130 | mkpart primary ext2 3M 1.4G \\ | |
1131 | mkpart primary ext2 1.4G 2.8G \\ | |
1132 | set 1 boot on \\ | |
1133 | set 1 bios_grub on | |
1134 | mkfs.btrfs -L root-fs -d raid0 -m raid0 /dev/vdb2 /dev/vdb3 | |
1135 | mount /dev/vdb2 /mnt | |
1136 | df -h /mnt | |
1137 | herd start cow-store /mnt | |
1138 | mkdir /mnt/etc | |
1139 | cp /etc/target-config.scm /mnt/etc/config.scm | |
1140 | guix system init /mnt/etc/config.scm /mnt --no-substitutes | |
1141 | sync | |
1142 | reboot\n") | |
1143 | ||
1144 | (define %test-btrfs-raid-root-os | |
1145 | (system-test | |
1146 | (name "btrfs-raid-root-os") | |
1147 | (description "Test functionality of an OS installed with a Btrfs | |
1148 | RAID-0 (stripe) root partition.") | |
1149 | (value | |
1150 | (mlet* %store-monad | |
1151 | ((image (run-install %btrfs-raid-root-os | |
1152 | %btrfs-raid-root-os-source | |
1153 | #:script %btrfs-raid-root-installation-script | |
1154 | #:target-size (* 2800 MiB))) | |
1155 | (command (qemu-command/writable-image image))) | |
1156 | (run-basic-test %btrfs-raid-root-os `(,@command) "btrfs-raid-root-os"))))) | |
1157 | ||
4f51fdba | 1158 | \f |
b460ba79 MC |
1159 | ;;; |
1160 | ;;; Btrfs root file system on a subvolume. | |
1161 | ;;; | |
1162 | ||
1163 | (define-os-with-source (%btrfs-root-on-subvolume-os | |
1164 | %btrfs-root-on-subvolume-os-source) | |
1165 | ;; The OS we want to install. | |
1166 | (use-modules (gnu) (gnu tests) (srfi srfi-1)) | |
1167 | ||
1168 | (operating-system | |
1169 | (host-name "hurd") | |
1170 | (timezone "America/Montreal") | |
1171 | (locale "en_US.UTF-8") | |
1172 | (bootloader (bootloader-configuration | |
1173 | (bootloader grub-bootloader) | |
1174 | (target "/dev/vdb"))) | |
1175 | (kernel-arguments '("console=ttyS0")) | |
1176 | (file-systems (cons* (file-system | |
1177 | (device (file-system-label "btrfs-pool")) | |
1178 | (mount-point "/") | |
1179 | (options "subvol=rootfs,compress=zstd") | |
1180 | (type "btrfs")) | |
1181 | (file-system | |
1182 | (device (file-system-label "btrfs-pool")) | |
1183 | (mount-point "/home") | |
1184 | (options "subvol=homefs,compress=lzo") | |
1185 | (type "btrfs")) | |
1186 | %base-file-systems)) | |
1187 | (users (cons (user-account | |
1188 | (name "charlie") | |
1189 | (group "users") | |
1190 | (supplementary-groups '("wheel" "audio" "video"))) | |
1191 | %base-user-accounts)) | |
1192 | (services (cons (service marionette-service-type | |
1193 | (marionette-configuration | |
1194 | (imported-modules '((gnu services herd) | |
1195 | (guix combinators))))) | |
1196 | %base-services)))) | |
1197 | ||
1198 | (define %btrfs-root-on-subvolume-installation-script | |
1199 | ;; Shell script of a simple installation. | |
1200 | "\ | |
1201 | . /etc/profile | |
1202 | set -e -x | |
1203 | guix --version | |
1204 | ||
1205 | export GUIX_BUILD_OPTIONS=--no-grafts | |
1206 | ls -l /run/current-system/gc-roots | |
1207 | parted --script /dev/vdb mklabel gpt \\ | |
1208 | mkpart primary ext2 1M 3M \\ | |
1209 | mkpart primary ext2 3M 2G \\ | |
1210 | set 1 boot on \\ | |
1211 | set 1 bios_grub on | |
1212 | ||
1213 | # Setup the top level Btrfs file system with its subvolume. | |
1214 | mkfs.btrfs -L btrfs-pool /dev/vdb2 | |
1215 | mount /dev/vdb2 /mnt | |
1216 | btrfs subvolume create /mnt/rootfs | |
1217 | btrfs subvolume create /mnt/homefs | |
1218 | umount /dev/vdb2 | |
1219 | ||
1220 | # Mount the subvolumes, ready for installation. | |
1221 | mount LABEL=btrfs-pool -o 'subvol=rootfs,compress=zstd' /mnt | |
1222 | mkdir /mnt/home | |
1223 | mount LABEL=btrfs-pool -o 'subvol=homefs,compress=zstd' /mnt/home | |
1224 | ||
1225 | herd start cow-store /mnt | |
1226 | mkdir /mnt/etc | |
1227 | cp /etc/target-config.scm /mnt/etc/config.scm | |
1228 | guix system build /mnt/etc/config.scm | |
1229 | guix system init /mnt/etc/config.scm /mnt --no-substitutes | |
1230 | sync | |
1231 | reboot\n") | |
1232 | ||
1233 | (define %test-btrfs-root-on-subvolume-os | |
1234 | (system-test | |
1235 | (name "btrfs-root-on-subvolume-os") | |
1236 | (description | |
1237 | "Test basic functionality of an OS installed like one would do by hand. | |
1238 | This test is expensive in terms of CPU and storage usage since we need to | |
1239 | build (current-guix) and then store a couple of full system images.") | |
1240 | (value | |
1241 | (mlet* %store-monad | |
1242 | ((image | |
1243 | (run-install %btrfs-root-on-subvolume-os | |
1244 | %btrfs-root-on-subvolume-os-source | |
1245 | #:script | |
1246 | %btrfs-root-on-subvolume-installation-script)) | |
1247 | (command (qemu-command/writable-image image))) | |
1248 | (run-basic-test %btrfs-root-on-subvolume-os command | |
1249 | "btrfs-root-on-subvolume-os"))))) | |
1250 | ||
1251 | \f | |
4f51fdba TGR |
1252 | ;;; |
1253 | ;;; JFS root file system. | |
1254 | ;;; | |
1255 | ||
1256 | (define-os-with-source (%jfs-root-os %jfs-root-os-source) | |
1257 | ;; The OS we want to install. | |
1258 | (use-modules (gnu) (gnu tests) (srfi srfi-1)) | |
1259 | ||
1260 | (operating-system | |
1261 | (host-name "liberigilo") | |
1262 | (timezone "Europe/Paris") | |
1263 | (locale "en_US.UTF-8") | |
1264 | ||
1265 | (bootloader (bootloader-configuration | |
1266 | (bootloader grub-bootloader) | |
1267 | (target "/dev/vdb"))) | |
1268 | (kernel-arguments '("console=ttyS0")) | |
1269 | (file-systems (cons (file-system | |
1270 | (device (file-system-label "my-root")) | |
1271 | (mount-point "/") | |
1272 | (type "jfs")) | |
1273 | %base-file-systems)) | |
1274 | (users (cons (user-account | |
1275 | (name "charlie") | |
1276 | (group "users") | |
1277 | (supplementary-groups '("wheel" "audio" "video"))) | |
1278 | %base-user-accounts)) | |
1279 | (services (cons (service marionette-service-type | |
1280 | (marionette-configuration | |
1281 | (imported-modules '((gnu services herd) | |
1282 | (guix combinators))))) | |
1283 | %base-services)))) | |
1284 | ||
1285 | (define %jfs-root-installation-script | |
1286 | ;; Shell script of a simple installation. | |
1287 | "\ | |
1288 | . /etc/profile | |
1289 | set -e -x | |
1290 | guix --version | |
1291 | ||
1292 | export GUIX_BUILD_OPTIONS=--no-grafts | |
1293 | ls -l /run/current-system/gc-roots | |
1294 | parted --script /dev/vdb mklabel gpt \\ | |
1295 | mkpart primary ext2 1M 3M \\ | |
1296 | mkpart primary ext2 3M 2G \\ | |
1297 | set 1 boot on \\ | |
1298 | set 1 bios_grub on | |
1299 | jfs_mkfs -L my-root -q /dev/vdb2 | |
1300 | mount /dev/vdb2 /mnt | |
1301 | herd start cow-store /mnt | |
1302 | mkdir /mnt/etc | |
1303 | cp /etc/target-config.scm /mnt/etc/config.scm | |
1304 | guix system build /mnt/etc/config.scm | |
1305 | guix system init /mnt/etc/config.scm /mnt --no-substitutes | |
1306 | sync | |
1307 | reboot\n") | |
1308 | ||
1309 | (define %test-jfs-root-os | |
1310 | (system-test | |
1311 | (name "jfs-root-os") | |
1312 | (description | |
1313 | "Test basic functionality of an OS installed like one would do by hand. | |
1314 | This test is expensive in terms of CPU and storage usage since we need to | |
1315 | build (current-guix) and then store a couple of full system images.") | |
1316 | (value | |
1317 | (mlet* %store-monad ((image (run-install %jfs-root-os | |
1318 | %jfs-root-os-source | |
1319 | #:script | |
1320 | %jfs-root-installation-script)) | |
1321 | (command (qemu-command/writable-image image))) | |
1322 | (run-basic-test %jfs-root-os command "jfs-root-os"))))) | |
1323 | ||
ccb1a8c4 | 1324 | \f |
af7a8e71 DM |
1325 | ;;; |
1326 | ;;; F2FS root file system. | |
1327 | ;;; | |
1328 | ||
1329 | (define-os-with-source (%f2fs-root-os %f2fs-root-os-source) | |
1330 | ;; The OS we want to install. | |
1331 | (use-modules (gnu) (gnu tests) (srfi srfi-1)) | |
1332 | ||
1333 | (operating-system | |
1334 | (host-name "liberigilo") | |
1335 | (timezone "Europe/Paris") | |
1336 | (locale "en_US.UTF-8") | |
1337 | ||
1338 | (bootloader (bootloader-configuration | |
1339 | (bootloader grub-bootloader) | |
1340 | (target "/dev/vdb"))) | |
1341 | (kernel-arguments '("console=ttyS0")) | |
1342 | (file-systems (cons (file-system | |
1343 | (device (file-system-label "my-root")) | |
1344 | (mount-point "/") | |
1345 | (type "f2fs")) | |
1346 | %base-file-systems)) | |
1347 | (users (cons (user-account | |
1348 | (name "charlie") | |
1349 | (group "users") | |
1350 | (supplementary-groups '("wheel" "audio" "video"))) | |
1351 | %base-user-accounts)) | |
1352 | (services (cons (service marionette-service-type | |
1353 | (marionette-configuration | |
1354 | (imported-modules '((gnu services herd) | |
1355 | (guix combinators))))) | |
1356 | %base-services)))) | |
1357 | ||
1358 | (define %f2fs-root-installation-script | |
1359 | ;; Shell script of a simple installation. | |
1360 | "\ | |
1361 | . /etc/profile | |
1362 | set -e -x | |
1363 | guix --version | |
1364 | ||
1365 | export GUIX_BUILD_OPTIONS=--no-grafts | |
1366 | ls -l /run/current-system/gc-roots | |
1367 | parted --script /dev/vdb mklabel gpt \\ | |
1368 | mkpart primary ext2 1M 3M \\ | |
1369 | mkpart primary ext2 3M 2G \\ | |
1370 | set 1 boot on \\ | |
1371 | set 1 bios_grub on | |
1372 | mkfs.f2fs -l my-root -q /dev/vdb2 | |
1373 | mount /dev/vdb2 /mnt | |
1374 | herd start cow-store /mnt | |
1375 | mkdir /mnt/etc | |
1376 | cp /etc/target-config.scm /mnt/etc/config.scm | |
1377 | guix system build /mnt/etc/config.scm | |
1378 | guix system init /mnt/etc/config.scm /mnt --no-substitutes | |
1379 | sync | |
1380 | reboot\n") | |
1381 | ||
1382 | (define %test-f2fs-root-os | |
1383 | (system-test | |
1384 | (name "f2fs-root-os") | |
1385 | (description | |
1386 | "Test basic functionality of an OS installed like one would do by hand. | |
1387 | This test is expensive in terms of CPU and storage usage since we need to | |
1388 | build (current-guix) and then store a couple of full system images.") | |
1389 | (value | |
1390 | (mlet* %store-monad ((image (run-install %f2fs-root-os | |
1391 | %f2fs-root-os-source | |
1392 | #:script | |
1393 | %f2fs-root-installation-script)) | |
1394 | (command (qemu-command/writable-image image))) | |
1395 | (run-basic-test %f2fs-root-os command "f2fs-root-os"))))) | |
1396 | ||
1397 | \f | |
ccb1a8c4 LC |
1398 | ;;; |
1399 | ;;; Installation through the graphical interface. | |
1400 | ;;; | |
1401 | ||
1402 | (define %syslog-conf | |
1403 | ;; Syslog configuration that dumps to /dev/console, so we can see the | |
1404 | ;; installer's messages during the test. | |
1405 | (computed-file "syslog.conf" | |
1406 | #~(begin | |
1407 | (copy-file #$%default-syslog.conf #$output) | |
1408 | (chmod #$output #o644) | |
1409 | (let ((port (open-file #$output "a"))) | |
1410 | (display "\n*.info /dev/console\n" port) | |
1411 | #t)))) | |
1412 | ||
1413 | (define (operating-system-with-console-syslog os) | |
1414 | "Return OS with a syslog service that writes to /dev/console." | |
1415 | (operating-system | |
1416 | (inherit os) | |
1417 | (services (modify-services (operating-system-user-services os) | |
1418 | (syslog-service-type config | |
1419 | => | |
1420 | (syslog-configuration | |
1421 | (inherit config) | |
1422 | (config-file %syslog-conf))))))) | |
1423 | ||
1424 | (define %root-password "foo") | |
1425 | ||
b03ebdbc MO |
1426 | (define* (gui-test-program marionette |
1427 | #:key | |
1428 | (desktop? #f) | |
95b3fc12 MO |
1429 | (encrypted? #f) |
1430 | (uefi-support? #f) | |
1431 | (system (%current-system))) | |
ccb1a8c4 LC |
1432 | #~(let () |
1433 | (define (screenshot file) | |
1434 | (marionette-control (string-append "screendump " file) | |
1435 | #$marionette)) | |
1436 | ||
1550db6f MO |
1437 | (define-syntax-rule (marionette-eval* exp marionette) |
1438 | (or (marionette-eval exp marionette) | |
1439 | (throw 'marionette-eval-failure 'exp))) | |
1440 | ||
ccb1a8c4 LC |
1441 | (setvbuf (current-output-port) 'none) |
1442 | (setvbuf (current-error-port) 'none) | |
1443 | ||
1550db6f MO |
1444 | (marionette-eval* '(use-modules (gnu installer tests)) |
1445 | #$marionette) | |
ccb1a8c4 LC |
1446 | |
1447 | ;; Arrange so that 'converse' prints debugging output to the console. | |
1550db6f MO |
1448 | (marionette-eval* '(let ((console (open-output-file "/dev/console"))) |
1449 | (setvbuf console 'none) | |
1450 | (conversation-log-port console)) | |
1451 | #$marionette) | |
ccb1a8c4 LC |
1452 | |
1453 | ;; Tell the installer to not wait for the Connman "online" status. | |
1550db6f MO |
1454 | (marionette-eval* '(call-with-output-file "/tmp/installer-assume-online" |
1455 | (const #t)) | |
1456 | #$marionette) | |
ccb1a8c4 LC |
1457 | |
1458 | ;; Run 'guix system init' with '--no-grafts', to cope with the lack of | |
1459 | ;; network access. | |
1550db6f MO |
1460 | (marionette-eval* '(call-with-output-file |
1461 | "/tmp/installer-system-init-options" | |
1462 | (lambda (port) | |
1463 | (write '("--no-grafts" "--no-substitutes") | |
1464 | port))) | |
1465 | #$marionette) | |
1466 | ||
1467 | (marionette-eval* '(define installer-socket | |
1468 | (open-installer-socket)) | |
1469 | #$marionette) | |
ccb1a8c4 LC |
1470 | (screenshot "installer-start.ppm") |
1471 | ||
1550db6f MO |
1472 | (marionette-eval* '(choose-locale+keyboard installer-socket) |
1473 | #$marionette) | |
ccb1a8c4 LC |
1474 | (screenshot "installer-locale.ppm") |
1475 | ||
1476 | ;; Choose the host name that the "basic" test expects. | |
1550db6f MO |
1477 | (marionette-eval* '(enter-host-name+passwords installer-socket |
1478 | #:host-name "liberigilo" | |
1479 | #:root-password | |
1480 | #$%root-password | |
1481 | #:users | |
1482 | '(("alice" "pass1") | |
1483 | ("bob" "pass2"))) | |
1484 | #$marionette) | |
ccb1a8c4 LC |
1485 | (screenshot "installer-services.ppm") |
1486 | ||
1550db6f | 1487 | (marionette-eval* '(choose-services installer-socket |
b03ebdbc MO |
1488 | #:choose-desktop-environment? |
1489 | (const #$desktop?) | |
1550db6f MO |
1490 | #:choose-network-service? |
1491 | (const #f)) | |
1492 | #$marionette) | |
ccb1a8c4 LC |
1493 | (screenshot "installer-partitioning.ppm") |
1494 | ||
1550db6f MO |
1495 | (marionette-eval* '(choose-partitioning installer-socket |
1496 | #:encrypted? #$encrypted? | |
95b3fc12 MO |
1497 | #:passphrase #$%luks-passphrase |
1498 | #:uefi-support? #$uefi-support?) | |
1550db6f | 1499 | #$marionette) |
ccb1a8c4 LC |
1500 | (screenshot "installer-run.ppm") |
1501 | ||
1c6d9853 LC |
1502 | (unless #$encrypted? |
1503 | ;; At this point, user partitions are formatted and the installer is | |
1504 | ;; waiting for us to start the final step: generating the | |
1505 | ;; configuration file, etc. Set a fixed UUID on the swap partition | |
1506 | ;; that matches what 'installation-target-os-for-gui-tests' expects. | |
1507 | (marionette-eval* '(invoke #$(file-append util-linux "/sbin/swaplabel") | |
1508 | "-U" "11111111-2222-3333-4444-123456789abc" | |
1509 | "/dev/vda2") | |
1510 | #$marionette)) | |
1511 | ||
95b3fc12 | 1512 | (marionette-eval* '(start-installation installer-socket) |
1550db6f | 1513 | #$marionette) |
ccb1a8c4 | 1514 | |
95b3fc12 MO |
1515 | ;; XXX: The grub-install process uses efibootmgr to add an UEFI Guix |
1516 | ;; boot entry. The corresponding UEFI variable is stored in RAM, and | |
1517 | ;; possibly saved persistently on QEMU reboot in a NvVars file, see: | |
1518 | ;; https://lists.gnu.org/archive/html/qemu-discuss/2018-04/msg00045.html. | |
1519 | ;; | |
1520 | ;; As we are running QEMU with the no-reboot flag, this variable is | |
1521 | ;; never saved persistently, QEMU fails to boot the installed system and | |
1522 | ;; an UEFI shell is displayed instead. | |
1523 | ;; | |
1524 | ;; To make the installed UEFI system bootable, register Grub as the | |
1525 | ;; default UEFI boot entry, in the same way as if grub-install was | |
1526 | ;; invoked with the --removable option. | |
1527 | (when #$uefi-support? | |
1528 | (marionette-eval* | |
1529 | '(begin | |
1530 | (use-modules (ice-9 match)) | |
1531 | (let ((targets (cond | |
1532 | ((string-prefix? "x86_64" #$system) | |
1533 | '("grubx64.efi" "BOOTX64.EFI")) | |
1534 | ((string-prefix? "i686" #$system) | |
1535 | '("grubia32.efi" "BOOTIA32.EFI")) | |
1536 | (else #f)))) | |
1537 | (match targets | |
1538 | ((src dest) | |
1539 | (rename-file "/mnt/boot/efi/EFI/Guix" | |
1540 | "/mnt/boot/efi/EFI/BOOT") | |
1541 | (rename-file | |
1542 | (string-append "/mnt/boot/efi/EFI/BOOT/" src) | |
1543 | (string-append "/mnt/boot/efi/EFI/BOOT/" dest))) | |
1544 | (_ #f)))) | |
1545 | #$marionette)) | |
1546 | ||
1547 | (marionette-eval* '(complete-installation installer-socket) | |
1548 | #$marionette) | |
ccb1a8c4 LC |
1549 | (sync) |
1550 | #t)) | |
1551 | ||
1552 | (define %extra-packages | |
1553 | ;; Packages needed when installing with an encrypted root. | |
1554 | (list isc-dhcp | |
1555 | lvm2-static cryptsetup-static e2fsck/static | |
95b3fc12 | 1556 | loadkeys-static grub-efi fatfsck/static dosfstools)) |
ccb1a8c4 LC |
1557 | |
1558 | (define installation-os-for-gui-tests | |
1559 | ;; Operating system that contains all of %EXTRA-PACKAGES, needed for the | |
1560 | ;; target OS, as well as syslog output redirected to the console so we can | |
1561 | ;; see what the installer is up to. | |
1562 | (marionette-operating-system | |
1563 | (operating-system | |
1564 | (inherit (operating-system-with-console-syslog | |
1565 | (operating-system-add-packages | |
1566 | (operating-system-with-current-guix | |
1567 | installation-os) | |
1568 | %extra-packages))) | |
1569 | (kernel-arguments '("console=ttyS0"))) | |
1570 | #:imported-modules '((gnu services herd) | |
1571 | (gnu installer tests) | |
1572 | (guix combinators)))) | |
1573 | ||
b03ebdbc | 1574 | (define* (installation-target-os-for-gui-tests |
95b3fc12 MO |
1575 | #:key |
1576 | (encrypted? #f) | |
1577 | (uefi-support? #f)) | |
b03ebdbc | 1578 | (operating-system |
c537d2bc | 1579 | (inherit %minimal-os-on-vda) |
95b3fc12 MO |
1580 | (file-systems `(,(file-system |
1581 | (device (file-system-label "my-root")) | |
1582 | (mount-point "/") | |
1583 | (type "ext4")) | |
1584 | ,@(if uefi-support? | |
1585 | (list (file-system | |
1586 | (device (uuid "1234-ABCD" 'fat)) | |
1587 | (mount-point "/boot/efi") | |
1588 | (type "vfat"))) | |
1589 | '()) | |
1590 | ,@%base-file-systems)) | |
b03ebdbc MO |
1591 | (users (append (list (user-account |
1592 | (name "alice") | |
1593 | (comment "Bob's sister") | |
1594 | (group "users") | |
1595 | (supplementary-groups | |
1596 | '("wheel" "audio" "video"))) | |
1597 | (user-account | |
1598 | (name "bob") | |
1599 | (comment "Alice's brother") | |
1600 | (group "users") | |
1601 | (supplementary-groups | |
1602 | '("wheel" "audio" "video")))) | |
1603 | %base-user-accounts)) | |
1604 | ;; The installer does not create a swap device in guided mode with | |
1c6d9853 LC |
1605 | ;; encryption support. The installer produces a UUID for the partition; |
1606 | ;; this "UUID" is explicitly set in 'gui-test-program' to the value shown | |
1607 | ;; below. | |
1608 | (swap-devices (if encrypted? | |
1609 | '() | |
1610 | (list (uuid "11111111-2222-3333-4444-123456789abc")))) | |
b03ebdbc | 1611 | (services (cons (service dhcp-client-service-type) |
c537d2bc | 1612 | (operating-system-user-services %minimal-os-on-vda))))) |
b03ebdbc MO |
1613 | |
1614 | (define* (installation-target-desktop-os-for-gui-tests | |
1615 | #:key (encrypted? #f)) | |
1616 | (operating-system | |
1617 | (inherit (installation-target-os-for-gui-tests | |
1618 | #:encrypted? encrypted?)) | |
1619 | (keyboard-layout (keyboard-layout "us" "altgr-intl")) | |
1620 | ||
1621 | ;; Make sure that all the packages and services that may be used by the | |
1622 | ;; graphical installer are available. | |
1623 | (packages (append | |
1624 | (list openbox awesome i3-wm i3status | |
1197b8b2 JN |
1625 | dmenu st ratpoison xterm |
1626 | emacs emacs-exwm emacs-desktop-environment) | |
b03ebdbc MO |
1627 | %base-packages)) |
1628 | (services | |
1629 | (append | |
1630 | (list (service gnome-desktop-service-type) | |
1631 | (service xfce-desktop-service-type) | |
1632 | (service mate-desktop-service-type) | |
1633 | (service enlightenment-desktop-service-type) | |
1634 | (set-xorg-configuration | |
1635 | (xorg-configuration | |
1636 | (keyboard-layout keyboard-layout))) | |
1637 | (service marionette-service-type | |
1638 | (marionette-configuration | |
1639 | (imported-modules '((gnu services herd) | |
1640 | (guix build utils) | |
1641 | (guix combinators)))))) | |
1642 | %desktop-services)))) | |
1643 | ||
1644 | (define* (guided-installation-test name | |
1645 | #:key | |
1646 | (desktop? #f) | |
1647 | (encrypted? #f) | |
95b3fc12 | 1648 | (uefi-support? #f) |
b03ebdbc MO |
1649 | target-os |
1650 | (install-size 'guess) | |
1651 | (target-size (* 2200 MiB))) | |
ccb1a8c4 LC |
1652 | (system-test |
1653 | (name name) | |
1654 | (description | |
1655 | "Install an OS using the graphical installer and test it.") | |
1656 | (value | |
b03ebdbc MO |
1657 | (mlet* %store-monad |
1658 | ((image (run-install target-os '(this is unused) | |
1659 | #:script #f | |
1660 | #:os installation-os-for-gui-tests | |
95b3fc12 | 1661 | #:uefi-support? uefi-support? |
b03ebdbc MO |
1662 | #:install-size install-size |
1663 | #:target-size target-size | |
10b135ce MO |
1664 | #:installation-image-type |
1665 | 'uncompressed-iso9660 | |
b03ebdbc MO |
1666 | #:gui-test |
1667 | (lambda (marionette) | |
1668 | (gui-test-program | |
1669 | marionette | |
1670 | #:desktop? desktop? | |
95b3fc12 MO |
1671 | #:encrypted? encrypted? |
1672 | #:uefi-support? uefi-support?)))) | |
1673 | (command (qemu-command/writable-image image | |
1674 | #:uefi-support? uefi-support? | |
1675 | #:memory-size 512))) | |
b03ebdbc | 1676 | (run-basic-test target-os command name |
ccb1a8c4 | 1677 | #:initialization (and encrypted? enter-luks-passphrase) |
6e71514a MO |
1678 | #:root-password %root-password |
1679 | #:desktop? desktop?))))) | |
ccb1a8c4 LC |
1680 | |
1681 | (define %test-gui-installed-os | |
b03ebdbc MO |
1682 | (guided-installation-test |
1683 | "gui-installed-os" | |
1684 | #:target-os (installation-target-os-for-gui-tests))) | |
ccb1a8c4 | 1685 | |
95b3fc12 MO |
1686 | ;; Test the UEFI installation of Guix System using the graphical installer. |
1687 | (define %test-gui-uefi-installed-os | |
1688 | (guided-installation-test | |
1689 | "gui-uefi-installed-os" | |
1690 | #:uefi-support? #t | |
1691 | #:target-os (installation-target-os-for-gui-tests | |
1692 | #:uefi-support? #t) | |
1693 | #:target-size (* 3200 MiB))) | |
1694 | ||
e666a923 | 1695 | (define %test-gui-installed-os-encrypted |
b03ebdbc MO |
1696 | (guided-installation-test |
1697 | "gui-installed-os-encrypted" | |
1698 | #:encrypted? #t | |
1699 | #:target-os (installation-target-os-for-gui-tests | |
1700 | #:encrypted? #t))) | |
1701 | ||
1702 | ;; Building a desktop image is very time and space consuming. Install all | |
1703 | ;; desktop environments in a single test to reduce the overhead. | |
1704 | (define %test-gui-installed-desktop-os-encrypted | |
1705 | (guided-installation-test "gui-installed-desktop-os-encrypted" | |
1706 | #:desktop? #t | |
1707 | #:encrypted? #t | |
1708 | #:target-os | |
1709 | (installation-target-desktop-os-for-gui-tests | |
1710 | #:encrypted? #t) | |
1711 | ;; XXX: The disk-image size guess is too low. Use | |
1712 | ;; a constant value until this is fixed. | |
1713 | #:install-size (* 8000 MiB) | |
1714 | #:target-size (* 9000 MiB))) | |
ccb1a8c4 | 1715 | |
94b4274d | 1716 | ;;; install.scm ends here |