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 A03281903B; Fri, 28 Nov 2025 21:14:29 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 993) id 3FF8718FE2; Fri, 28 Nov 2025 21:14:26 +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 735C218FE1 for ; Fri, 28 Nov 2025 21:14:25 +0000 (UTC) Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfhigh.stl.internal (Postfix) with ESMTP id 0A5E57A082D; Fri, 28 Nov 2025 16:14:23 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Fri, 28 Nov 2025 16:14:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alyssa.is; h=cc :cc:content-type: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=1764364462; x=1764450862; bh=3Tc5doBtab pBAHsqyvoQeKIwR3KdQ2o0PjHFe6VTcPk=; b=SqnRaqTttjtIlYUZk6VeJPXxam DdjTjwQnXgeZzVYNDCJ85a+Vq83GiOJO5ODOIxkrgoBIpLxrzq34yPyPIkK8NUoj dSPnw8vLWej8SFLdbldKe+6jvudzufk+mWVzwzUGgh88TdQ0FxpYw6VCe5HMFSTA 2mRODsbIivgNidce3iHbRkts4eMU65lvbHAnaLPGeIkkh7UMuj0NU5Kb3rH1qwmx c2k5K6MUz4dxOzFJanZCWT9OxMXt6DjMi6UuyAyE9f106mH67/tJBYnJNLtOjfLZ EJjb/8FfXjgY97RQ6B7jY3uMns+5ItJz+wf1hleAsvwBvJVu2vtagttk930g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type: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= 1764364462; x=1764450862; bh=3Tc5doBtabpBAHsqyvoQeKIwR3KdQ2o0PjH Fe6VTcPk=; b=mcX+P4q6kieanX4oAHyExKWaG4QgTUeqKdb3VzCxvNQZlUzSQIF uXcMAjeB+2E2QW7luR+P0+KomI/qtBfZ7bVfk5ibSN4awAt/Hnz381LPidcSyyiT +RD2GthsaqXi7DC6s00vQ9bnh9IEsR6xZIuW9gYAk43FGvnevTo2Kz/0uaDI4Z3s Mp8r/P4dm5un3pWRglayWkuOnjam6f+KpOIzOBQkRy6yZEgeXo5PkMR5CX8/Tyr2 wM7RxVTsQ7Woz1VRBe4MHRxFSD2msbiwN+/0MSCdWCjHlWQRCuJhdop+pgO/j1q6 Mzwqk6/h5TG7otv/i8z5g6lYFNhzK+K1P4g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddvhedtkeeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefujghffffkgggtsehgtderredttddtnecuhfhrohhmpeetlhihshhsrgcu tfhoshhsuceohhhisegrlhihshhsrgdrihhsqeenucggtffrrghtthgvrhhnpeevjeeike ehffeuheejvedtkeellefhhefhleegffeiieduvdeuieefteekleffvdenucffohhmrghi nhepshhpvggtthhruhhmqdhoshdrohhrghenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpehhihesrghlhihsshgrrdhishdpnhgspghrtghpthht ohepvddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepuggvmhhiohgsvghnohhurh esghhmrghilhdrtghomhdprhgtphhtthhopeguvghvvghlsehsphgvtghtrhhumhdqohhs rdhorhhg X-ME-Proxy: Feedback-ID: i12284293:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 28 Nov 2025 16:14:22 -0500 (EST) Received: by fw12.qyliss.net (Postfix, from userid 1000) id 7BC0E2DB33AD; Fri, 28 Nov 2025 22:14:06 +0100 (CET) From: Alyssa Ross To: Demi Marie Obenour Subject: Re: [PATCH v2] scripts/make-gpt.sh: allow setting partition size In-Reply-To: References: <20251128132227.243596-2-hi@alyssa.is> Date: Fri, 28 Nov 2025 22:14:04 +0100 Message-ID: <87ms45oo6b.fsf@alyssa.is> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Message-ID-Hash: FKXYGLF3IFIDGR4VQHZ5CA6BFNGVTNXI X-Message-ID-Hash: FKXYGLF3IFIDGR4VQHZ5CA6BFNGVTNXI 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: devel@spectrum-os.org 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: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Demi Marie Obenour writes: > On 11/28/25 08:22, Alyssa Ross wrote: >> 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. >>=20 >> 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. >>=20 >> Signed-off-by: Alyssa Ross >> Message-ID: <20251127174054.2056835-2-hi@alyssa.is> >> --- >> v2: fix conflicts after applying Demi's optimization, and avoid awk >> to sum partition sizes, taking inspiration from the same. >> v1: https://spectrum-os.org/lists/archives/spectrum-devel/20251127174054= .2056835-2-hi@alyssa.is/ >>=20 >> scripts/make-gpt.sh | 30 ++++++++++++++++++------------ >> scripts/sfdisk-field.awk | 22 +++++++++++++++++----- >> 2 files changed, 35 insertions(+), 17 deletions(-) >>=20 >> diff --git a/scripts/make-gpt.sh b/scripts/make-gpt.sh >> index 3cae441..cb19868 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[:PARTM= iB]]]... >>=20=20 >> ONE_MiB=3D1048576 >>=20=20 >> @@ -33,21 +33,27 @@ scriptsDir=3D"$(dirname "$0")" >> out=3D"$1" >> shift >>=20=20 >> -nl=3D' >> -' >> -table=3D"label: gpt" >> +table=3D$(for partition; do >> + awk -f "$scriptsDir/sfdisk-field.awk" \ >> + -v partition=3D"$partition" \ >> + -v size=3D"$(sizeMiB "${partition%%:*}")" >> +done) > > $(sizeMiB) should be moved into a separate command. Shellcheck can > catch this if you enable SC2312. Good catch, thanks. Feel free to suggest other optional shellcheck things we should enable. (Although I've just noticed release/checks/shellcheck.nix doesn't seem to be reading the .shellcheckrc file properly so don't use that for testing.) >> # Keep 1MiB free at the start, and 1MiB free at the end. >> -gptBytes=3D$((ONE_MiB * 2)) >> -for partition; do >> - sizeMiB=3D"$(sizeMiB "${partition%%:*}")" >> - table=3D"$table${nl}size=3D${sizeMiB}MiB,$(awk -f "$scriptsDir/sfdisk-= field.awk" -v partition=3D"$partition")" >> - gptBytes=3D"$((gptBytes + sizeMiB * ONE_MiB))" >> -done >> +gptMiB=3D2 >> +while read -r partition; do >> + # Here we rely on sfdisk-field.awk always putting size last. >> + : $((gptMiB +=3D ${partition##*=3D})) >> +done <> +$table >> +EOF > > Nit: should ${partition##*=3D} be in double quotes? I tried changing it, but it is apparently an "arithmetic syntax error" to use double quotes here. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEARYKAB0WIQQGoGac7QfI+H5ZtFCZddwkt31pFQUCaSoQnAAKCRCZddwkt31p FXTHAQC5oTzcRwmfX9ffNYrI38C1s3+kzrQJ9L3uJfCZcWbO7wEAz46gIj8PqHh5 AlQQA/DDxZWuYAf4m5sdG5G6MJeeoAU= =2/RP -----END PGP SIGNATURE----- --=-=-=--