From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39525) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dRgI7-0000d7-OD for guix-patches@gnu.org; Sun, 02 Jul 2017 10:56:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dRgI6-0004sC-N9 for guix-patches@gnu.org; Sun, 02 Jul 2017 10:56:03 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:46210) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dRgI6-0004ro-Je for guix-patches@gnu.org; Sun, 02 Jul 2017 10:56:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dRgI6-0004to-9c for guix-patches@gnu.org; Sun, 02 Jul 2017 10:56:02 -0400 Subject: [bug#27521] [PATCH v5] build: Add iso9660 system image generator. Resent-Message-ID: From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) References: <20170629020954.22464-1-dannym@scratchpost.org> <20170629134707.12576-1-dannym@scratchpost.org> Date: Sun, 02 Jul 2017 16:55:47 +0200 In-Reply-To: <20170629134707.12576-1-dannym@scratchpost.org> (Danny Milosavljevic's message of "Thu, 29 Jun 2017 15:47:07 +0200") Message-ID: <87bmp299cc.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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: Danny Milosavljevic Cc: 27521@debbugs.gnu.org Hi Danny, Danny Milosavljevic skribis: > * build-aux/hydra/gnu-system.scm (qemu-jobs): Add 'iso9660-image . > * guix/script/system.scm: Add "iso9660-disk-image" action. > * gnu/build/vm.scm (make-iso9660-image): New variable. Export it. > * gnu/system/vm.scm (iso9660-image): New variable. Use make-iso9660-imag= e. > (system-disk-image): Use iso9660-image. This all sounds like excellent news! (BTW it=E2=80=99s funny to see new versions of this patch set come in regul= arly; at least it acts as a reminder. ;-)) > --- a/gnu/build/vm.scm > +++ b/gnu/build/vm.scm > @@ -48,7 +48,8 @@ >=20=20 > root-partition-initializer > initialize-partition-table > - initialize-hard-disk)) > + initialize-hard-disk > + make-iso9660-image)) >=20=20 > ;;; Commentary: > ;;; > @@ -344,6 +345,20 @@ SYSTEM-DIRECTORY is the name of the directory of the= 'system' derivation." > (string-append "boot/grub/grub.cfg=3D" confi= g-file))) > (error "failed to create GRUB EFI image")))) >=20=20 > +(define (make-iso9660-image grub config-file os-drv target) > + "Given a GRUB package, creates an iso image as TARGET, using CONFIG-FI= LE as > +Grub configuration and OS-DRV as the stuff in it." > + (let ((grub-mkrescue (string-append grub "/bin/grub-mkrescue"))) > + (mkdir-p "/tmp/root/var/run") > + (mkdir-p "/tmp/root/run") > + (unless (zero? (system* grub-mkrescue "-o" target > + (string-append "boot/grub/grub.cfg=3D" confi= g-file) > + (string-append "gnu/store=3D" os-drv "/..") > + "var=3D/tmp/root/var" > + "run=3D/tmp/root/run" > + "--" "-volid" "GUIXSD")) Let=E2=80=99s add #:key (volume-id "GuixSD") and then: "--" "-volid" (string-upcase volume-id) > diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm > index 392737d07..5a865d24b 100644 > --- a/gnu/system/vm.scm > +++ b/gnu/system/vm.scm > @@ -34,6 +34,7 @@ > #:select (qemu-command)) > #:use-module (gnu packages base) > #:use-module (gnu packages bootloaders) > + #:use-module (gnu packages cdrom) > #:use-module (gnu packages guile) > #:use-module (gnu packages gawk) > #:use-module (gnu packages bash) > @@ -170,6 +171,51 @@ made available under the /xchg CIFS share." > #:guile-for-build guile-for-build > #:references-graphs references-graphs))) >=20=20 > +(define* (iso9660-image #:key > + (name "iso9660-image") > + (system (%current-system)) > + (qemu qemu-minimal) > + os-drv > + bootcfg-drv > + bootloader > + (inputs '())) > + "Return a bootable, stand-alone iso9660 image. > + > +INPUTS is a list of inputs (as for packages)." > + (expression->derivation-in-linux-vm > + name > + (with-imported-modules (source-module-closure '((gnu build vm) > + (guix build utils))) > + #~(begin > + (use-modules (gnu build vm) > + (guix build utils)) > + > + (let ((inputs > + '#$(append (list qemu parted e2fsprogs dosfstools xorris= o) > + (map canonical-package > + (list sed grep coreutils findutils gawk)= ))) > + > + ;; This variable is unused but allows us to add INPUTS-TO= -COPY > + ;; as inputs. > + (to-register > + '#$(map (match-lambda > + ((name thing) thing) > + ((name thing output) `(,thing ,output))) > + inputs))) > + > + (set-path-environment-variable "PATH" '("bin" "sbin") inputs) > + (mkdir-p "/tmp") > + ;(mount "none" "/tmp" "tmpfs") > + ;(mkdir-p "/tmp/extra") > + (make-iso9660-image #$(bootloader-package bootloader) > + #$bootcfg-drv > + #$os-drv > + "/xchg/guixsd.iso") > + (reboot)))) > + #:system system > + #:make-disk-image? #f > + #:references-graphs inputs)) Since this doesn=E2=80=99t have much to do with VMs, what about adding these things to (gnu system iso9660) and (gnu build iso9660)? They may have to use procedure from the =E2=80=98vm=E2=80=99 modules, but t= hat=E2=80=99s OK. > (define* (qemu-image #:key > (name "qemu-image") > (system (%current-system)) > @@ -308,19 +354,30 @@ to USB sticks meant to be read-only." >=20=20 > (mlet* %store-monad ((os-drv (operating-system-derivation os)) > (bootcfg (operating-system-bootcfg os))) > - (qemu-image #:name name > - #:os-drv os-drv > - #:bootcfg-drv bootcfg > - #:bootloader (bootloader-configuration-bootloader > - (operating-system-bootloader os)) > - #:disk-image-size disk-image-size > - #:disk-image-format "raw" > - #:file-system-type file-system-type > - #:file-system-label root-label > - #:copy-inputs? #t > - #:register-closures? #t > - #:inputs `(("system" ,os-drv) > - ("bootcfg" ,bootcfg)))))) > + (if (string=3D? "iso9660" file-system-type) > + (iso9660-image #:name name > + #:os-drv os-drv > + #:bootcfg-drv bootcfg > + #:bootloader (bootloader-configuration-bootload= er > + (operating-system-bootloader os)) > + #:inputs `(("system" ,os-drv) > + ("bootcfg" ,bootcfg))) > + (qemu-image #:name name We can also remove this =E2=80=98if=E2=80=99: it=E2=80=99s not natural for = =E2=80=98qemu-image=E2=80=99 to produce something that=E2=80=99s not a =E2=80=9CQEMU image.=E2=80=9D Could you update =E2=80=9CInvoking guix system=E2=80=9D accordingly? We could add a installation test that boots from an ISO image, but we can do that later if you want. Thank you! Ludo=E2=80=99.