From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46581) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doSUf-00034q-TF for guix-patches@gnu.org; Sun, 03 Sep 2017 06:51:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doSUb-0001oF-4z for guix-patches@gnu.org; Sun, 03 Sep 2017 06:51:09 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:36166) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1doSUa-0001ng-W9 for guix-patches@gnu.org; Sun, 03 Sep 2017 06:51:05 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1doSUZ-0004Q0-HN for guix-patches@gnu.org; Sun, 03 Sep 2017 06:51:04 -0400 Subject: [bug#28288] [PATCH 5/5] tests: Add test for installing from an ISO Image. Resent-Message-ID: From: Christopher Baines Date: Sun, 3 Sep 2017 11:50:41 +0100 Message-Id: <20170903105041.2925-5-mail@cbaines.net> In-Reply-To: <20170903105041.2925-1-mail@cbaines.net> References: <20170903105041.2925-1-mail@cbaines.net> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 28288@debbugs.gnu.org * gnu/tests/install.scm (%test-iso-image-installer): New variable. (run-install): Add #:installation-disk-image-file-system-type as a keyword argument. --- gnu/tests/install.scm | 110 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 99 insertions(+), 11 deletions(-) diff --git a/gnu/tests/install.scm b/gnu/tests/install.scm index 866bf885c..93c8a89cd 100644 --- a/gnu/tests/install.scm +++ b/gnu/tests/install.scm @@ -37,6 +37,7 @@ #:use-module (guix utils) #:export (%test-installed-os %test-installed-extlinux-os + %test-iso-image-installer %test-separate-store-os %test-separate-home-os %test-raid-root-os @@ -196,6 +197,7 @@ reboot\n") (kernel-arguments '("console=ttyS0"))) #:imported-modules '((gnu services herd) (guix combinators)))) + (installation-disk-image-file-system-type "ext4") (target-size (* 1200 MiB))) "Run SCRIPT (a shell script following the GuixSD installation procedure) in OS to install TARGET-OS. Return a VM image of TARGET-SIZE bytes containing @@ -213,7 +215,9 @@ packages defined in installation-os." (image (system-disk-image (operating-system-with-gc-roots os (list target)) - #:disk-image-size (* 1500 MiB)))) + #:disk-image-size (* 1500 MiB) + #:file-system-type + installation-disk-image-file-system-type))) (define install (with-imported-modules '((guix build utils) (gnu build marionette)) @@ -229,16 +233,25 @@ packages defined in installation-os." (define marionette (make-marionette - (cons (which #$(qemu-command system)) - (cons* "-no-reboot" "-m" "800" - "-drive" - (string-append "file=" #$image - ",if=virtio,readonly") - "-drive" - (string-append "file=" #$output ",if=virtio") - (if (file-exists? "/dev/kvm") - '("-enable-kvm") - '()))))) + `(,(which #$(qemu-command system)) + "-no-reboot" + "-m" "800" + #$@(cond + ((string=? "ext4" installation-disk-image-file-system-type) + `("-drive" + ,(file-append "file=" image + ",if=virtio,readonly"))) + ((string=? "iso9660" installation-disk-image-file-system-type) + `("-cdrom" ,image)) + (else + (error + "unsupported installation-disk-image-file-system-type:" + installation-disk-image-file-system-type))) + "-drive" + ,(string-append "file=" #$output ",if=virtio") + ,@(if (file-exists? "/dev/kvm") + '("-enable-kvm") + '())))) (pk 'uname (marionette-eval '(uname) marionette)) @@ -313,6 +326,81 @@ per %test-installed-os, this test is expensive in terms of CPU and storage.") "installed-extlinux-os"))))) +;;; +;;; Installation through an ISO image. +;;; + +(define-os-with-source (%minimal-os-on-vda %minimal-os-on-vda-source) + ;; The OS we want to install. + (use-modules (gnu) (gnu tests) (srfi srfi-1)) + + (operating-system + (host-name "liberigilo") + (timezone "Europe/Paris") + (locale "en_US.UTF-8") + + (bootloader (grub-configuration (target "/dev/vda"))) + (kernel-arguments '("console=ttyS0")) + (file-systems (cons (file-system + (device "my-root") + (title 'label) + (mount-point "/") + (type "ext4")) + %base-file-systems)) + (users (cons (user-account + (name "alice") + (comment "Bob's sister") + (group "users") + (supplementary-groups '("wheel" "audio" "video")) + (home-directory "/home/alice")) + %base-user-accounts)) + (services (cons (service marionette-service-type + (marionette-configuration + (imported-modules '((gnu services herd) + (guix combinators))))) + %base-services)))) + +(define %simple-installation-script-for-/dev/vda + ;; Shell script of a simple installation. + "\ +. /etc/profile +set -e -x +guix --version + +export GUIX_BUILD_OPTIONS=--no-grafts +guix build isc-dhcp +parted --script /dev/vda mklabel gpt \\ + mkpart primary ext2 1M 3M \\ + mkpart primary ext2 3M 1G \\ + set 1 boot on \\ + set 1 bios_grub on +mkfs.ext4 -L my-root /dev/vda2 +mount /dev/vda2 /mnt +df -h /mnt +herd start cow-store /mnt +mkdir /mnt/etc +cp /etc/target-config.scm /mnt/etc/config.scm +guix system init /mnt/etc/config.scm /mnt --no-substitutes +sync +reboot\n") + +(define %test-iso-image-installer + (system-test + (name "iso-image-installer") + (description + "") + (value + (mlet* %store-monad ((image (run-install + %minimal-os-on-vda + %minimal-os-on-vda-source + #:script + %simple-installation-script-for-/dev/vda + #:installation-disk-image-file-system-type + "iso9660")) + (command (qemu-command/writable-image image))) + (run-basic-test %minimal-os-on-vda command name))))) + + ;;; ;;; Separate /home. ;;; -- 2.14.1