install.scm 75 KB

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