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 AD22219169; Fri, 28 Nov 2025 21:26:29 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 993) id 19F27191D0; Fri, 28 Nov 2025 21:26:27 +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-b2-smtp.messagingengine.com (fout-b2-smtp.messagingengine.com [202.12.124.145]) by atuin.qyliss.net (Postfix) with ESMTPS id 1CCC8191CE for ; Fri, 28 Nov 2025 21:26:26 +0000 (UTC) Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfout.stl.internal (Postfix) with ESMTP id 603C61D0070E; Fri, 28 Nov 2025 16:26:23 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Fri, 28 Nov 2025 16:26: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=1764365183; x=1764451583; bh=uXwkdGJRLz J47HDss8MT7uOtDIZPvoQBeYoz0o/aJ+4=; b=j83Yy5LyZ/knlW0nSdE3I/t0Q3 5Uabb7/ei+5LAa2lV+f8Zvi/RhKYYLkmFmm2u3lyjghZhYj+854r+tWKK6wilDJQ 0evcMtrVGTBoAmN1oNdhEUlTXWqhS+avZIHC4Ic86tNDTYrXCOqjSbsLgXqKtAMP Ofu1RzgI0O/SwQxFuy9prosPFRYRQSLf8rYLMo6NL0cvc5T5DN1PVAlSEVXA4I4T paMRfe6UDQ2vrfcKGUXlNSYZQJAxmVFlR6LBBDldSFVe251VJvreF9bLxgQjJSBp u8MBz8mWRzR1k1AnrGBPW0XYjcTG5X01ltP51X15HD/wwdpRmE0hzqRETx9g== 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= 1764365183; x=1764451583; bh=uXwkdGJRLzJ47HDss8MT7uOtDIZPvoQBeYo z0o/aJ+4=; b=DTiMCr4UxHcg8dazVknsIqO18KlMAiOBKNN6veBqWows45moTHA LenVUOxts4mYKFWr7MQr4okscfpiCrpeQiW8TUUvNtJvTn29zkX+6grVX4pI2MEP ab0eJm/V3GGm8wknOz3AWNkCqYAehJjZWOWNg+CLoyX0OMeC44ccjpG/JvOrVUDp jGdsqpfzimyzre+m3qZpO9lAUls9tauXd5iGBXmSH1IhgwPnVgTMuWsmGRjTCqP+ 8zP+U0skPNNeGt0r24/Q1t1pINGl8SkA6pYPBdls+6Kv5+oW72ETJAWeYJ0z+QtJ lSSlRJyiT+s0FZ5/YbxH+XovRwBvWtmnh4Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddvhedtkeejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefujghffffkgggtsehgtderredttdejnecuhfhrohhmpeetlhihshhsrgcu tfhoshhsuceohhhisegrlhihshhsrgdrihhsqeenucggtffrrghtthgvrhhnpefhteeigf fgkefhteejkeffvdegvdeghfeitdeilefgudejfedtteevffdvleefueenucffohhmrghi 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:26:22 -0500 (EST) Received: by fw12.qyliss.net (Postfix, from userid 1000) id AF2872DB34F4; Fri, 28 Nov 2025 22:26: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: <373ef2eb-d230-431a-a22c-1a83348d5075@gmail.com> References: <20251128132227.243596-2-hi@alyssa.is> <87ms45oo6b.fsf@alyssa.is> <373ef2eb-d230-431a-a22c-1a83348d5075@gmail.com> Date: Fri, 28 Nov 2025 22:26:03 +0100 Message-ID: <87jyz9onmc.fsf@alyssa.is> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Message-ID-Hash: UZI72JFKTORWJKBZDYWH7JNCJGDTOZUL X-Message-ID-Hash: UZI72JFKTORWJKBZDYWH7JNCJGDTOZUL 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; charset=utf-8 Content-Transfer-Encoding: quoted-printable Demi Marie Obenour writes: > On 11/28/25 16:14, Alyssa Ross wrote: >> Demi Marie Obenour writes: >>=20 >>> 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. >>>> >>>> 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 >>>> 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/202511271740= 54.2056835-2-hi@alyssa.is/ >>>> >>>> scripts/make-gpt.sh | 30 ++++++++++++++++++------------ >>>> scripts/sfdisk-field.awk | 22 +++++++++++++++++----- >>>> 2 files changed, 35 insertions(+), 17 deletions(-) >>>> >>>> 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[:PAR= TMiB]]]... >>>>=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. >>=20 >> 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.) > > I'll look later. > >>>> # 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/sfdis= k-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? >>=20 >> I tried changing it, but it is apparently an "arithmetic syntax error" >> to use double quotes here. > > I'd use a separate variable then. Doesn't seem to make a difference. As an experiment: partition=3D"size=3D2 + 3" size=3D${partition##*=3D} printf "%s\n" $(($size)) This prints 5 even though a separate variable is used. It doesn't seem to be possible to get $(( =E2=80=A6 )) *not* to interpret arithmetic in variables. In bash, but not busybox ash as used in Nix builds, it is possible to use double quotes like you suggested, but $(("$size")) is /still/ 5. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEARYKAB0WIQQGoGac7QfI+H5ZtFCZddwkt31pFQUCaSoTawAKCRCZddwkt31p FYIhAP4xA97B4sUYZy+fXUhk4fJr5+756PJqVA2I/eRDk+sBGQEA77MOe+EVX++p gkWakyJ9wpNuOVG7aCsjVQF4HQz4nA8= =klMI -----END PGP SIGNATURE----- --=-=-=--