From 0996fcc657593955845c2761d7eb0f656149fe11 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Sat, 19 Sep 2020 14:24:59 +0200 Subject: system: image: Rename ISO9660 files. * gnu/system/image.scm (system-iso9660-image): Change the default file output name to "image.iso". --- gnu/system/image.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gnu/system/image.scm') diff --git a/gnu/system/image.scm b/gnu/system/image.scm index 97c7021454..49cdd9e7de 100644 --- a/gnu/system/image.scm +++ b/gnu/system/image.scm @@ -340,7 +340,7 @@ image ~a { (define* (system-iso9660-image image #:key - (name "iso9660-image") + (name "image.iso") bootcfg bootloader register-closures? -- cgit v1.2.3 From f441e3e8b5fbc2406fa924d3761774bbd50cc683 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Tue, 29 Sep 2020 11:37:19 +0200 Subject: image: Add support for compressed-qcow2 format. * gnu/build/image.scm (convert-disk-image): New procedure. (genimage): Remove target argument. * gnu/system/image.scm (system-disk-image): Add support for 'compressed-qcow2 image format. Call "convert-disk-image" to apply image conversions on the final image. Add "qemu-minimal" to the build inputs. (system-image): Also add support for 'compressed-qcow2. --- gnu/build/image.scm | 16 +++++++++++++--- gnu/system/image.scm | 30 ++++++++++++++++-------------- 2 files changed, 29 insertions(+), 17 deletions(-) (limited to 'gnu/system/image.scm') diff --git a/gnu/build/image.scm b/gnu/build/image.scm index d8efa73f16..8a2d0eb5fd 100644 --- a/gnu/build/image.scm +++ b/gnu/build/image.scm @@ -37,6 +37,7 @@ #:use-module (srfi srfi-34) #:use-module (srfi srfi-35) #:export (make-partition-image + convert-disk-image genimage initialize-efi-partition initialize-root-partition @@ -120,13 +121,22 @@ ROOT directory to populate the image." (format (current-error-port) "Unsupported partition type~%."))))) -(define* (genimage config target) +(define (convert-disk-image image format output) + "Convert IMAGE to OUTPUT according to the given FORMAT." + (case format + ((compressed-qcow2) + (begin + (invoke "qemu-img" "convert" "-c" "-f" "raw" + "-O" "qcow2" image output))) + (else + (copy-file image output)))) + +(define* (genimage config) "Use genimage to generate in TARGET directory, the image described in the given CONFIG file." ;; genimage needs a 'root' directory. (mkdir "root") - (invoke "genimage" "--config" config - "--outputpath" target)) + (invoke "genimage" "--config" config)) (define* (register-closure prefix closure #:key diff --git a/gnu/system/image.scm b/gnu/system/image.scm index 49cdd9e7de..0f2fb62a6b 100644 --- a/gnu/system/image.scm +++ b/gnu/system/image.scm @@ -47,11 +47,13 @@ #:use-module (gnu packages hurd) #:use-module (gnu packages linux) #:use-module (gnu packages mtools) + #:use-module (gnu packages virtualization) #:use-module ((srfi srfi-1) #:prefix srfi-1:) #:use-module (srfi srfi-11) #:use-module (srfi srfi-26) #:use-module (srfi srfi-35) #:use-module (rnrs bytevectors) + #:use-module (ice-9 format) #:use-module (ice-9 match) #:export (root-offset root-label @@ -207,8 +209,8 @@ used in the image." (define (format->image-type format) ;; Return the genimage format corresponding to FORMAT. For now, only ;; the hdimage format (raw disk-image) is supported. - (case format - ((disk-image) "hdimage") + (cond + ((memq format '(disk-image compressed-qcow2)) "hdimage") (else (raise (condition (&message @@ -306,25 +308,24 @@ image ~a { (name (if image-name (symbol->string image-name) name)) + (format (image-format image)) (substitutable? (image-substitutable? image)) (builder (with-imported-modules* - (let ((inputs '#+(list genimage coreutils findutils)) + (let ((inputs '#+(list genimage coreutils findutils qemu-minimal)) (bootloader-installer - #+(bootloader-disk-image-installer bootloader))) + #+(bootloader-disk-image-installer bootloader)) + (out-image (string-append "images/" #$genimage-name))) (set-path-environment-variable "PATH" '("bin" "sbin") inputs) - (genimage #$(image->genimage-cfg image) #$output) + (genimage #$(image->genimage-cfg image)) ;; Install the bootloader directly on the disk-image. (when bootloader-installer (bootloader-installer #+(bootloader-package bootloader) #$(root-partition-index image) - (string-append #$output "/" #$genimage-name)))))) - (image-dir (computed-file "image-dir" builder))) - (computed-file name - #~(symlink - (string-append #$image-dir "/" #$genimage-name) - #$output) + out-image)) + (convert-disk-image out-image '#$format #$output))))) + (computed-file name builder #:options `(#:substitutable? ,substitutable?)))) @@ -523,19 +524,20 @@ image, depending on IMAGE format." (with-parameters ((%current-target-system target)) (let* ((os (operating-system-for-image image)) (image* (image-with-os image os)) + (image-format (image-format image)) (register-closures? (has-guix-service-type? os)) (bootcfg (operating-system-bootcfg os)) (bootloader (bootloader-configuration-bootloader (operating-system-bootloader os)))) - (case (image-format image) - ((disk-image) + (cond + ((memq image-format '(disk-image compressed-qcow2)) (system-disk-image image* #:bootcfg bootcfg #:bootloader bootloader #:register-closures? register-closures? #:inputs `(("system" ,os) ("bootcfg" ,bootcfg)))) - ((iso9660) + ((memq image-format '(iso9660)) (system-iso9660-image image* #:bootcfg bootcfg -- cgit v1.2.3 From 10b135cef54348e48805bd9c64b463c465c65eb5 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Fri, 31 Jul 2020 16:49:28 +0200 Subject: system: image: Add image-type support. * gnu/system/image.scm (image-with-os): New macro. Rename the old "image-with-os" procedure to ... (image-with-os*): ... this new procedure, (system-image): adapt according, (raw-image-type, iso-image-type, uncompressed-iso-image-type %image-types): new variables, (lookup-image-type-by-name): new procedure. (find-image): remove it. * gnu/system/images/hurd.scm (hurd-image-type): New variable, use it to define ... (hurd-disk-image): ... this variable, using "os->image" procedure. * gnu/tests/install.scm (run-install): Rename installation-disk-image-file-system-type parameter to installation-image-type, use os->config instead of find-image to compute the image passed to system-image, (%test-iso-image-installer) adapt accordingly, (guided-installation-test): ditto. Signed-off-by: Mathieu Othacehe --- gnu/system/image.scm | 90 +++++++++++++++++++++++++++++++++++++--------- gnu/system/images/hurd.scm | 29 +++++++++++---- gnu/tests/install.scm | 46 ++++++++++++------------ 3 files changed, 118 insertions(+), 47 deletions(-) (limited to 'gnu/system/image.scm') diff --git a/gnu/system/image.scm b/gnu/system/image.scm index 0f2fb62a6b..c81054f847 100644 --- a/gnu/system/image.scm +++ b/gnu/system/image.scm @@ -18,6 +18,8 @@ ;;; along with GNU Guix. If not, see . (define-module (gnu system image) + #:use-module (guix diagnostics) + #:use-module (guix discovery) #:use-module (guix gexp) #:use-module (guix modules) #:use-module (guix monads) @@ -64,9 +66,16 @@ efi-disk-image iso9660-image - find-image + image-with-os + raw-image-type + iso-image-type + uncompressed-iso-image-type + + image-with-label system-image - image-with-label)) + + %image-types + lookup-image-type-by-name)) ;;; @@ -113,6 +122,37 @@ (label "GUIX_IMAGE") (flags '(boot))))))) + +;;; +;;; Images types. +;;; + +(define-syntax-rule (image-with-os base-image os) + "Return an image inheriting from BASE-IMAGE, with the operating-system field +set to the given OS." + (image + (inherit base-image) + (operating-system os))) + +(define raw-image-type + (image-type + (name 'raw) + (constructor (cut image-with-os efi-disk-image <>)))) + +(define iso-image-type + (image-type + (name 'iso9660) + (constructor (cut image-with-os iso9660-image <>)))) + +(define uncompressed-iso-image-type + (image-type + (name 'uncompressed-iso9660) + (constructor (cut image-with-os + (image + (inherit iso9660-image) + (compression? #f)) + <>)))) + ;; ;; Helpers. @@ -442,7 +482,7 @@ returns an image record where the first partition's label is set to