install.scm 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
  3. ;;; Copyright © 2017, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
  4. ;;; Copyright © 2020 Mathieu Othacehe <m.othacehe@gmail.com>
  5. ;;; Copyright © 2020 Danny Milosavljevic <dannym@scratchpost.org>
  6. ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
  7. ;;;
  8. ;;; This file is part of GNU Guix.
  9. ;;;
  10. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  11. ;;; under the terms of the GNU General Public License as published by
  12. ;;; the Free Software Foundation; either version 3 of the License, or (at
  13. ;;; your option) any later version.
  14. ;;;
  15. ;;; GNU Guix is distributed in the hope that it will be useful, but
  16. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. ;;; GNU General Public License for more details.
  19. ;;;
  20. ;;; You should have received a copy of the GNU General Public License
  21. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  22. (define-module (gnu tests install)
  23. #:use-module (gnu)
  24. #:use-module (gnu bootloader extlinux)
  25. #:use-module (gnu image)
  26. #:use-module (gnu tests)
  27. #:use-module (gnu tests base)
  28. #:use-module (gnu system)
  29. #:use-module (gnu system image)
  30. #:use-module (gnu system install)
  31. #:use-module (gnu system vm)
  32. #:use-module ((gnu build vm) #:select (qemu-command))
  33. #:use-module (gnu packages admin)
  34. #:use-module (gnu packages bootloaders)
  35. #:use-module (gnu packages commencement) ;for 'guile-final'
  36. #:use-module (gnu packages cryptsetup)
  37. #:use-module (gnu packages linux)
  38. #:use-module (gnu packages ocr)
  39. #:use-module (gnu packages openbox)
  40. #:use-module (gnu packages package-management)
  41. #:use-module (gnu packages ratpoison)
  42. #:use-module (gnu packages suckless)
  43. #:use-module (gnu packages virtualization)
  44. #:use-module (gnu packages wm)
  45. #:use-module (gnu packages xorg)
  46. #:use-module (gnu services desktop)
  47. #:use-module (gnu services networking)
  48. #:use-module (gnu services xorg)
  49. #:use-module (guix store)
  50. #:use-module (guix monads)
  51. #:use-module (guix packages)
  52. #:use-module (guix grafts)
  53. #:use-module (guix gexp)
  54. #:use-module (guix utils)
  55. #:use-module (srfi srfi-1)
  56. #:export (%test-installed-os
  57. %test-installed-extlinux-os
  58. %test-iso-image-installer
  59. %test-separate-store-os
  60. %test-separate-home-os
  61. %test-raid-root-os
  62. %test-encrypted-root-os
  63. %test-btrfs-root-os
  64. %test-btrfs-root-on-subvolume-os
  65. %test-jfs-root-os
  66. %test-f2fs-root-os
  67. %test-gui-installed-os
  68. %test-gui-installed-os-encrypted
  69. %test-gui-installed-desktop-os-encrypted))
  70. ;;; Commentary:
  71. ;;;
  72. ;;; Test the installation of Guix using the documented approach at the
  73. ;;; command line.
  74. ;;;
  75. ;;; Code:
  76. (define-os-with-source (%minimal-os %minimal-os-source)
  77. ;; The OS we want to install.
  78. (use-modules (gnu) (gnu tests) (srfi srfi-1))
  79. (operating-system
  80. (host-name "liberigilo")
  81. (timezone "Europe/Paris")
  82. (locale "en_US.UTF-8")
  83. (bootloader (bootloader-configuration
  84. (bootloader grub-bootloader)
  85. (target "/dev/vdb")))
  86. (kernel-arguments '("console=ttyS0"))
  87. (file-systems (cons (file-system
  88. (device (file-system-label "my-root"))
  89. (mount-point "/")
  90. (type "ext4"))
  91. %base-file-systems))
  92. (users (cons (user-account
  93. (name "alice")
  94. (comment "Bob's sister")
  95. (group "users")
  96. (supplementary-groups '("wheel" "audio" "video")))
  97. %base-user-accounts))
  98. (services (cons (service marionette-service-type
  99. (marionette-configuration
  100. (imported-modules '((gnu services herd)
  101. (guix build utils)
  102. (guix combinators)))))
  103. %base-services))))
  104. (define (operating-system-add-packages os packages)
  105. "Append PACKAGES to OS packages list."
  106. (operating-system
  107. (inherit os)
  108. (packages (append packages (operating-system-packages os)))))
  109. (define-os-with-source (%minimal-extlinux-os
  110. %minimal-extlinux-os-source)
  111. (use-modules (gnu) (gnu tests) (gnu bootloader extlinux)
  112. (srfi srfi-1))
  113. (operating-system
  114. (host-name "liberigilo")
  115. (timezone "Europe/Paris")
  116. (locale "en_US.UTF-8")
  117. (bootloader (bootloader-configuration
  118. (bootloader extlinux-bootloader-gpt)
  119. (target "/dev/vdb")))
  120. (kernel-arguments '("console=ttyS0"))
  121. (file-systems (cons (file-system
  122. (device (file-system-label "my-root"))
  123. (mount-point "/")
  124. (type "ext4"))
  125. %base-file-systems))
  126. (services (cons (service marionette-service-type
  127. (marionette-configuration
  128. (imported-modules '((gnu services herd)
  129. (guix combinators)))))
  130. %base-services))))
  131. (define (operating-system-with-current-guix os)
  132. "Return a variant of OS that uses the current Guix."
  133. (operating-system
  134. (inherit os)
  135. (services (modify-services (operating-system-user-services os)
  136. (guix-service-type config =>
  137. (guix-configuration
  138. (inherit config)
  139. (guix (current-guix))))))))
  140. (define MiB (expt 2 20))
  141. (define %simple-installation-script
  142. ;; Shell script of a simple installation.
  143. "\
  144. . /etc/profile
  145. set -e -x
  146. guix --version
  147. export GUIX_BUILD_OPTIONS=--no-grafts
  148. guix build isc-dhcp
  149. parted --script /dev/vdb mklabel gpt \\
  150. mkpart primary ext2 1M 3M \\
  151. mkpart primary ext2 3M 1.6G \\
  152. set 1 boot on \\
  153. set 1 bios_grub on
  154. mkfs.ext4 -L my-root /dev/vdb2
  155. mount /dev/vdb2 /mnt
  156. df -h /mnt
  157. herd start cow-store /mnt
  158. mkdir /mnt/etc
  159. cp /etc/target-config.scm /mnt/etc/config.scm
  160. guix system init /mnt/etc/config.scm /mnt --no-substitutes
  161. sync
  162. reboot\n")
  163. (define %extlinux-gpt-installation-script
  164. ;; Shell script of a simple installation.
  165. ;; As syslinux 6.0.3 does not handle 64bits ext4 partitions,
  166. ;; we make sure to pass -O '^64bit' to mkfs.
  167. "\
  168. . /etc/profile
  169. set -e -x
  170. guix --version
  171. export GUIX_BUILD_OPTIONS=--no-grafts
  172. guix build isc-dhcp
  173. parted --script /dev/vdb mklabel gpt \\
  174. mkpart ext2 1M 1.6G \\
  175. set 1 legacy_boot on
  176. mkfs.ext4 -L my-root -O '^64bit' /dev/vdb1
  177. mount /dev/vdb1 /mnt
  178. df -h /mnt
  179. herd start cow-store /mnt
  180. mkdir /mnt/etc
  181. cp /etc/target-config.scm /mnt/etc/config.scm
  182. guix system init /mnt/etc/config.scm /mnt --no-substitutes
  183. sync
  184. reboot\n")
  185. (define* (run-install target-os target-os-source
  186. #:key
  187. (script %simple-installation-script)
  188. (gui-test #f)
  189. (packages '())
  190. (os (marionette-operating-system
  191. (operating-system
  192. ;; Since the image has no network access, use the
  193. ;; current Guix so the store items we need are in
  194. ;; the image and add packages provided.
  195. (inherit (operating-system-add-packages
  196. (operating-system-with-current-guix
  197. installation-os)
  198. packages))
  199. (kernel-arguments '("console=ttyS0")))
  200. #:imported-modules '((gnu services herd)
  201. (gnu installer tests)
  202. (guix combinators))))
  203. (installation-image-type 'raw)
  204. (install-size 'guess)
  205. (target-size (* 2200 MiB)))
  206. "Run SCRIPT (a shell script following the system installation procedure) in
  207. OS to install TARGET-OS. Return a VM image of TARGET-SIZE bytes containing
  208. the installed system. The packages specified in PACKAGES will be appended to
  209. packages defined in installation-os."
  210. (mlet* %store-monad ((_ (set-grafting #f))
  211. (system (current-system))
  212. ;; Since the installation system has no network access,
  213. ;; we cheat a little bit by adding TARGET to its GC
  214. ;; roots. This way, we know 'guix system init' will
  215. ;; succeed. Also add guile-final, which is pulled in
  216. ;; through provenance.drv and may not always be present.
  217. (target (operating-system-derivation target-os))
  218. (base-image ->
  219. (os->image
  220. (operating-system-with-gc-roots
  221. os (list target guile-final))
  222. #:type (lookup-image-type-by-name
  223. installation-image-type)))
  224. (image ->
  225. (system-image
  226. (image
  227. (inherit base-image)
  228. (size install-size)
  229. ;; Don't provide substitutes; too big.
  230. (substitutable? #f)))))
  231. (define install
  232. (with-imported-modules '((guix build utils)
  233. (gnu build marionette))
  234. #~(begin
  235. (use-modules (guix build utils)
  236. (gnu build marionette))
  237. (set-path-environment-variable "PATH" '("bin")
  238. (list #$qemu-minimal))
  239. (system* "qemu-img" "create" "-f" "qcow2"
  240. #$output #$(number->string target-size))
  241. (define marionette
  242. (make-marionette
  243. `(,(which #$(qemu-command system))
  244. "-no-reboot"
  245. "-m" "1200"
  246. #$@(cond
  247. ((eq? 'raw installation-image-type)
  248. #~("-drive"
  249. ,(string-append "file=" #$image
  250. ",if=virtio,readonly")))
  251. ((eq? 'uncompressed-iso9660 installation-image-type)
  252. #~("-cdrom" #$image))
  253. (else
  254. (error
  255. "unsupported installation-image-type:"
  256. installation-image-type)))
  257. "-drive"
  258. ,(string-append "file=" #$output ",if=virtio")
  259. ,@(if (file-exists? "/dev/kvm")
  260. '("-enable-kvm")
  261. '()))))
  262. (pk 'uname (marionette-eval '(uname) marionette))
  263. ;; Wait for tty1.
  264. (marionette-eval '(begin
  265. (use-modules (gnu services herd))
  266. (start 'term-tty1))
  267. marionette)
  268. (when #$(->bool script)
  269. (marionette-eval '(call-with-output-file "/etc/target-config.scm"
  270. (lambda (port)
  271. (write '#$target-os-source port)))
  272. marionette)
  273. ;; Run SCRIPT. It typically invokes 'reboot' as a last step and
  274. ;; thus normally gets killed with SIGTERM by PID 1.
  275. (let ((status (marionette-eval '(system #$script) marionette)))
  276. (exit (or (eof-object? status)
  277. (equal? (status:term-sig status) SIGTERM)
  278. (equal? (status:exit-val status) 0)))))
  279. (when #$(->bool gui-test)
  280. (wait-for-unix-socket "/var/guix/installer-socket"
  281. marionette)
  282. (format #t "installer socket ready~%")
  283. (force-output)
  284. (exit #$(and gui-test
  285. (gui-test #~marionette)))))))
  286. (gexp->derivation "installation" install
  287. #:substitutable? #f))) ;too big
  288. (define* (qemu-command/writable-image image #:key (memory-size 256))
  289. "Return as a monadic value the command to run QEMU on a writable copy of
  290. IMAGE, a disk image. The QEMU VM has access to MEMORY-SIZE MiB of RAM."
  291. (mlet %store-monad ((system (current-system)))
  292. (return #~(let ((image #$image))
  293. ;; First we need a writable copy of the image.
  294. (format #t "creating writable image from '~a'...~%" image)
  295. (unless (zero? (system* #+(file-append qemu-minimal
  296. "/bin/qemu-img")
  297. "create" "-f" "qcow2"
  298. "-o"
  299. (string-append "backing_file=" image)
  300. "disk.img"))
  301. (error "failed to create writable QEMU image" image))
  302. (chmod "disk.img" #o644)
  303. `(,(string-append #$qemu-minimal "/bin/"
  304. #$(qemu-command system))
  305. ,@(if (file-exists? "/dev/kvm")
  306. '("-enable-kvm")
  307. '())
  308. "-no-reboot" "-m" #$(number->string memory-size)
  309. "-drive" "file=disk.img,if=virtio")))))
  310. (define %test-installed-os
  311. (system-test
  312. (name "installed-os")
  313. (description
  314. "Test basic functionality of an OS installed like one would do by hand.
  315. This test is expensive in terms of CPU and storage usage since we need to
  316. build (current-guix) and then store a couple of full system images.")
  317. (value
  318. (mlet* %store-monad ((image (run-install %minimal-os %minimal-os-source))
  319. (command (qemu-command/writable-image image)))
  320. (run-basic-test %minimal-os command
  321. "installed-os")))))
  322. (define %test-installed-extlinux-os
  323. (system-test
  324. (name "installed-extlinux-os")
  325. (description
  326. "Test basic functionality of an OS booted with an extlinux bootloader. As
  327. per %test-installed-os, this test is expensive in terms of CPU and storage.")
  328. (value
  329. (mlet* %store-monad ((image (run-install %minimal-extlinux-os
  330. %minimal-extlinux-os-source
  331. #:packages
  332. (list syslinux)
  333. #:script
  334. %extlinux-gpt-installation-script))
  335. (command (qemu-command/writable-image image)))
  336. (run-basic-test %minimal-extlinux-os command
  337. "installed-extlinux-os")))))
  338. ;;;
  339. ;;; Installation through an ISO image.
  340. ;;;
  341. (define-os-with-source (%minimal-os-on-vda %minimal-os-on-vda-source)
  342. ;; The OS we want to install.
  343. (use-modules (gnu) (gnu tests) (srfi srfi-1))
  344. (operating-system
  345. (host-name "liberigilo")
  346. (timezone "Europe/Paris")
  347. (locale "en_US.UTF-8")
  348. (bootloader (bootloader-configuration
  349. (bootloader grub-bootloader)
  350. (target "/dev/vda")))
  351. (kernel-arguments '("console=ttyS0"))
  352. (file-systems (cons (file-system
  353. (device (file-system-label "my-root"))
  354. (mount-point "/")
  355. (type "ext4"))
  356. %base-file-systems))
  357. (users (cons (user-account
  358. (name "alice")
  359. (comment "Bob's sister")
  360. (group "users")
  361. (supplementary-groups '("wheel" "audio" "video")))
  362. %base-user-accounts))
  363. (services (cons (service marionette-service-type
  364. (marionette-configuration
  365. (imported-modules '((gnu services herd)
  366. (guix build utils)
  367. (guix combinators)))))
  368. %base-services))))
  369. (define %simple-installation-script-for-/dev/vda
  370. ;; Shell script of a simple installation.
  371. "\
  372. . /etc/profile
  373. set -e -x
  374. guix --version
  375. export GUIX_BUILD_OPTIONS=--no-grafts
  376. guix build isc-dhcp
  377. parted --script /dev/vda mklabel gpt \\
  378. mkpart primary ext2 1M 3M \\
  379. mkpart primary ext2 3M 1.6G \\
  380. set 1 boot on \\
  381. set 1 bios_grub on
  382. mkfs.ext4 -L my-root /dev/vda2
  383. mount /dev/vda2 /mnt
  384. df -h /mnt
  385. herd start cow-store /mnt
  386. mkdir /mnt/etc
  387. cp /etc/target-config.scm /mnt/etc/config.scm
  388. guix system init /mnt/etc/config.scm /mnt --no-substitutes
  389. sync
  390. reboot\n")
  391. (define %test-iso-image-installer
  392. (system-test
  393. (name "iso-image-installer")
  394. (description
  395. "")
  396. (value
  397. (mlet* %store-monad ((image (run-install
  398. %minimal-os-on-vda
  399. %minimal-os-on-vda-source
  400. #:script
  401. %simple-installation-script-for-/dev/vda
  402. #:installation-image-type
  403. 'uncompressed-iso9660))
  404. (command (qemu-command/writable-image image)))
  405. (run-basic-test %minimal-os-on-vda command name)))))
  406. ;;;
  407. ;;; Separate /home.
  408. ;;;
  409. (define-os-with-source (%separate-home-os %separate-home-os-source)
  410. ;; The OS we want to install.
  411. (use-modules (gnu) (gnu tests) (srfi srfi-1))
  412. (operating-system
  413. (host-name "liberigilo")
  414. (timezone "Europe/Paris")
  415. (locale "en_US.utf8")
  416. (bootloader (bootloader-configuration
  417. (bootloader grub-bootloader)
  418. (target "/dev/vdb")))
  419. (kernel-arguments '("console=ttyS0"))
  420. (file-systems (cons* (file-system
  421. (device (file-system-label "my-root"))
  422. (mount-point "/")
  423. (type "ext4"))
  424. (file-system
  425. (device "none")
  426. (mount-point "/home")
  427. (type "tmpfs"))
  428. %base-file-systems))
  429. (users (cons* (user-account
  430. (name "alice")
  431. (group "users"))
  432. (user-account
  433. (name "charlie")
  434. (group "users"))
  435. %base-user-accounts))
  436. (services (cons (service marionette-service-type
  437. (marionette-configuration
  438. (imported-modules '((gnu services herd)
  439. (guix combinators)))))
  440. %base-services))))
  441. (define %test-separate-home-os
  442. (system-test
  443. (name "separate-home-os")
  444. (description
  445. "Test basic functionality of an installed OS with a separate /home
  446. partition. In particular, home directories must be correctly created (see
  447. <https://bugs.gnu.org/21108>).")
  448. (value
  449. (mlet* %store-monad ((image (run-install %separate-home-os
  450. %separate-home-os-source
  451. #:script
  452. %simple-installation-script))
  453. (command (qemu-command/writable-image image)))
  454. (run-basic-test %separate-home-os command "separate-home-os")))))
  455. ;;;
  456. ;;; Separate /gnu/store partition.
  457. ;;;
  458. (define-os-with-source (%separate-store-os %separate-store-os-source)
  459. ;; The OS we want to install.
  460. (use-modules (gnu) (gnu tests) (srfi srfi-1))
  461. (operating-system
  462. (host-name "liberigilo")
  463. (timezone "Europe/Paris")
  464. (locale "en_US.UTF-8")
  465. (bootloader (bootloader-configuration
  466. (bootloader grub-bootloader)
  467. (target "/dev/vdb")))
  468. (kernel-arguments '("console=ttyS0"))
  469. (file-systems (cons* (file-system
  470. (device (file-system-label "root-fs"))
  471. (mount-point "/")
  472. (type "ext4"))
  473. (file-system
  474. (device (file-system-label "store-fs"))
  475. (mount-point "/gnu")
  476. (type "ext4"))
  477. %base-file-systems))
  478. (users %base-user-accounts)
  479. (services (cons (service marionette-service-type
  480. (marionette-configuration
  481. (imported-modules '((gnu services herd)
  482. (guix combinators)))))
  483. %base-services))))
  484. (define %separate-store-installation-script
  485. ;; Installation with a separate /gnu partition.
  486. "\
  487. . /etc/profile
  488. set -e -x
  489. guix --version
  490. export GUIX_BUILD_OPTIONS=--no-grafts
  491. guix build isc-dhcp
  492. parted --script /dev/vdb mklabel gpt \\
  493. mkpart primary ext2 1M 3M \\
  494. mkpart primary ext2 3M 400M \\
  495. mkpart primary ext2 400M 2.1G \\
  496. set 1 boot on \\
  497. set 1 bios_grub on
  498. mkfs.ext4 -L root-fs /dev/vdb2
  499. mkfs.ext4 -L store-fs /dev/vdb3
  500. mount /dev/vdb2 /mnt
  501. mkdir /mnt/gnu
  502. mount /dev/vdb3 /mnt/gnu
  503. df -h /mnt
  504. df -h /mnt/gnu
  505. herd start cow-store /mnt
  506. mkdir /mnt/etc
  507. cp /etc/target-config.scm /mnt/etc/config.scm
  508. guix system init /mnt/etc/config.scm /mnt --no-substitutes
  509. sync
  510. reboot\n")
  511. (define %test-separate-store-os
  512. (system-test
  513. (name "separate-store-os")
  514. (description
  515. "Test basic functionality of an OS installed like one would do by hand,
  516. where /gnu lives on a separate partition.")
  517. (value
  518. (mlet* %store-monad ((image (run-install %separate-store-os
  519. %separate-store-os-source
  520. #:script
  521. %separate-store-installation-script))
  522. (command (qemu-command/writable-image image)))
  523. (run-basic-test %separate-store-os command "separate-store-os")))))
  524. ;;;
  525. ;;; RAID root device.
  526. ;;;
  527. (define-os-with-source (%raid-root-os %raid-root-os-source)
  528. ;; An OS whose root partition is a RAID partition.
  529. (use-modules (gnu) (gnu tests))
  530. (operating-system
  531. (host-name "raidified")
  532. (timezone "Europe/Paris")
  533. (locale "en_US.utf8")
  534. (bootloader (bootloader-configuration
  535. (bootloader grub-bootloader)
  536. (target "/dev/vdb")))
  537. (kernel-arguments '("console=ttyS0"))
  538. ;; Add a kernel module for RAID-1 (aka. "mirror").
  539. (initrd-modules (cons "raid1" %base-initrd-modules))
  540. (mapped-devices (list (mapped-device
  541. (source (list "/dev/vda2" "/dev/vda3"))
  542. (target "/dev/md0")
  543. (type raid-device-mapping))))
  544. (file-systems (cons (file-system
  545. (device (file-system-label "root-fs"))
  546. (mount-point "/")
  547. (type "ext4")
  548. (dependencies mapped-devices))
  549. %base-file-systems))
  550. (users %base-user-accounts)
  551. (services (cons (service marionette-service-type
  552. (marionette-configuration
  553. (imported-modules '((gnu services herd)
  554. (guix combinators)))))
  555. %base-services))))
  556. (define %raid-root-installation-script
  557. ;; Installation with a separate /gnu partition. See
  558. ;; <https://raid.wiki.kernel.org/index.php/RAID_setup> for more on RAID and
  559. ;; mdadm.
  560. "\
  561. . /etc/profile
  562. set -e -x
  563. guix --version
  564. export GUIX_BUILD_OPTIONS=--no-grafts
  565. parted --script /dev/vdb mklabel gpt \\
  566. mkpart primary ext2 1M 3M \\
  567. mkpart primary ext2 3M 1.6G \\
  568. mkpart primary ext2 1.6G 3.2G \\
  569. set 1 boot on \\
  570. set 1 bios_grub on
  571. yes | mdadm --create /dev/md0 --verbose --level=mirror --raid-devices=2 \\
  572. /dev/vdb2 /dev/vdb3
  573. mkfs.ext4 -L root-fs /dev/md0
  574. mount /dev/md0 /mnt
  575. df -h /mnt
  576. herd start cow-store /mnt
  577. mkdir /mnt/etc
  578. cp /etc/target-config.scm /mnt/etc/config.scm
  579. guix system init /mnt/etc/config.scm /mnt --no-substitutes
  580. sync
  581. reboot\n")
  582. (define %test-raid-root-os
  583. (system-test
  584. (name "raid-root-os")
  585. (description
  586. "Test functionality of an OS installed with a RAID root partition managed
  587. by 'mdadm'.")
  588. (value
  589. (mlet* %store-monad ((image (run-install %raid-root-os
  590. %raid-root-os-source
  591. #:script
  592. %raid-root-installation-script
  593. #:target-size (* 3200 MiB)))
  594. (command (qemu-command/writable-image image)))
  595. (run-basic-test %raid-root-os
  596. `(,@command) "raid-root-os")))))
  597. ;;;
  598. ;;; LUKS-encrypted root file system.
  599. ;;;
  600. (define-os-with-source (%encrypted-root-os %encrypted-root-os-source)
  601. ;; The OS we want to install.
  602. (use-modules (gnu) (gnu tests) (srfi srfi-1))
  603. (operating-system
  604. (host-name "liberigilo")
  605. (timezone "Europe/Paris")
  606. (locale "en_US.UTF-8")
  607. (bootloader (bootloader-configuration
  608. (bootloader grub-bootloader)
  609. (target "/dev/vdb")))
  610. ;; Note: Do not pass "console=ttyS0" so we can use our passphrase prompt
  611. ;; detection logic in 'enter-luks-passphrase'.
  612. (mapped-devices (list (mapped-device
  613. (source (uuid "12345678-1234-1234-1234-123456789abc"))
  614. (target "the-root-device")
  615. (type luks-device-mapping))))
  616. (file-systems (cons (file-system
  617. (device "/dev/mapper/the-root-device")
  618. (mount-point "/")
  619. (type "ext4"))
  620. %base-file-systems))
  621. (users (cons (user-account
  622. (name "charlie")
  623. (group "users")
  624. (supplementary-groups '("wheel" "audio" "video")))
  625. %base-user-accounts))
  626. (services (cons (service marionette-service-type
  627. (marionette-configuration
  628. (imported-modules '((gnu services herd)
  629. (guix combinators)))))
  630. %base-services))))
  631. (define %luks-passphrase
  632. ;; LUKS encryption passphrase used in tests.
  633. "thepassphrase")
  634. (define %encrypted-root-installation-script
  635. ;; Shell script of a simple installation.
  636. (string-append "\
  637. . /etc/profile
  638. set -e -x
  639. guix --version
  640. export GUIX_BUILD_OPTIONS=--no-grafts
  641. ls -l /run/current-system/gc-roots
  642. parted --script /dev/vdb mklabel gpt \\
  643. mkpart primary ext2 1M 3M \\
  644. mkpart primary ext2 3M 1.6G \\
  645. set 1 boot on \\
  646. set 1 bios_grub on
  647. echo -n " %luks-passphrase " | \\
  648. cryptsetup luksFormat --uuid=12345678-1234-1234-1234-123456789abc -q /dev/vdb2 -
  649. echo -n " %luks-passphrase " | \\
  650. cryptsetup open --type luks --key-file - /dev/vdb2 the-root-device
  651. mkfs.ext4 -L my-root /dev/mapper/the-root-device
  652. mount LABEL=my-root /mnt
  653. herd start cow-store /mnt
  654. mkdir /mnt/etc
  655. cp /etc/target-config.scm /mnt/etc/config.scm
  656. guix system build /mnt/etc/config.scm
  657. guix system init /mnt/etc/config.scm /mnt --no-substitutes
  658. sync
  659. reboot\n"))
  660. (define (enter-luks-passphrase marionette)
  661. "Return a gexp to be inserted in the basic system test running on MARIONETTE
  662. to enter the LUKS passphrase."
  663. (let ((ocrad (file-append ocrad "/bin/ocrad")))
  664. #~(begin
  665. (define (passphrase-prompt? text)
  666. (string-contains (pk 'screen-text text) "Enter pass"))
  667. (define (bios-boot-screen? text)
  668. ;; Return true if TEXT corresponds to the boot screen, before GRUB's
  669. ;; menu.
  670. (string-prefix? "SeaBIOS" text))
  671. (test-assert "enter LUKS passphrase for GRUB"
  672. (begin
  673. ;; At this point we have no choice but to use OCR to determine
  674. ;; when the passphrase should be entered.
  675. (wait-for-screen-text #$marionette passphrase-prompt?
  676. #:ocrad #$ocrad)
  677. (marionette-type #$(string-append %luks-passphrase "\n")
  678. #$marionette)
  679. ;; Now wait until we leave the boot screen. This is necessary so
  680. ;; we can then be sure we match the "Enter passphrase" prompt from
  681. ;; 'cryptsetup', in the initrd.
  682. (wait-for-screen-text #$marionette (negate bios-boot-screen?)
  683. #:ocrad #$ocrad
  684. #:timeout 20)))
  685. (test-assert "enter LUKS passphrase for the initrd"
  686. (begin
  687. ;; XXX: Here we use OCR as well but we could instead use QEMU
  688. ;; '-serial stdio' and run it in an input pipe,
  689. (wait-for-screen-text #$marionette passphrase-prompt?
  690. #:ocrad #$ocrad
  691. #:timeout 60)
  692. (marionette-type #$(string-append %luks-passphrase "\n")
  693. #$marionette)
  694. ;; Take a screenshot for debugging purposes.
  695. (marionette-control (string-append "screendump " #$output
  696. "/post-initrd-passphrase.ppm")
  697. #$marionette))))))
  698. (define %test-encrypted-root-os
  699. (system-test
  700. (name "encrypted-root-os")
  701. (description
  702. "Test basic functionality of an OS installed like one would do by hand.
  703. This test is expensive in terms of CPU and storage usage since we need to
  704. build (current-guix) and then store a couple of full system images.")
  705. (value
  706. (mlet* %store-monad ((image (run-install %encrypted-root-os
  707. %encrypted-root-os-source
  708. #:script
  709. %encrypted-root-installation-script))
  710. (command (qemu-command/writable-image image)))
  711. (run-basic-test %encrypted-root-os command "encrypted-root-os"
  712. #:initialization enter-luks-passphrase)))))
  713. ;;;
  714. ;;; Btrfs root file system.
  715. ;;;
  716. (define-os-with-source (%btrfs-root-os %btrfs-root-os-source)
  717. ;; The OS we want to install.
  718. (use-modules (gnu) (gnu tests) (srfi srfi-1))
  719. (operating-system
  720. (host-name "liberigilo")
  721. (timezone "Europe/Paris")
  722. (locale "en_US.UTF-8")
  723. (bootloader (bootloader-configuration
  724. (bootloader grub-bootloader)
  725. (target "/dev/vdb")))
  726. (kernel-arguments '("console=ttyS0"))
  727. (file-systems (cons (file-system
  728. (device (file-system-label "my-root"))
  729. (mount-point "/")
  730. (type "btrfs"))
  731. %base-file-systems))
  732. (users (cons (user-account
  733. (name "charlie")
  734. (group "users")
  735. (supplementary-groups '("wheel" "audio" "video")))
  736. %base-user-accounts))
  737. (services (cons (service marionette-service-type
  738. (marionette-configuration
  739. (imported-modules '((gnu services herd)
  740. (guix combinators)))))
  741. %base-services))))
  742. (define %btrfs-root-installation-script
  743. ;; Shell script of a simple installation.
  744. "\
  745. . /etc/profile
  746. set -e -x
  747. guix --version
  748. export GUIX_BUILD_OPTIONS=--no-grafts
  749. ls -l /run/current-system/gc-roots
  750. parted --script /dev/vdb mklabel gpt \\
  751. mkpart primary ext2 1M 3M \\
  752. mkpart primary ext2 3M 2G \\
  753. set 1 boot on \\
  754. set 1 bios_grub on
  755. mkfs.btrfs -L my-root /dev/vdb2
  756. mount /dev/vdb2 /mnt
  757. btrfs subvolume create /mnt/home
  758. herd start cow-store /mnt
  759. mkdir /mnt/etc
  760. cp /etc/target-config.scm /mnt/etc/config.scm
  761. guix system build /mnt/etc/config.scm
  762. guix system init /mnt/etc/config.scm /mnt --no-substitutes
  763. sync
  764. reboot\n")
  765. (define %test-btrfs-root-os
  766. (system-test
  767. (name "btrfs-root-os")
  768. (description
  769. "Test basic functionality of an OS installed like one would do by hand.
  770. This test is expensive in terms of CPU and storage usage since we need to
  771. build (current-guix) and then store a couple of full system images.")
  772. (value
  773. (mlet* %store-monad ((image (run-install %btrfs-root-os
  774. %btrfs-root-os-source
  775. #:script
  776. %btrfs-root-installation-script))
  777. (command (qemu-command/writable-image image)))
  778. (run-basic-test %btrfs-root-os command "btrfs-root-os")))))
  779. ;;;
  780. ;;; Btrfs root file system on a subvolume.
  781. ;;;
  782. (define-os-with-source (%btrfs-root-on-subvolume-os
  783. %btrfs-root-on-subvolume-os-source)
  784. ;; The OS we want to install.
  785. (use-modules (gnu) (gnu tests) (srfi srfi-1))
  786. (operating-system
  787. (host-name "hurd")
  788. (timezone "America/Montreal")
  789. (locale "en_US.UTF-8")
  790. (bootloader (bootloader-configuration
  791. (bootloader grub-bootloader)
  792. (target "/dev/vdb")))
  793. (kernel-arguments '("console=ttyS0"))
  794. (file-systems (cons* (file-system
  795. (device (file-system-label "btrfs-pool"))
  796. (mount-point "/")
  797. (options "subvol=rootfs,compress=zstd")
  798. (type "btrfs"))
  799. (file-system
  800. (device (file-system-label "btrfs-pool"))
  801. (mount-point "/home")
  802. (options "subvol=homefs,compress=lzo")
  803. (type "btrfs"))
  804. %base-file-systems))
  805. (users (cons (user-account
  806. (name "charlie")
  807. (group "users")
  808. (supplementary-groups '("wheel" "audio" "video")))
  809. %base-user-accounts))
  810. (services (cons (service marionette-service-type
  811. (marionette-configuration
  812. (imported-modules '((gnu services herd)
  813. (guix combinators)))))
  814. %base-services))))
  815. (define %btrfs-root-on-subvolume-installation-script
  816. ;; Shell script of a simple installation.
  817. "\
  818. . /etc/profile
  819. set -e -x
  820. guix --version
  821. export GUIX_BUILD_OPTIONS=--no-grafts
  822. ls -l /run/current-system/gc-roots
  823. parted --script /dev/vdb mklabel gpt \\
  824. mkpart primary ext2 1M 3M \\
  825. mkpart primary ext2 3M 2G \\
  826. set 1 boot on \\
  827. set 1 bios_grub on
  828. # Setup the top level Btrfs file system with its subvolume.
  829. mkfs.btrfs -L btrfs-pool /dev/vdb2
  830. mount /dev/vdb2 /mnt
  831. btrfs subvolume create /mnt/rootfs
  832. btrfs subvolume create /mnt/homefs
  833. umount /dev/vdb2
  834. # Mount the subvolumes, ready for installation.
  835. mount LABEL=btrfs-pool -o 'subvol=rootfs,compress=zstd' /mnt
  836. mkdir /mnt/home
  837. mount LABEL=btrfs-pool -o 'subvol=homefs,compress=zstd' /mnt/home
  838. herd start cow-store /mnt
  839. mkdir /mnt/etc
  840. cp /etc/target-config.scm /mnt/etc/config.scm
  841. guix system build /mnt/etc/config.scm
  842. guix system init /mnt/etc/config.scm /mnt --no-substitutes
  843. sync
  844. reboot\n")
  845. (define %test-btrfs-root-on-subvolume-os
  846. (system-test
  847. (name "btrfs-root-on-subvolume-os")
  848. (description
  849. "Test basic functionality of an OS installed like one would do by hand.
  850. This test is expensive in terms of CPU and storage usage since we need to
  851. build (current-guix) and then store a couple of full system images.")
  852. (value
  853. (mlet* %store-monad
  854. ((image
  855. (run-install %btrfs-root-on-subvolume-os
  856. %btrfs-root-on-subvolume-os-source
  857. #:script
  858. %btrfs-root-on-subvolume-installation-script))
  859. (command (qemu-command/writable-image image)))
  860. (run-basic-test %btrfs-root-on-subvolume-os command
  861. "btrfs-root-on-subvolume-os")))))
  862. ;;;
  863. ;;; JFS root file system.
  864. ;;;
  865. (define-os-with-source (%jfs-root-os %jfs-root-os-source)
  866. ;; The OS we want to install.
  867. (use-modules (gnu) (gnu tests) (srfi srfi-1))
  868. (operating-system
  869. (host-name "liberigilo")
  870. (timezone "Europe/Paris")
  871. (locale "en_US.UTF-8")
  872. (bootloader (bootloader-configuration
  873. (bootloader grub-bootloader)
  874. (target "/dev/vdb")))
  875. (kernel-arguments '("console=ttyS0"))
  876. (file-systems (cons (file-system
  877. (device (file-system-label "my-root"))
  878. (mount-point "/")
  879. (type "jfs"))
  880. %base-file-systems))
  881. (users (cons (user-account
  882. (name "charlie")
  883. (group "users")
  884. (supplementary-groups '("wheel" "audio" "video")))
  885. %base-user-accounts))
  886. (services (cons (service marionette-service-type
  887. (marionette-configuration
  888. (imported-modules '((gnu services herd)
  889. (guix combinators)))))
  890. %base-services))))
  891. (define %jfs-root-installation-script
  892. ;; Shell script of a simple installation.
  893. "\
  894. . /etc/profile
  895. set -e -x
  896. guix --version
  897. export GUIX_BUILD_OPTIONS=--no-grafts
  898. ls -l /run/current-system/gc-roots
  899. parted --script /dev/vdb mklabel gpt \\
  900. mkpart primary ext2 1M 3M \\
  901. mkpart primary ext2 3M 2G \\
  902. set 1 boot on \\
  903. set 1 bios_grub on
  904. jfs_mkfs -L my-root -q /dev/vdb2
  905. mount /dev/vdb2 /mnt
  906. herd start cow-store /mnt
  907. mkdir /mnt/etc
  908. cp /etc/target-config.scm /mnt/etc/config.scm
  909. guix system build /mnt/etc/config.scm
  910. guix system init /mnt/etc/config.scm /mnt --no-substitutes
  911. sync
  912. reboot\n")
  913. (define %test-jfs-root-os
  914. (system-test
  915. (name "jfs-root-os")
  916. (description
  917. "Test basic functionality of an OS installed like one would do by hand.
  918. This test is expensive in terms of CPU and storage usage since we need to
  919. build (current-guix) and then store a couple of full system images.")
  920. (value
  921. (mlet* %store-monad ((image (run-install %jfs-root-os
  922. %jfs-root-os-source
  923. #:script
  924. %jfs-root-installation-script))
  925. (command (qemu-command/writable-image image)))
  926. (run-basic-test %jfs-root-os command "jfs-root-os")))))
  927. ;;;
  928. ;;; F2FS root file system.
  929. ;;;
  930. (define-os-with-source (%f2fs-root-os %f2fs-root-os-source)
  931. ;; The OS we want to install.
  932. (use-modules (gnu) (gnu tests) (srfi srfi-1))
  933. (operating-system
  934. (host-name "liberigilo")
  935. (timezone "Europe/Paris")
  936. (locale "en_US.UTF-8")
  937. (bootloader (bootloader-configuration
  938. (bootloader grub-bootloader)
  939. (target "/dev/vdb")))
  940. (kernel-arguments '("console=ttyS0"))
  941. (file-systems (cons (file-system
  942. (device (file-system-label "my-root"))
  943. (mount-point "/")
  944. (type "f2fs"))
  945. %base-file-systems))
  946. (users (cons (user-account
  947. (name "charlie")
  948. (group "users")
  949. (supplementary-groups '("wheel" "audio" "video")))
  950. %base-user-accounts))
  951. (services (cons (service marionette-service-type
  952. (marionette-configuration
  953. (imported-modules '((gnu services herd)
  954. (guix combinators)))))
  955. %base-services))))
  956. (define %f2fs-root-installation-script
  957. ;; Shell script of a simple installation.
  958. "\
  959. . /etc/profile
  960. set -e -x
  961. guix --version
  962. export GUIX_BUILD_OPTIONS=--no-grafts
  963. ls -l /run/current-system/gc-roots
  964. parted --script /dev/vdb mklabel gpt \\
  965. mkpart primary ext2 1M 3M \\
  966. mkpart primary ext2 3M 2G \\
  967. set 1 boot on \\
  968. set 1 bios_grub on
  969. mkfs.f2fs -l my-root -q /dev/vdb2
  970. mount /dev/vdb2 /mnt
  971. herd start cow-store /mnt
  972. mkdir /mnt/etc
  973. cp /etc/target-config.scm /mnt/etc/config.scm
  974. guix system build /mnt/etc/config.scm
  975. guix system init /mnt/etc/config.scm /mnt --no-substitutes
  976. sync
  977. reboot\n")
  978. (define %test-f2fs-root-os
  979. (system-test
  980. (name "f2fs-root-os")
  981. (description
  982. "Test basic functionality of an OS installed like one would do by hand.
  983. This test is expensive in terms of CPU and storage usage since we need to
  984. build (current-guix) and then store a couple of full system images.")
  985. (value
  986. (mlet* %store-monad ((image (run-install %f2fs-root-os
  987. %f2fs-root-os-source
  988. #:script
  989. %f2fs-root-installation-script))
  990. (command (qemu-command/writable-image image)))
  991. (run-basic-test %f2fs-root-os command "f2fs-root-os")))))
  992. ;;;
  993. ;;; Installation through the graphical interface.
  994. ;;;
  995. (define %syslog-conf
  996. ;; Syslog configuration that dumps to /dev/console, so we can see the
  997. ;; installer's messages during the test.
  998. (computed-file "syslog.conf"
  999. #~(begin
  1000. (copy-file #$%default-syslog.conf #$output)
  1001. (chmod #$output #o644)
  1002. (let ((port (open-file #$output "a")))
  1003. (display "\n*.info /dev/console\n" port)
  1004. #t))))
  1005. (define (operating-system-with-console-syslog os)
  1006. "Return OS with a syslog service that writes to /dev/console."
  1007. (operating-system
  1008. (inherit os)
  1009. (services (modify-services (operating-system-user-services os)
  1010. (syslog-service-type config
  1011. =>
  1012. (syslog-configuration
  1013. (inherit config)
  1014. (config-file %syslog-conf)))))))
  1015. (define %root-password "foo")
  1016. (define* (gui-test-program marionette
  1017. #:key
  1018. (desktop? #f)
  1019. (encrypted? #f))
  1020. #~(let ()
  1021. (define (screenshot file)
  1022. (marionette-control (string-append "screendump " file)
  1023. #$marionette))
  1024. (define-syntax-rule (marionette-eval* exp marionette)
  1025. (or (marionette-eval exp marionette)
  1026. (throw 'marionette-eval-failure 'exp)))
  1027. (setvbuf (current-output-port) 'none)
  1028. (setvbuf (current-error-port) 'none)
  1029. (marionette-eval* '(use-modules (gnu installer tests))
  1030. #$marionette)
  1031. ;; Arrange so that 'converse' prints debugging output to the console.
  1032. (marionette-eval* '(let ((console (open-output-file "/dev/console")))
  1033. (setvbuf console 'none)
  1034. (conversation-log-port console))
  1035. #$marionette)
  1036. ;; Tell the installer to not wait for the Connman "online" status.
  1037. (marionette-eval* '(call-with-output-file "/tmp/installer-assume-online"
  1038. (const #t))
  1039. #$marionette)
  1040. ;; Run 'guix system init' with '--no-grafts', to cope with the lack of
  1041. ;; network access.
  1042. (marionette-eval* '(call-with-output-file
  1043. "/tmp/installer-system-init-options"
  1044. (lambda (port)
  1045. (write '("--no-grafts" "--no-substitutes")
  1046. port)))
  1047. #$marionette)
  1048. (marionette-eval* '(define installer-socket
  1049. (open-installer-socket))
  1050. #$marionette)
  1051. (screenshot "installer-start.ppm")
  1052. (marionette-eval* '(choose-locale+keyboard installer-socket)
  1053. #$marionette)
  1054. (screenshot "installer-locale.ppm")
  1055. ;; Choose the host name that the "basic" test expects.
  1056. (marionette-eval* '(enter-host-name+passwords installer-socket
  1057. #:host-name "liberigilo"
  1058. #:root-password
  1059. #$%root-password
  1060. #:users
  1061. '(("alice" "pass1")
  1062. ("bob" "pass2")))
  1063. #$marionette)
  1064. (screenshot "installer-services.ppm")
  1065. (marionette-eval* '(choose-services installer-socket
  1066. #:choose-desktop-environment?
  1067. (const #$desktop?)
  1068. #:choose-network-service?
  1069. (const #f))
  1070. #$marionette)
  1071. (screenshot "installer-partitioning.ppm")
  1072. (marionette-eval* '(choose-partitioning installer-socket
  1073. #:encrypted? #$encrypted?
  1074. #:passphrase #$%luks-passphrase)
  1075. #$marionette)
  1076. (screenshot "installer-run.ppm")
  1077. (marionette-eval* '(conclude-installation installer-socket)
  1078. #$marionette)
  1079. (sync)
  1080. #t))
  1081. (define %extra-packages
  1082. ;; Packages needed when installing with an encrypted root.
  1083. (list isc-dhcp
  1084. lvm2-static cryptsetup-static e2fsck/static
  1085. loadkeys-static))
  1086. (define installation-os-for-gui-tests
  1087. ;; Operating system that contains all of %EXTRA-PACKAGES, needed for the
  1088. ;; target OS, as well as syslog output redirected to the console so we can
  1089. ;; see what the installer is up to.
  1090. (marionette-operating-system
  1091. (operating-system
  1092. (inherit (operating-system-with-console-syslog
  1093. (operating-system-add-packages
  1094. (operating-system-with-current-guix
  1095. installation-os)
  1096. %extra-packages)))
  1097. (kernel-arguments '("console=ttyS0")))
  1098. #:imported-modules '((gnu services herd)
  1099. (gnu installer tests)
  1100. (guix combinators))))
  1101. (define* (installation-target-os-for-gui-tests
  1102. #:key (encrypted? #f))
  1103. (operating-system
  1104. (inherit %minimal-os-on-vda)
  1105. (users (append (list (user-account
  1106. (name "alice")
  1107. (comment "Bob's sister")
  1108. (group "users")
  1109. (supplementary-groups
  1110. '("wheel" "audio" "video")))
  1111. (user-account
  1112. (name "bob")
  1113. (comment "Alice's brother")
  1114. (group "users")
  1115. (supplementary-groups
  1116. '("wheel" "audio" "video"))))
  1117. %base-user-accounts))
  1118. ;; The installer does not create a swap device in guided mode with
  1119. ;; encryption support.
  1120. (swap-devices (if encrypted? '() '("/dev/vda2")))
  1121. (services (cons (service dhcp-client-service-type)
  1122. (operating-system-user-services %minimal-os-on-vda)))))
  1123. (define* (installation-target-desktop-os-for-gui-tests
  1124. #:key (encrypted? #f))
  1125. (operating-system
  1126. (inherit (installation-target-os-for-gui-tests
  1127. #:encrypted? encrypted?))
  1128. (keyboard-layout (keyboard-layout "us" "altgr-intl"))
  1129. ;; Make sure that all the packages and services that may be used by the
  1130. ;; graphical installer are available.
  1131. (packages (append
  1132. (list openbox awesome i3-wm i3status
  1133. dmenu st ratpoison xterm)
  1134. %base-packages))
  1135. (services
  1136. (append
  1137. (list (service gnome-desktop-service-type)
  1138. (service xfce-desktop-service-type)
  1139. (service mate-desktop-service-type)
  1140. (service enlightenment-desktop-service-type)
  1141. (set-xorg-configuration
  1142. (xorg-configuration
  1143. (keyboard-layout keyboard-layout)))
  1144. (service marionette-service-type
  1145. (marionette-configuration
  1146. (imported-modules '((gnu services herd)
  1147. (guix build utils)
  1148. (guix combinators))))))
  1149. %desktop-services))))
  1150. (define* (guided-installation-test name
  1151. #:key
  1152. (desktop? #f)
  1153. (encrypted? #f)
  1154. target-os
  1155. (install-size 'guess)
  1156. (target-size (* 2200 MiB)))
  1157. (system-test
  1158. (name name)
  1159. (description
  1160. "Install an OS using the graphical installer and test it.")
  1161. (value
  1162. (mlet* %store-monad
  1163. ((image (run-install target-os '(this is unused)
  1164. #:script #f
  1165. #:os installation-os-for-gui-tests
  1166. #:install-size install-size
  1167. #:target-size target-size
  1168. #:installation-image-type
  1169. 'uncompressed-iso9660
  1170. #:gui-test
  1171. (lambda (marionette)
  1172. (gui-test-program
  1173. marionette
  1174. #:desktop? desktop?
  1175. #:encrypted? encrypted?))))
  1176. (command (qemu-command/writable-image image #:memory-size 512)))
  1177. (run-basic-test target-os command name
  1178. #:initialization (and encrypted? enter-luks-passphrase)
  1179. #:root-password %root-password
  1180. #:desktop? desktop?)))))
  1181. (define %test-gui-installed-os
  1182. (guided-installation-test
  1183. "gui-installed-os"
  1184. #:target-os (installation-target-os-for-gui-tests)))
  1185. (define %test-gui-installed-os-encrypted
  1186. (guided-installation-test
  1187. "gui-installed-os-encrypted"
  1188. #:encrypted? #t
  1189. #:target-os (installation-target-os-for-gui-tests
  1190. #:encrypted? #t)))
  1191. ;; Building a desktop image is very time and space consuming. Install all
  1192. ;; desktop environments in a single test to reduce the overhead.
  1193. (define %test-gui-installed-desktop-os-encrypted
  1194. (guided-installation-test "gui-installed-desktop-os-encrypted"
  1195. #:desktop? #t
  1196. #:encrypted? #t
  1197. #:target-os
  1198. (installation-target-desktop-os-for-gui-tests
  1199. #:encrypted? #t)
  1200. ;; XXX: The disk-image size guess is too low. Use
  1201. ;; a constant value until this is fixed.
  1202. #:install-size (* 8000 MiB)
  1203. #:target-size (* 9000 MiB)))
  1204. ;;; install.scm ends here