From: Mathieu Othacehe <m.othacehe@gmail.com>
To: 42634@debbugs.gnu.org
Cc: Mathieu Othacehe <othacehe@gnu.org>
Subject: [bug#42634] [PATCH 3/3] scripts: system: Add support for image-type.
Date: Fri, 31 Jul 2020 16:49:29 +0200 [thread overview]
Message-ID: <20200731144929.703345-3-othacehe@gnu.org> (raw)
In-Reply-To: <20200731144929.703345-1-othacehe@gnu.org>
* guix/scripts/system.scm (list-image-types): New procedure,
(%options): add "image-type" and "list-image-types" options, remove
"file-system-type" option,
(show-help): adapt accordingly,
(%default-options): also adapt, and set the default "image-type" to "raw",
(perform-action): add image-type argument and remove file-system-type argument,
(process-action): adapt perform-action call,
(system-derivation-for-action): remove base-image
argument, add image-type argument, and use it to create the image passed to
"system-image".
---
guix/scripts/system.scm | 56 +++++++++++++++++++++++++----------------
1 file changed, 35 insertions(+), 21 deletions(-)
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index bfd50c7a79..4962401f36 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -659,8 +659,8 @@ checking this by themselves in their 'check' procedure."
;;; Action.
;;;
-(define* (system-derivation-for-action os base-image action
- #:key image-size file-system-type
+(define* (system-derivation-for-action os action
+ #:key image-size image-type
full-boot? container-shared-network?
mappings)
"Return as a monadic value the derivation for OS according to ACTION."
@@ -686,9 +686,8 @@ checking this by themselves in their 'check' procedure."
(lower-object
(system-image
(image
- (inherit base-image)
- (size image-size)
- (operating-system os)))))
+ (inherit (os->image os #:type image-type))
+ (size image-size)))))
((docker-image)
(system-docker-image os #:shared-network? container-shared-network?))))
@@ -741,16 +740,17 @@ and TARGET arguments."
install-bootloader?
dry-run? derivations-only?
use-substitutes? bootloader-target target
- image-size file-system-type full-boot?
- container-shared-network?
+ image-size image-type
+ full-boot? container-shared-network?
(mappings '())
(gc-root #f))
"Perform ACTION for OS. INSTALL-BOOTLOADER? specifies whether to install
bootloader; BOOTLOADER-TAGET is the target for the bootloader; TARGET is the
target root directory; IMAGE-SIZE is the size of the image to be built, for
-the 'vm-image' and 'disk-image' actions. The root file system is created as a
-FILE-SYSTEM-TYPE file system. FULL-BOOT? is used for the 'vm' action; it
-determines whether to boot directly to the kernel or to the bootloader.
+the 'vm-image' and 'disk-image' actions. IMAGE-TYPE is the type of image to
+be built.
+FULL-BOOT? is used for the 'vm' action; it determines whether to boot directly
+to the kernel or to the bootloader.
CONTAINER-SHARED-NETWORK? determines if the container will use a separate
network namespace.
@@ -792,10 +792,8 @@ static checks."
(check-initrd-modules os)))
(mlet* %store-monad
- ((target* (current-target-system))
- (image -> (find-image file-system-type target*))
- (sys (system-derivation-for-action os image action
- #:file-system-type file-system-type
+ ((sys (system-derivation-for-action os action
+ #:image-type image-type
#:image-size image-size
#:full-boot? full-boot?
#:container-shared-network? container-shared-network?
@@ -876,6 +874,17 @@ upgrade, and restart each service that was not automatically restarted.\n"))))))
#:node-type (shepherd-service-node-type shepherds)
#:reverse-edges? #t)))
+\f
+;;;
+;;; Images.
+;;;
+
+(define (list-image-types)
+ "Print the available image types."
+ (display (G_ "The available image types are:\n"))
+ (newline)
+ (format #t "~{ - ~a ~%~}" (map image-type-name (force %image-types))))
+
\f
;;;
;;; Options.
@@ -935,9 +944,9 @@ Some ACTIONS support additional ARGS.\n"))
apply STRATEGY (one of nothing-special, backtrace,
or debug) when an error occurs while reading FILE"))
(display (G_ "
- --file-system-type=TYPE
- for 'disk-image', produce a root file system of TYPE
- (one of 'ext4', 'iso9660')"))
+ --list-image-types list available image types"))
+ (display (G_ "
+ -t, --image-type=TYPE for 'disk-image', produce an image of TYPE"))
(display (G_ "
--image-size=SIZE for 'vm-image', produce an image of SIZE"))
(display (G_ "
@@ -994,10 +1003,14 @@ Some ACTIONS support additional ARGS.\n"))
(lambda (opt name arg result)
(alist-cons 'on-error (string->symbol arg)
result)))
- (option '(#\t "file-system-type") #t #f
+ (option '(#\t "image-type") #t #f
(lambda (opt name arg result)
- (alist-cons 'file-system-type arg
+ (alist-cons 'image-type arg
result)))
+ (option '("list-image-types") #f #f
+ (lambda (opt name arg result)
+ (list-image-types)
+ (exit 0)))
(option '("image-size") #t #f
(lambda (opt name arg result)
(alist-cons 'image-size (size->number arg)
@@ -1063,7 +1076,7 @@ Some ACTIONS support additional ARGS.\n"))
(debug . 0)
(verbosity . #f) ;default
(validate-reconfigure . ,ensure-forward-reconfigure)
- (file-system-type . "ext4")
+ (image-type . "raw")
(image-size . guess)
(install-bootloader? . #t)))
@@ -1150,7 +1163,8 @@ resulting from command-line parsing."
(assoc-ref opts 'skip-safety-checks?)
#:validate-reconfigure
(assoc-ref opts 'validate-reconfigure)
- #:file-system-type (assoc-ref opts 'file-system-type)
+ #:image-type (lookup-image-type-by-name
+ (assoc-ref opts 'image-type))
#:image-size (assoc-ref opts 'image-size)
#:full-boot? (assoc-ref opts 'full-boot?)
#:container-shared-network?
--
2.26.2
next prev parent reply other threads:[~2020-07-31 14:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-31 14:48 [bug#42634] [PATCH 0/3] Add image-type support Mathieu Othacehe
2020-07-31 14:49 ` [bug#42634] [PATCH 1/3] image: " Mathieu Othacehe
2020-07-31 14:49 ` [bug#42634] [PATCH 2/3] system: " Mathieu Othacehe
2020-09-24 15:37 ` Ludovic Courtès
2020-07-31 14:49 ` Mathieu Othacehe [this message]
2020-09-24 15:39 ` [bug#42634] [PATCH 3/3] scripts: system: Add support for image-type Ludovic Courtès
2020-09-30 9:51 ` bug#42634: " Mathieu Othacehe
2020-09-24 15:35 ` [bug#42634] [PATCH 1/3] image: Add image-type support Ludovic Courtès
2020-09-24 15:34 ` [bug#42634] [PATCH 0/3] " Ludovic Courtès
2020-09-30 9:50 ` Mathieu Othacehe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200731144929.703345-3-othacehe@gnu.org \
--to=m.othacehe@gmail.com \
--cc=42634@debbugs.gnu.org \
--cc=othacehe@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).