From e871c3a857005c2c55fcbf4dbd48e22fe33b6451 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 1 Jul 2022 09:42:53 +0200 Subject: image: 'system-image' throws when given an incorrect image format. Previously 'system-image' would return *unspecified* in that case, leading to a wrong-type-arg error crash down the road. * gnu/system/image.scm (system-image): Add 'else' clause. --- gnu/system/image.scm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'gnu/system') diff --git a/gnu/system/image.scm b/gnu/system/image.scm index 5972a944d7..f1739a35c1 100644 --- a/gnu/system/image.scm +++ b/gnu/system/image.scm @@ -842,7 +842,10 @@ (define target (cond ;; This happens if some limits are exceeded, see: ;; https://lists.gnu.org/archive/html/grub-devel/2020-06/msg00048.html #:grub-mkrescue-environment - '(("MKRESCUE_SED_MODE" . "mbr_only")))))))) + '(("MKRESCUE_SED_MODE" . "mbr_only")))) + (else + (raise (formatted-message + (G_ "~a: unsupported image format") image-format))))))) ;; -- cgit v1.2.3 From 9f530ef38a23caa1136f93cda45d396ce8fe1569 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 1 Jul 2022 10:26:17 +0200 Subject: image: Add default value for partition initializer. Previously, the default value would lead to a wrong-type-to-apply crash. * gnu/system/image.scm (system-disk-image)[image-builder]: When 'partition-initializer' returns #f, fall back to INITIALIZE-ROOT-PARTITION. * gnu/tests/base.scm (run-root-unmount-test)[test-image]: Remove 'initializer' field of partition. * gnu/image.scm ()[initializer]: Add comment. --- gnu/image.scm | 2 +- gnu/system/image.scm | 3 ++- gnu/tests/base.scm | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'gnu/system') diff --git a/gnu/image.scm b/gnu/image.scm index e10a495d3d..e347089b34 100644 --- a/gnu/image.scm +++ b/gnu/image.scm @@ -70,7 +70,7 @@ (define-record-type* partition make-partition (label partition-label (default #f)) (uuid partition-uuid (default #f)) (flags partition-flags (default '())) - (initializer partition-initializer (default #f))) + (initializer partition-initializer (default #f))) ;gexp | #f ;;; diff --git a/gnu/system/image.scm b/gnu/system/image.scm index f1739a35c1..60ae38f6d8 100644 --- a/gnu/system/image.scm +++ b/gnu/system/image.scm @@ -374,7 +374,8 @@ (define (partition-image partition) (type (partition-file-system partition)) (image-builder (with-imported-modules* - (let ((initializer #$(partition-initializer partition)) + (let ((initializer (or #$(partition-initializer partition) + initialize-root-partition)) (inputs '#+(list e2fsprogs fakeroot dosfstools mtools)) (image-root "tmp-root")) (sql-schema #$schema) diff --git a/gnu/tests/base.scm b/gnu/tests/base.scm index 8284446868..353d6d415a 100644 --- a/gnu/tests/base.scm +++ b/gnu/tests/base.scm @@ -637,7 +637,6 @@ (define test-image (size 'guess) (offset (* 512 2048)) ;leave room for GRUB (flags '(boot)) - (initializer #~initialize-root-partition) (label "root-under-test")))))) ;max 16 characters! (define observer-os -- cgit v1.2.3 From ed19bc87e4234144a05040aae75aee9a57e71f9b Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 1 Jul 2022 10:33:51 +0200 Subject: image: Avoid use of the deprecated 'gpt' option of genimage. * gnu/system/image.scm (system-disk-image)[genimage-type-options]: Use 'partition-table-type' instead of the deprecated 'gpt' option. --- gnu/system/image.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gnu/system') diff --git a/gnu/system/image.scm b/gnu/system/image.scm index 60ae38f6d8..e6e6917ecd 100644 --- a/gnu/system/image.scm +++ b/gnu/system/image.scm @@ -445,8 +445,8 @@ (define (partition->config image partition) (define (genimage-type-options image-type image) (cond ((equal? image-type "hdimage") - (format #f "~%~/~/gpt = ~a~%~/" - (if (gpt-image? image) "true" "false"))) + (format #f "~%~/~/partition-table-type = \"~a\"~%~/" + (image-partition-table-type image))) (else ""))) (let* ((format (image-format image)) -- cgit v1.2.3 From 05a759ab36c66e6336cdcf9f04ecc9e6e8e29dc2 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 1 Jul 2022 10:38:37 +0200 Subject: image: Raise an error when an image lacks a bootable partition. * gnu/system/image.scm (find-root-partition): Raise an error when 'find' returns #f. --- gnu/system/image.scm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'gnu/system') diff --git a/gnu/system/image.scm b/gnu/system/image.scm index e6e6917ecd..42c2e6c121 100644 --- a/gnu/system/image.scm +++ b/gnu/system/image.scm @@ -275,7 +275,9 @@ (define (root-partition? partition) (define (find-root-partition image) "Return the root partition of the given IMAGE." - (srfi-1:find root-partition? (image-partitions image))) + (or (srfi-1:find root-partition? (image-partitions image)) + (raise (formatted-message + (G_ "image lacks a partition with the 'boot' flag"))))) (define (root-partition-index image) "Return the index of the root partition of the given IMAGE." -- cgit v1.2.3