From patchwork Wed Sep 7 12:46:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Othacehe X-Patchwork-Id: 42266 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id BB5E627BBEA; Wed, 7 Sep 2022 13:48:31 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 2E92427BBE9 for ; Wed, 7 Sep 2022 13:48:31 +0100 (BST) Received: from localhost ([::1]:48392 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oVuTm-0005hq-Ar for patchwork@mira.cbaines.net; Wed, 07 Sep 2022 08:48:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44852) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVuTL-0005g5-HS for guix-patches@gnu.org; Wed, 07 Sep 2022 08:48:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:36973) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oVuTL-00077p-9N for guix-patches@gnu.org; Wed, 07 Sep 2022 08:48:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oVuTL-0002Y6-5A for guix-patches@gnu.org; Wed, 07 Sep 2022 08:48:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57643] [PATCH 1/3] image: Make the operating-system field mandatory. References: <20220907124449.16904-1-othacehe@gnu.org> In-Reply-To: <20220907124449.16904-1-othacehe@gnu.org> Resent-From: Mathieu Othacehe Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 07 Sep 2022 12:48:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57643 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 57643@debbugs.gnu.org Cc: Mathieu Othacehe Received: via spool by 57643-submit@debbugs.gnu.org id=B57643.16625548399634 (code B ref 57643); Wed, 07 Sep 2022 12:48:03 +0000 Received: (at 57643) by debbugs.gnu.org; 7 Sep 2022 12:47:19 +0000 Received: from localhost ([127.0.0.1]:53882 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oVuSc-0002VI-GE for submit@debbugs.gnu.org; Wed, 07 Sep 2022 08:47:18 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34746) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oVuSb-0002V4-Ge for 57643@debbugs.gnu.org; Wed, 07 Sep 2022 08:47:17 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:53462) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVuSV-00071d-VK for 57643@debbugs.gnu.org; Wed, 07 Sep 2022 08:47:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to: references; bh=RChMoL0UAs9OfUYL8vjxUsMfC9FGFwSxE8zQ/5AZ+1k=; b=mwBh0WucMEimlW 60i1rTgRMLkjuipRmNIdDXgyuCHlfJthiUpQeMeqppm74PVDpI7ihBafg3lpF81ImpN5Z4XLswuka zlNYx4eUh/y9ayrM80XwmddDRP/26y3y8M+1E6oDcNzyiLOVku5E7FPvNbJ0JoK2av2/4pEehkZUL ceTjwGpdxj6AEOReSOz7xlHpAdD0f/PFDKrf9piRBA6t9z2Socc8kbWFhVI8fLTlCQH9yiYeqpp0l DperQHm0mt/8KYsleE7OI1isuHMKTPlr4Y/vf264O32PptTSb4F1TZUOcz5JH1JUWpo1Z59n53KPc S1ollqa7mJOujd44PtdQ==; Received: from ppp079167215024.access.hol.gr ([79.167.215.24]:46736 helo=localhost.localdomain) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oVuSV-0002jZ-ET; Wed, 07 Sep 2022 08:47:11 -0400 From: Mathieu Othacehe Date: Wed, 7 Sep 2022 14:46:31 +0200 Message-Id: <20220907124633.17013-1-othacehe@gnu.org> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Make the operating-system field mandatory as creating an image without it makes no sense. Introduce a new macro, image-without-os for the specific cases where the image is only created to be inherited from afterwards. * gnu/image.scm ()[operating-system]: Make it mandatory. * gnu/system/image.scm (image-without-os): New macro. (efi-disk-image, efi32-disk-image, iso9660-image, docker-image, raw-with-offset-disk-image): Use it. * gnu/system/images/hurd.scm (hurd-disk-image): Ditto. --- gnu/image.scm | 3 +-- gnu/system/image.scm | 41 +++++++++++++++++++++++++++++++++----- gnu/system/images/hurd.scm | 2 +- 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/gnu/image.scm b/gnu/image.scm index 4a0068934e..68784deb12 100644 --- a/gnu/image.scm +++ b/gnu/image.scm @@ -170,8 +170,7 @@ (define-record-type* (size image-size ;size in bytes as integer (default 'guess) (sanitize validate-size)) - (operating-system image-operating-system ; - (default #f)) + (operating-system image-operating-system) ; (partition-table-type image-partition-table-type ; 'mbr or 'gpt (default 'mbr) (sanitize validate-partition-table-type)) diff --git a/gnu/system/image.scm b/gnu/system/image.scm index a04363a130..709c3ab6ff 100644 --- a/gnu/system/image.scm +++ b/gnu/system/image.scm @@ -65,6 +65,7 @@ (define-module (gnu system image) #:use-module (ice-9 match) #:export (root-offset root-label + image-without-os esp-partition esp32-partition @@ -102,6 +103,36 @@ (define root-offset (* 512 2048)) ;; Generic root partition label. (define root-label "Guix_image") +(define-syntax image-without-os + (lambda (x) + "Return an image record with the mandatory operating-system field set to +#false. This is useful when creating an image record that will serve as a +parent image record." + + (define (maybe-cons field acc) + ;; Return the given ACC list if FIELD is 'operating-system or the + ;; concatenation of FIELD to ACC otherwise. + (syntax-case field () + ((f v) + (if (eq? (syntax->datum #'f) 'operating-system) + acc + (cons field acc))))) + + (syntax-case x (image) + ;; Remove the operating-system field from the defined fields and then + ;; force it to #false. + ((_ fields ...) + (let loop ((fields #'(fields ...)) + (acc '())) + (syntax-case fields () + ((last) + #`(image + ;; Force it to #false. + (operating-system #false) + #,@(maybe-cons #'last acc))) + ((field rest ...) + (loop #'(rest ...) (maybe-cons #'field acc))))))))) + (define esp-partition (partition (size (* 40 (expt 2 20))) @@ -127,17 +158,17 @@ (define root-partition (initializer (gexp initialize-root-partition)))) (define efi-disk-image - (image + (image-without-os (format 'disk-image) (partitions (list esp-partition root-partition)))) (define efi32-disk-image - (image + (image-without-os (format 'disk-image) (partitions (list esp32-partition root-partition)))) (define iso9660-image - (image + (image-without-os (format 'iso9660) (partitions (list (partition @@ -146,11 +177,11 @@ (define iso9660-image (flags '(boot))))))) (define docker-image - (image + (image-without-os (format 'docker))) (define* (raw-with-offset-disk-image #:optional (offset root-offset)) - (image + (image-without-os (format 'disk-image) (partitions (list (partition diff --git a/gnu/system/images/hurd.scm b/gnu/system/images/hurd.scm index 6da09b855a..2c64117c08 100644 --- a/gnu/system/images/hurd.scm +++ b/gnu/system/images/hurd.scm @@ -74,7 +74,7 @@ (define hurd-initialize-root-partition #:wal-mode? #f))))) (define hurd-disk-image - (image + (image-without-os (format 'disk-image) (platform hurd) (partitions