From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from atuin.qyliss.net (localhost [IPv6:::1]) by atuin.qyliss.net (Postfix) with ESMTP id 3613011715; Thu, 27 Nov 2025 17:42:06 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 993) id 00072116F9; Thu, 27 Nov 2025 17:42:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on atuin.qyliss.net X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DMARC_MISSING,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=4.0.1 Received: from fout-b1-smtp.messagingengine.com (fout-b1-smtp.messagingengine.com [202.12.124.144]) by atuin.qyliss.net (Postfix) with ESMTPS id EAF8E116F5 for ; Thu, 27 Nov 2025 17:42:00 +0000 (UTC) Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.stl.internal (Postfix) with ESMTP id 6AA621D00061; Thu, 27 Nov 2025 12:41:58 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Thu, 27 Nov 2025 12:41:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alyssa.is; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:message-id:mime-version:reply-to:subject:subject:to :to; s=fm3; t=1764265318; x=1764351718; bh=tmyFv+mT6CQ/Xy3FIUQ9n 1JuTy11WzdLDCf0sbA6HgU=; b=WW4TbhNNayoJYm8GvADMXSa0aUGLDKP1N09oN GnGaxl2M7ybT8NgTqZc7mEmwPTtr9gof4p9O1e7V1MMovNCwl+WpGpMl7PTKTWNS veRLxr8JS5HMH2TTVWf697d7YDT7kgG1ZAL91U8pUE4DzXNL0J+nvZHaqWNtUWB7 cbIHwh3xilaNFFr+Fs23wiwVzB8266RUg/wwBHUG6ihfka/BKMVtzEJIqJdbqpQL cKW27pQ0xtWaqtDyx/95DUMZa1BIWHcFnYJ2b0zx31fm5/vZ0867WafL84wJa1eY 9lW7On1YKdTMNEVzvKDZI13BT8R9+35CBT8puaWPquHQnAkBg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:message-id:mime-version:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1764265318; x=1764351718; bh=tmyFv+mT6CQ/Xy3FIUQ9n1JuTy11WzdLDCf 0sbA6HgU=; b=fEJi4sm6QCmHGpdPDLIx9IfQ+uuRQNlkKH1t2AjPQnGz05SNYuI Rnf01XGv0qXViobyTyv7vBazVjPp+0vqMJWRYTuQb2EuqK7NUVObfVB7WKxVG+NP DPQgkt1UmNruk10Cxj30RhnOJ2AutA69A9MQqTTOBXP2Qgfaj+z5zDIexZxEkecr rTNMdUFPfBPikJMZ5O6WBlN6Oul9HPJhY22SoPVnw8e0LmL9AG9ArCJEQjubFw0i 1C53HUMLeS8tfvWPSOP2tIzGyYF0SIsB/RFRDkFnH+k17hD7P6y3ur6dKSl0yACg rBA4ZJ8QQuCZbG+5wlkIa+STbtTkq2ZumPA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddvgeejkeehucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgggfestdekredtredttdenucfhrhhomheptehlhihsshgrucft ohhsshcuoehhihesrghlhihsshgrrdhisheqnecuggftrfgrthhtvghrnhepkedugfekfe efvdeihedtheevjeetueejhffhuddtueffhfeikeevteffheefgeevnecuffhomhgrihhn pehsphgvtghtrhhumhdqohhsrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomhephhhisegrlhihshhsrgdrihhspdhnsggprhgtphhtthho pedvpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopeguvghmihhosggvnhhouhhrse hgmhgrihhlrdgtohhmpdhrtghpthhtohepuggvvhgvlhesshhpvggtthhruhhmqdhoshdr ohhrgh X-ME-Proxy: Feedback-ID: i12284293:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 27 Nov 2025 12:41:57 -0500 (EST) Received: by fw12.qyliss.net (Postfix, from userid 1000) id 6F49D2A7F5BB; Thu, 27 Nov 2025 18:41:41 +0100 (CET) From: Alyssa Ross To: devel@spectrum-os.org Subject: [PATCH] scripts/make-gpt.sh: allow setting partition size Date: Thu, 27 Nov 2025 18:40:55 +0100 Message-ID: <20251127174054.2056835-2-hi@alyssa.is> X-Mailer: git-send-email 2.51.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: UHF464EE7V34VMCVAE7LU5BGSRNXVMPQ X-Message-ID-Hash: UHF464EE7V34VMCVAE7LU5BGSRNXVMPQ X-MailFrom: hi@alyssa.is X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-devel.spectrum-os.org-0; header-match-devel.spectrum-os.org-1; header-match-devel.spectrum-os.org-2; header-match-devel.spectrum-os.org-3; header-match-devel.spectrum-os.org-4; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Demi Marie Obenour X-Mailman-Version: 3.3.9 Precedence: list List-Id: Patches and low-level development discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: We want non-minimally-sized partitions to leave space for updates. All such partitions will also be labelled, so we can just add another optional field at the end. Since we don't parse partition specifications in sh, we can't keep a running total any more, so instead we just go through the table at the end and add up all the sizes, taking advantage of our knowledge that the size will always be the last thing in each line in our tables. Signed-off-by: Alyssa Ross --- This is an alternative to Demi's implementation[1], which required Bash features. [1]: https://spectrum-os.org/lists/archives/spectrum-devel/20251126-updates-v5-3-fd746748febd@gmail.com/ scripts/make-gpt.sh | 28 +++++++++++++++------------- scripts/sfdisk-field.awk | 22 +++++++++++++++++----- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/scripts/make-gpt.sh b/scripts/make-gpt.sh index 96f0d2c..07eac50 100755 --- a/scripts/make-gpt.sh +++ b/scripts/make-gpt.sh @@ -1,10 +1,10 @@ #!/bin/sh -eu # -# SPDX-FileCopyrightText: 2021-2023 Alyssa Ross +# SPDX-FileCopyrightText: 2021-2023, 2025 Alyssa Ross # SPDX-FileCopyrightText: 2022 Unikie # SPDX-License-Identifier: EUPL-1.2+ # -# usage: make-gpt.sh GPT_PATH PATH:PARTTYPE[:PARTUUID[:PARTLABEL]]... +# usage: make-gpt.sh GPT_PATH PATH:PARTTYPE[:PARTUUID[:PARTLABEL[:PARTMiB]]]... ONE_MiB=1048576 @@ -28,7 +28,8 @@ fillPartition() { lseek -S 1 "$start" cat "$3" 1<>"$1" } -# Prints the partition path from a PATH:PARTTYPE[:PARTUUID[:PARTLABEL]] string. +# Prints the partition path from a +# PATH:PARTTYPE[:PARTUUID[:PARTLABEL[:PARTMiB]]] string. partitionPath() { awk -F: '{print $1}' < +# SPDX-FileCopyrightText: 2022, 2024-2025 Alyssa Ross BEGIN { types["root.aarch64"] = "b921b045-1df0-41c3-af44-4c6f280d3fae" @@ -9,12 +9,11 @@ BEGIN { types["verity.aarch64"] = "df3300ce-d69f-4c92-978c-9bfb0f38d820" types["verity.x86_64"] = "2c7357ed-ebd2-46d9-aec1-23d437ec2bf5" - # Field #1 is the partition path, which make-gpt.sh will turn into - # the size field. Since it's handled elsewhere, we skip that - # first field. + # Field #1 is the partition path, which is read by make-gpt.sh + # but not relevant for running sfdisk, so skip it. skip=1 - split("type uuid name", keys) + split("type uuid name size", keys) split(partition, fields, ":") arch = ENVIRON["ARCH"] @@ -31,8 +30,21 @@ BEGIN { if (keys[n - skip] == "type") { if (uuid = types[fields[n] "." arch]) fields[n] = uuid + } else if (keys[n - skip] == "size") { + if (fields[n] < size) { + printf "%s MiB partition content is too big for %s MiB partition\n", + size, fields[n] > "/dev/stderr" + exit 1 + } + + size = fields[n] + continue # Handled at the end. } printf "%s=%s,", keys[n - skip], fields[n] } + + # Always output a size field, either supplied in input or + # default value of the size variable. + printf "size=%s\n", size } base-commit: c43e5c63a028994d5f66a15db19f415bf3cb7736 -- 2.51.0