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 E50CA19458; Fri, 28 Nov 2025 21:45:13 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 993) id 1B5E61944D; Fri, 28 Nov 2025 21:45:11 +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 fhigh-b2-smtp.messagingengine.com (fhigh-b2-smtp.messagingengine.com [202.12.124.153]) by atuin.qyliss.net (Postfix) with ESMTPS id 59E0B1944B for ; Fri, 28 Nov 2025 21:45:09 +0000 (UTC) Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfhigh.stl.internal (Postfix) with ESMTP id C3D317A06E6; Fri, 28 Nov 2025 16:45:05 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Fri, 28 Nov 2025 16:45:05 -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:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm3; t=1764366305; x= 1764452705; bh=+GEr/N4CNkF52GQ4jYSCopw6BWfWnQEc53yMWI3R1c0=; b=N KRD8hbKY4pS1/TyKq48ubXcEAC4sCqWJRgX4md2ZGz+kR+DwRsdHxRo8xtg8I/i2 BWQ3zh2p2mZgjpGViFkePm8I2x0LVoOsLHCBh7wSYQ0oRd+s6x7lEjCeh+ttwz7U DvXyZBy+D6MJLb1GdMcluVasQBgLjssU0dax4d8HZhZHFVxnBVQ7vRvWW2vrbNcu K2oGYN9gYbMLp/J+fTzUF6YWIHZYOOeCtUuwq9JpPpqSpgyBQvXg8tfhOSVbfil2 xj5nLAEcZww5tW77TYWEkKG7E+34ctKzELwUFRhvAZ9Y7iQtHW6AcoM2W+vT/hcs 9steFIY8xcLKibc9fQozQ== 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:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1764366305; x=1764452705; bh=+ GEr/N4CNkF52GQ4jYSCopw6BWfWnQEc53yMWI3R1c0=; b=P+bUOhJCfJAPtasO/ bmUZnhBLmzZNratUYHY/yJvishzi4qJug5wh/Th2CzFKPnwa/5JAqh44y7GxJFla hdKA3oEOVcT5BRM43CSUzYuU3rb6KXGTabsJN1jDWZmunL/wPCBQyKFEcGepsINS tun7ilcbPg+2/TuoAenQjuYKrXgtd7z+ksXKNNQAmnPWSQ0kw90lHAIWIyPJclIm 0pTVyw2Om+zTrFDL5aF3q33GOOe56VtMySQgAR+o9VAr06ozBBnj7D/wz71Y7LIC miBRgoi1hTJwYWPfDWYTOJ+NGo3ATGhUTU/sdT3O1ewUiZjTZoZMywyyWfAxhEkG FBpEw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddvhedtkeelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomheptehlhihsshgr ucftohhsshcuoehhihesrghlhihsshgrrdhisheqnecuggftrfgrthhtvghrnheptefhge eiffffleetudeuledtleeutefhueetveeiteeugfegfeduvdelgfdtfedvnecuffhomhgr ihhnpehsphgvtghtrhhumhdqohhsrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhephhhisegrlhihshhsrgdrihhspdhnsggprhgtphht thhopedvpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopeguvghmihhosggvnhhouh hrsehgmhgrihhlrdgtohhmpdhrtghpthhtohepuggvvhgvlhesshhpvggtthhruhhmqdho shdrohhrgh X-ME-Proxy: Feedback-ID: i12284293:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 28 Nov 2025 16:45:05 -0500 (EST) Received: by fw12.qyliss.net (Postfix, from userid 1000) id 1E5692DB376A; Fri, 28 Nov 2025 22:44:54 +0100 (CET) From: Alyssa Ross To: devel@spectrum-os.org Subject: [PATCH v3 2/2] scripts/make-gpt.sh: allow setting partition size Date: Fri, 28 Nov 2025 22:44:07 +0100 Message-ID: <20251128214406.465618-2-hi@alyssa.is> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251128211710.462696-2-hi@alyssa.is> References: <20251128211710.462696-2-hi@alyssa.is> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: ZIHI75HIG26IJW7PYNLF5O6GJC3VNHV4 X-Message-ID-Hash: ZIHI75HIG26IJW7PYNLF5O6GJC3VNHV4 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 --- v3: don't discard return value of sizeMiB v2: https://spectrum-os.org/lists/archives/spectrum-devel/d7a8c13d-5bae-47c8-a1a4-b8bc78cadffa@gmail.com scripts/make-gpt.sh | 31 +++++++++++++++++++------------ scripts/sfdisk-field.awk | 22 +++++++++++++++++----- 2 files changed, 36 insertions(+), 17 deletions(-) diff --git a/scripts/make-gpt.sh b/scripts/make-gpt.sh index e39828b..998a54d 100755 --- a/scripts/make-gpt.sh +++ b/scripts/make-gpt.sh @@ -1,10 +1,10 @@ #!/bin/sh -- # -# 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]]]... set -euo pipefail @@ -35,21 +35,28 @@ scriptsDir="$(dirname "$0")" out="$1" shift -nl=' -' -table="label: gpt" +table=$(for partition; do + size="$(sizeMiB "${partition%%:*}")" + awk -f "$scriptsDir/sfdisk-field.awk" \ + -v partition="$partition" \ + -v size="$size" +done) # Keep 1MiB free at the start, and 1MiB free at the end. -gptBytes=$((ONE_MiB * 2)) -for partition; do - sizeMiB="$(sizeMiB "${partition%%:*}")" - table="$table${nl}size=${sizeMiB}MiB,$(awk -f "$scriptsDir/sfdisk-field.awk" -v partition="$partition")" - gptBytes="$((gptBytes + sizeMiB * ONE_MiB))" -done +gptMiB=2 +while read -r partition; do + # Here we rely on sfdisk-field.awk always putting size last. + : $((gptMiB += ${partition##*=})) +done < +# 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 } -- 2.51.0