From: "Johannes Süllner" <johannes.suellner@mailbox.org>
To: devel@spectrum-os.org
Cc: "Johannes Süllner" <johannes.suellner@mailbox.org>
Subject: [PATCH v2 5/5] Revert "scripts/make-gpt.sh: allow setting partition size"
Date: Wed, 4 Feb 2026 18:55:25 +0100 [thread overview]
Message-ID: <20260204175543.22164-7-johannes.suellner@mailbox.org> (raw)
In-Reply-To: <20260204175543.22164-2-johannes.suellner@mailbox.org>
This reverts commit d4832d18f7c938782efd88185b31180d7475b575.
The only place where partition sizes were set was for the live image,
and this was removed in the parent commit.
Signed-off-by: Johannes Süllner <johannes.suellner@mailbox.org>
---
scripts/make-gpt.sh | 31 ++++++++++++-------------------
scripts/sfdisk-field.awk | 22 +++++-----------------
2 files changed, 17 insertions(+), 36 deletions(-)
diff --git a/scripts/make-gpt.sh b/scripts/make-gpt.sh
index 998a54d..e39828b 100755
--- a/scripts/make-gpt.sh
+++ b/scripts/make-gpt.sh
@@ -1,10 +1,10 @@
#!/bin/sh --
#
-# SPDX-FileCopyrightText: 2021-2023, 2025 Alyssa Ross <hi@alyssa.is>
+# SPDX-FileCopyrightText: 2021-2023 Alyssa Ross <hi@alyssa.is>
# SPDX-FileCopyrightText: 2022 Unikie
# SPDX-License-Identifier: EUPL-1.2+
#
-# usage: make-gpt.sh GPT_PATH PATH:PARTTYPE[:PARTUUID[:PARTLABEL[:PARTMiB]]]...
+# usage: make-gpt.sh GPT_PATH PATH:PARTTYPE[:PARTUUID[:PARTLABEL]]...
set -euo pipefail
@@ -35,28 +35,21 @@ scriptsDir="$(dirname "$0")"
out="$1"
shift
-table=$(for partition; do
- size="$(sizeMiB "${partition%%:*}")"
- awk -f "$scriptsDir/sfdisk-field.awk" \
- -v partition="$partition" \
- -v size="$size"
-done)
+nl='
+'
+table="label: gpt"
# Keep 1MiB free at the start, and 1MiB free at the end.
-gptMiB=2
-while read -r partition; do
- # Here we rely on sfdisk-field.awk always putting size last.
- : $((gptMiB += ${partition##*=}))
-done <<EOF
-$table
-EOF
+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
rm -f "$out"
-truncate -s "${gptMiB}M" "$out"
-
+truncate -s "$gptBytes" "$out"
sfdisk --no-reread --no-tell-kernel "$out" <<EOF
-label: gpt
-sector-size: $ONE_MiB
$table
EOF
diff --git a/scripts/sfdisk-field.awk b/scripts/sfdisk-field.awk
index 78b438e..e13c86d 100644
--- a/scripts/sfdisk-field.awk
+++ b/scripts/sfdisk-field.awk
@@ -1,7 +1,7 @@
#!/usr/bin/awk -f
#
# SPDX-License-Identifier: EUPL-1.2+
-# SPDX-FileCopyrightText: 2022, 2024-2025 Alyssa Ross <hi@alyssa.is>
+# SPDX-FileCopyrightText: 2022, 2024 Alyssa Ross <hi@alyssa.is>
BEGIN {
types["root.aarch64"] = "b921b045-1df0-41c3-af44-4c6f280d3fae"
@@ -9,11 +9,12 @@ 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 is read by make-gpt.sh
- # but not relevant for running sfdisk, so skip it.
+ # 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.
skip=1
- split("type uuid name size", keys)
+ split("type uuid name", keys)
split(partition, fields, ":")
arch = ENVIRON["ARCH"]
@@ -30,21 +31,8 @@ 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
}
next prev parent reply other threads:[~2026-02-04 17:57 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-04 17:55 [PATCH v2 0/5] Spectrum-installer Johannes Süllner
2026-02-04 17:55 ` [PATCH v2 1/5] tools: add spectrum-installer Johannes Süllner
2026-02-04 17:55 ` [PATCH v2 2/5] host/rootfs: integrate spectrum-installer Johannes Süllner
2026-02-05 4:17 ` Demi Marie Obenour
2026-02-05 8:56 ` Johannes Süllner
2026-03-15 11:56 ` Alyssa Ross
2026-03-15 12:15 ` Alyssa Ross
2026-02-04 17:55 ` [PATCH v2 3/5] release: drop combined and installer image Johannes Süllner
2026-03-15 12:20 ` Alyssa Ross
2026-02-04 17:55 ` [PATCH v2 4/5] release/live: remove B slot from live image and reduce A slot size Johannes Süllner
2026-03-15 12:21 ` Alyssa Ross
2026-02-04 17:55 ` Johannes Süllner [this message]
2026-03-15 12:23 ` [PATCH v2 5/5] Revert "scripts/make-gpt.sh: allow setting partition size" Alyssa Ross
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260204175543.22164-7-johannes.suellner@mailbox.org \
--to=johannes.suellner@mailbox.org \
--cc=devel@spectrum-os.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://spectrum-os.org/git/crosvm
https://spectrum-os.org/git/doc
https://spectrum-os.org/git/mktuntap
https://spectrum-os.org/git/nixpkgs
https://spectrum-os.org/git/spectrum
https://spectrum-os.org/git/ucspi-vsock
https://spectrum-os.org/git/www
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).