summary refs log tree commit diff
path: root/gnu/build/image.scm
diff options
context:
space:
mode:
authorMathieu Othacehe <othacehe@gnu.org>2020-09-29 11:37:19 +0200
committerMathieu Othacehe <othacehe@gnu.org>2020-09-29 11:42:52 +0200
commitf441e3e8b5fbc2406fa924d3761774bbd50cc683 (patch)
tree83442b571f049d2142f006b893ac2949c34c9c1f /gnu/build/image.scm
parentc4d3eb569ca08776895c15d3bd38a34c8c37a68a (diff)
downloadguix-f441e3e8b5fbc2406fa924d3761774bbd50cc683.tar.gz
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.
Diffstat (limited to 'gnu/build/image.scm')
-rw-r--r--gnu/build/image.scm16
1 files changed, 13 insertions, 3 deletions
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