From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id eI2YOXebg2G/NAEAgWs5BA (envelope-from ) for ; Thu, 04 Nov 2021 09:36:07 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id UJdPNXebg2GFPAAA1q6Kng (envelope-from ) for ; Thu, 04 Nov 2021 08:36:07 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 9C0EF13774 for ; Thu, 4 Nov 2021 09:36:07 +0100 (CET) Received: from localhost ([::1]:32808 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1miYEA-0007qc-SH for larch@yhetil.org; Thu, 04 Nov 2021 04:36:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46722) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1miYE6-0007q7-V5 for guix-patches@gnu.org; Thu, 04 Nov 2021 04:36:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:58654) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1miYE6-0008Jq-Lu for guix-patches@gnu.org; Thu, 04 Nov 2021 04:36:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1miYE6-00074J-Ji for guix-patches@gnu.org; Thu, 04 Nov 2021 04:36:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#51598] [PATCH 2/2] image: Support generating GPT images via `partition-table-type` Resent-From: Ryan Sundberg Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 04 Nov 2021 08:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 51598 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 51598@debbugs.gnu.org Cc: Ryan Sundberg X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.163601494327132 (code B ref -1); Thu, 04 Nov 2021 08:36:02 +0000 Received: (at submit) by debbugs.gnu.org; 4 Nov 2021 08:35:43 +0000 Received: from localhost ([127.0.0.1]:41965 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1miYDn-00073X-G2 for submit@debbugs.gnu.org; Thu, 04 Nov 2021 04:35:43 -0400 Received: from lists.gnu.org ([209.51.188.17]:34464) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1miYDl-00073J-81 for submit@debbugs.gnu.org; Thu, 04 Nov 2021 04:35:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46676) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1miYDl-0007pU-1U for guix-patches@gnu.org; Thu, 04 Nov 2021 04:35:41 -0400 Received: from mail.arctype.co ([138.68.9.245]:34821) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1miYDi-0008D8-QD for guix-patches@gnu.org; Thu, 04 Nov 2021 04:35:40 -0400 Received: from authenticated-user (mail.arctype.co [138.68.9.245]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by mail.arctype.co (Postfix) with ESMTPSA id BB12A13B2C3; Thu, 4 Nov 2021 08:35:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=arctype.co; s=mail; t=1636014936; bh=y8vSCv5cSARs+crGZYQcuABaxFTaajtzRyI5NOSw0ls=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A5TnX29DcEeidieBrQ6qxr5EyUf5+qoRmAGU25QnaUhWf+VMfb2bVX8uw/wUd6ZRG 1s1/Pg3UngQATlwsIG8HD3h3gSZLTeG1g33NoxGNMZVCw/n/i6cHUcvBWgRCNHsOQ2 Fm+KXJu9OlcXCPfkDaEBHB0COxfj/2ikekKqc4p1VQY4wqhUKI8AMaa9ieE+zk6F97 y/SDBkjkNDtTMAH3SwRunj5TnCKsJsEYPPIVW6teWKe1JNiwwli4tEpkltwfgkdpVY FDywvE5YV4e8JJjCf8QLxe1iWLrHMF60dDXUtHk108P6f7RCH92zw84b+XYSpek+86 dvpVLZa44uVhw== Date: Thu, 4 Nov 2021 01:35:11 -0700 Message-Id: <20211104083511.11852-2-ryan@arctype.co> In-Reply-To: <20211104083511.11852-1-ryan@arctype.co> References: <20211104083511.11852-1-ryan@arctype.co> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=138.68.9.245; envelope-from=ryan@arctype.co; helo=mail.arctype.co X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" Reply-to: Ryan Sundberg X-ACL-Warn: , Ryan Sundberg via Guix-patches From: Ryan Sundberg via Guix-patches via X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1636014967; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=LyqXd/lIVek25n4iNTpT3SfItieEkTNzQfkv5kTc+cw=; b=Ly+WqqjU2rHJ3PajnCjJrb5Cb0WsgyNb3Ssim1dojSpTC0ic57MhZTdg1Ip3YE1ndlbDSH dJaucRxJwYwgBSd9WpzzBkp5646AdxPyjUruFVqm8HPBXw4lzb//1nei5RZ3yhHBFwGBAt RnGaK6GYMFB0vJkSwB+oUqcL0pGoKlNUJ5c/4gwHa+6lLLL88wlpoFcG2uCLAtk/r76vd+ haPvO4AR1yMOqoakZsWtusDJxufU+MBR3HXI8waloaC5YA6HzPzF6eEDYts14ksjLbq530 5qXbcrGL0J8qlM/XZJLd9hkKwXdUuA0r9G49lCGC04du9eUP2g2z2VtDweRbXQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1636014967; a=rsa-sha256; cv=none; b=OEUnUCUcbQ3yuXLEdANG7jkpz998l3vcd9USQIiCYHbQ+WSkgdiNMjPTCoc71pPF0M/Rf5 PcCXxICIIx+3j1KkOjs3MIi+patDtequm4C/NyaYSOCmS3DaYD0aorJ7TB2LuOwHttwCRS 4N0g9tuLAMEg1zFifz0uKbqvKwrXHFPPyAYD9YDx+Wt7JoZuV0C5F9LDFLvTukzmucYW3p epJvXViMSLVbE9lDYujQJx69Jj8jZt+DHRbadCYitJBwgQVs3b1jYD+uo9+u9zuQ4QOJN3 V5KRDLDw33UEQyUqJbXhb87iU0rYTSHXv6T4Kfi9N3A80THvQ4BhSowWI8jN6Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=arctype.co header.s=mail header.b=A5TnX29D; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: 2.58 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=arctype.co header.s=mail header.b=A5TnX29D; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 9C0EF13774 X-Spam-Score: 2.58 X-Migadu-Scanner: scn0.migadu.com X-TUID: U+cGLcuo29fI * gnu/image.scm: Add partition-table-type field to image * gnu/system/image.scm: Implement partition-table-type logic for genimage. --- gnu/image.scm | 3 +++ gnu/system/image.scm | 59 +++++++++++++++++++++++++++++++------------- 2 files changed, 45 insertions(+), 17 deletions(-) diff --git a/gnu/image.scm b/gnu/image.scm index 75d489490d..b83c4275da 100644 --- a/gnu/image.scm +++ b/gnu/image.scm @@ -37,6 +37,7 @@ image-target image-size image-operating-system + image-partition-table-type image-partitions image-compression? image-volatile-root? @@ -84,6 +85,8 @@ (default 'guess)) (operating-system image-operating-system ; (default #f)) + (partition-table-type image-partition-table-type ; 'mbr or 'gpt + (default 'mbr)) (partitions image-partitions ;list of (default '())) (compression? image-compression? ;boolean diff --git a/gnu/system/image.scm b/gnu/system/image.scm index 7a3a637e47..ed22484a62 100644 --- a/gnu/system/image.scm +++ b/gnu/system/image.scm @@ -309,6 +309,14 @@ used in the image." ((member 'esp flags) "0xEF") (else "0x83")))) + (define (partition->gpt-type partition) + ;; Return the genimage GPT partition type code corresponding to PARTITION. + ;; See https://github.com/pengutronix/genimage/blob/master/README.rst + (let ((flags (partition-flags partition))) + (cond + ((member 'esp flags) "U") + (else "L")))) + (define (partition-image partition) ;; Return as a file-like object, an image of the given PARTITION. A ;; directory, filled by calling the PARTITION initializer procedure, is @@ -358,26 +366,43 @@ used in the image." #:local-build? #f #:options `(#:references-graphs ,inputs)))) - (define (partition->config partition) + (define (gpt-image? image) + (eq? 'gpt (image-partition-table-type image))) + + (define (partition-type-values image partition) + (if (gpt-image? image) + (values "partition-type-uuid" (partition->gpt-type partition)) + (values "partition-type" (partition->dos-type partition)))) + + (define (partition->config image partition) ;; Return the genimage partition configuration for PARTITION. - (let ((label (partition-label partition)) - (dos-type (partition->dos-type partition)) - (image (partition-image partition)) - (offset (partition-offset partition))) - #~(format #f "~/partition ~a { -~/~/partition-type = ~a -~/~/image = \"~a\" -~/~/offset = \"~a\" -~/}" - #$label - #$dos-type - #$image - #$offset))) + (let-values (((partition-type-attribute partition-type-value) (partition-type-values image partition))) + (let ((label (partition-label partition)) + (image (partition-image partition)) + (offset (partition-offset partition))) + #~(format #f "~/partition ~a { + ~/~/~a = ~a + ~/~/image = \"~a\" + ~/~/offset = \"~a\" + ~/}" + #$label + #$partition-type-attribute + #$partition-type-value + #$image + #$offset)))) + + (define (genimage-type-options image-type image) + (cond + ((equal? image-type "hdimage") + (format #f "~%~/~/gpt = ~a~%~/" + (if (gpt-image? image) "true" "false"))) + (else ""))) (let* ((format (image-format image)) (image-type (format->image-type format)) + (image-type-options (genimage-type-options image-type image)) (partitions (image-partitions image)) - (partitions-config (map partition->config partitions)) + (partitions-config (map (cut partition->config image <>) partitions)) (builder #~(begin (let ((format (@ (ice-9 format) format))) @@ -386,9 +411,9 @@ used in the image." (format port "\ image ~a { -~/~a {} +~/~a {~a} ~{~a~^~%~} -}~%" #$genimage-name #$image-type (list #$@partitions-config)))))))) +}~%" #$genimage-name #$image-type #$image-type-options (list #$@partitions-config)))))))) (computed-file "genimage.cfg" builder))) (let* ((image-name (image-name image)) -- 2.31.1