From: Alyssa Ross <hi@alyssa.is>
To: Demi Marie Obenour <demiobenour@gmail.com>
Cc: devel@spectrum-os.org
Subject: Re: [PATCH v2] scripts/make-gpt.sh: allow setting partition size
Date: Fri, 28 Nov 2025 22:35:13 +0100 [thread overview]
Message-ID: <u3lzrsdtbfpwezybuxmvmflavdha5jdz4lyl3utckxoc2dr3ef@7qdh334wew7v> (raw)
In-Reply-To: <08f97c52-d6e4-424a-99dc-f29f37515fcb@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2556 bytes --]
On Fri, Nov 28, 2025 at 04:31:21PM -0500, Demi Marie Obenour wrote:
> On 11/28/25 16:26, Alyssa Ross wrote:
> > Demi Marie Obenour <demiobenour@gmail.com> writes:
> >
> >> On 11/28/25 16:14, Alyssa Ross wrote:
> >>> Demi Marie Obenour <demiobenour@gmail.com> 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.
> >>>>>
> >>>>> 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 <hi@alyssa.is>
> >>>>> Message-ID: <20251127174054.2056835-2-hi@alyssa.is>
>
> (snip)
>
> >>>>> # 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 <<EOF
> >>>>> +$table
> >>>>> +EOF
> >>>>
> >>>> Nit: should ${partition##*=} be in double quotes?
> >>>
> >>> 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="size=2 + 3"
> > size=${partition##*=}
> > printf "%s\n" $(($size))
> >
> > This prints 5 even though a separate variable is used. It doesn't seem
> > to be possible to get $(( … )) *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.
>
> That's actually required by POSIX. What about:
>
> size=${partition##*=}
> : $((gptMiB += size))
How's that better? Arithmetic will still be expanded inside size —
or do you have some other concern with the parameter expansion inside
the arithmetic expansion?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2025-11-28 21:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-28 13:22 [PATCH v2] scripts/make-gpt.sh: allow setting partition size Alyssa Ross
2025-11-28 20:57 ` Demi Marie Obenour
2025-11-28 21:14 ` Alyssa Ross
2025-11-28 21:15 ` Demi Marie Obenour
2025-11-28 21:26 ` Alyssa Ross
2025-11-28 21:31 ` Demi Marie Obenour
2025-11-28 21:35 ` Alyssa Ross [this message]
2025-11-28 21:39 ` Demi Marie Obenour
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=u3lzrsdtbfpwezybuxmvmflavdha5jdz4lyl3utckxoc2dr3ef@7qdh334wew7v \
--to=hi@alyssa.is \
--cc=demiobenour@gmail.com \
--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).