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 AD2632D70; Tue, 25 Nov 2025 13:03:09 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 993) id EC1EC2D8D; Tue, 25 Nov 2025 13:03:06 +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,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=4.0.1 Received: from fhigh-a3-smtp.messagingengine.com (fhigh-a3-smtp.messagingengine.com [103.168.172.154]) by atuin.qyliss.net (Postfix) with ESMTPS id F076E2D8C for ; Tue, 25 Nov 2025 13:03:05 +0000 (UTC) Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.phl.internal (Postfix) with ESMTP id 179E314000C8; Tue, 25 Nov 2025 08:03:04 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Tue, 25 Nov 2025 08:03:04 -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=fm2; t=1764075784; x=1764162184; bh=nEGG4BUzTl pXDiZrsA0obAfPPLwbkpOa1ysBmduSnTM=; b=O+Wnc8+AJdFsX4pix8q83s5q5B EtDfaTHQl/kih4TM4hnvFO7qeBR9Q6LiTNZwqtepUyjQXSGoGZG5O1sySSeWRI0s LAD0/IU0dyAF0ZD92GznERpe87RsYo8O2s8uN82mEjki3JRrjf60fbsLlnTJ2uVm /B3RFY7krG5azs30vpFZgP+x7wFEqHak8WcMzvkmmECEdQZRFwZRX4Eytvypqkef 3pQdfKtBvFgU67fSD0GW3BtjeQXWANl99bIwVqc/01StxJrf36DnCvsd7lllUd+s ADsDrwoAK0cFuYbFzlZ5WJuwFUeLEOmBmQK2MY9eTFzHsGU+/Mp8oN3mpeyg== 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=fm3; t= 1764075784; x=1764162184; bh=nEGG4BUzTlpXDiZrsA0obAfPPLwbkpOa1ys BmduSnTM=; b=NUOvRoqF1SANkzLgOKapxFknU4f6qTGaMxAcJGHBfNH5H/fZ8q5 x8xpigIiTfr3hJgSfPgBduYpXbmeuktiOYH7qxbspgTzREa2Qd9fxGJEgzeI2gaC fgGrbQZipNl2YKTGjBz3vmwXxETIjbr/RdjkUlU0v4qF/+8pebOmAU8gSeyvk2qJ Xs8BCwqoq6M/M/wsnnkbGSXqAhtkb3nAY6dQ3OviiQyHmbUb3aXAJfhKK1mcsk65 aylIvU8kQHSjhDWowoZnmYq/q6PWbzo5V6bDFjYDRmGNGpjsJpR02mOFoDKJmocj 3ettH1qQVu++jPG+vC09eR7nelZnwkGhwGA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddvgeduheegucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefujghffffkgggtsehgtderredttdejnecuhfhrohhmpeetlhihshhsrgcu tfhoshhsuceohhhisegrlhihshhsrgdrihhsqeenucggtffrrghtthgvrhhnpeetheevud fgjefghefhieejudelkeeljeegvdekueeuhffhgedvveefteevgeetieenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehhihesrghlhihsshgrrd hishdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohep uggvmhhiohgsvghnohhurhesghhmrghilhdrtghomhdprhgtphhtthhopeguvghvvghlse hsphgvtghtrhhumhdqohhsrdhorhhg X-ME-Proxy: Feedback-ID: i12284293:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 25 Nov 2025 08:03:03 -0500 (EST) Received: by fw12.qyliss.net (Postfix, from userid 1000) id 48CE625FC9B0; Tue, 25 Nov 2025 14:02:52 +0100 (CET) From: Alyssa Ross To: Demi Marie Obenour Subject: Re: [PATCH v4 06/14] Support generating multiple partition UUIDs In-Reply-To: <20251121-updates-v4-6-d4561c42776e@gmail.com> References: <20251121-updates-v4-0-d4561c42776e@gmail.com> <20251121-updates-v4-6-d4561c42776e@gmail.com> Date: Tue, 25 Nov 2025 14:02:51 +0100 Message-ID: <874iqi2rk4.fsf@alyssa.is> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Message-ID-Hash: 34EWMSJFPPJ4OF7UKXV6CW55MWZYLUT6 X-Message-ID-Hash: 34EWMSJFPPJ4OF7UKXV6CW55MWZYLUT6 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: Spectrum OS Development 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: > Generate 4 partition UUIDs instead of just 2. Port > scripts/format-uuid.sh to awk to make this much easier. Would have been nice to see the awk port first with unchanged behaviour, so it was then easier to see what behaviour was actually getting changed here. > Signed-off-by: Demi Marie Obenour > --- > Changes since v2: > - Split into separate commit. > --- > host/initramfs/Makefile | 8 +++++--- > host/rootfs/Makefile | 6 ++++-- > release/live/Makefile | 8 +++++--- > release/live/default.nix | 2 +- > scripts/format-uuid.awk | 35 +++++++++++++++++++++++++++++++++++ > scripts/format-uuid.sh | 19 ------------------- > 6 files changed, 50 insertions(+), 28 deletions(-) No blockers in here, but there are improvements I'd like to see made at some point, even if that's after this has been applied. > diff --git a/host/initramfs/Makefile b/host/initramfs/Makefile > index fd8cbb6c3e775ed27d0a524bf167cb4d3940d799..27a26b46a8110d35ee02a63b1= 2931d6b9c2742e5 100644 > --- a/host/initramfs/Makefile > +++ b/host/initramfs/Makefile > @@ -35,10 +35,12 @@ build/mountpoints: > cd build/mountpoints && mkdir -p $(MOUNTPOINTS) > find build/mountpoints -mindepth 1 -exec touch -d @0 {} ';' >=20=20 > -build/live.img: ../../scripts/format-uuid.sh ../../scripts/make-gpt.sh .= ./../scripts/sfdisk-field.awk $(ROOT_FS_IMAGES) > +build/live.img: ../../scripts/format-uuid.awk ../../scripts/make-gpt.sh = ../../scripts/sfdisk-field.awk build/boot.fat $(ROOT_FS_IMAGES) > + uuids=3D$$(awk -f ../../scripts/format-uuid.awk < $(ROOT_FS_VERITY_ROOT= HASH)) && \ > + set -euo pipefail -- $$uuids && \ Nice trick =E2=80=94 I like it. There's no need to set -eo pipefail on Make commands that don't use ; or | though. If we did that consistently our Makefiles would be unreadable because it'd be hard to see past all the sets to the actual functionality, and seeing this here when it's not set on every command makes me wonder what's special about this one, which turns out to be nothing. > bash ../../scripts/make-gpt.sh $@.tmp \ > - $(ROOT_FS_VERITY):verity:$$(../../scripts/format-uuid.sh "$$(dd if=3D$(= ROOT_FS_VERITY_ROOTHASH) bs=3D32 skip=3D1 count=3D1 status=3Dnone)") \ > - $(ROOT_FS):root:$$(../../scripts/format-uuid.sh "$$(head -c 32 $(RO= OT_FS_VERITY_ROOTHASH))") > + $(ROOT_FS_VERITY):verity:$$3 \ > + $(ROOT_FS):root:$$1 > mv $@.tmp $@ >=20=20 > build/loop.tar: build/live.img > diff --git a/host/rootfs/Makefile b/host/rootfs/Makefile > index fcfbc3e437fdb108252ba77d4d4e8f4f636ffd78..f02bb76371f000e3f65bb7c2a= 7f217d437845481 100644 > --- a/host/rootfs/Makefile > +++ b/host/rootfs/Makefile > @@ -90,9 +90,11 @@ clean: > .PHONY: clean >=20=20 > build/live.img: ../../scripts/format-uuid.sh ../../scripts/make-gpt.sh .= ./../scripts/sfdisk-field.awk $(ROOT_FS_DIR)/verity-timestamp $(ROOT_FS) > + uuids=3D$$(awk -f ../../scripts/format-uuid.awk < $(ROOT_FS_VERITY_ROOT= HASH)) && \ > + set -euo pipefail -- $$uuids && \ > bash ../../scripts/make-gpt.sh $@.tmp \ > - $(ROOT_FS)/rootfs.verity.superblock:verity:$$(../../scripts/format-= uuid.sh "$$(dd if=3D$(ROOT_FS_VERITY_ROOTHASH) bs=3D32 skip=3D1 count=3D1 s= tatus=3Dnone)") \ > - $(ROOT_FS)/rootfs:root:$$(../../scripts/format-uuid.sh "$$(head -c = 32 $(ROOT_FS_VERITY_ROOTHASH)") > + $(ROOT_FS_VERITY):verity:$$3 \ > + $(ROOT_FS):root:$$1 > mv $@.tmp $@ >=20=20 > debug: > diff --git a/release/live/Makefile b/release/live/Makefile > index a79947c57d562677760bc669c66320953a2b0d2d..78361a48512a37514ba0e57e0= cc8b0ec3a71664b 100644 > --- a/release/live/Makefile > +++ b/release/live/Makefile > @@ -9,11 +9,13 @@ DTBS ?=3D build/empty >=20=20 > dest =3D build/live.img >=20=20 > -$(dest): ../../scripts/format-uuid.sh ../../scripts/make-gpt.sh ../../sc= ripts/sfdisk-field.awk build/boot.fat $(ROOT_FS_IMAGES) > +$(dest): ../../scripts/format-uuid.awk ../../scripts/make-gpt.sh ../../s= cripts/sfdisk-field.awk build/boot.fat $(ROOT_FS_IMAGES) > + uuids=3D$$(awk -f ../../scripts/format-uuid.awk < $(ROOT_FS_VERITY_ROOT= HASH)) && \ > + set -euo pipefail -- $$uuids && \ > bash ../../scripts/make-gpt.sh $@.tmp \ > build/boot.fat:c12a7328-f81f-11d2-ba4b-00a0c93ec93b \ > - $(ROOT_FS_VERITY):verity:$$(../../scripts/format-uuid.sh "$$(dd if= =3D$(ROOT_FS_VERITY_ROOTHASH) bs=3D32 skip=3D1 count=3D1 status=3Dnone)") \ > - $(ROOT_FS):root:$$(../../scripts/format-uuid.sh "$$(head -c 32 $(RO= OT_FS_VERITY_ROOTHASH))") > + $(ROOT_FS_VERITY):verity:$$3 \ > + $(ROOT_FS):root:$$1 > mv $@.tmp $@ >=20=20 > build/empty: > diff --git a/release/live/default.nix b/release/live/default.nix > index ac2d7a55fd4fe0c02108309ecea20e368000af0d..98cb4862e239e3ad9ddbd7b5a= ce5716f57df683b 100644 > --- a/release/live/default.nix > +++ b/release/live/default.nix > @@ -29,7 +29,7 @@ stdenv.mkDerivation { > fileset =3D lib.fileset.intersection src (lib.fileset.unions [ > ./. > ../../lib/common.mk > - ../../scripts/format-uuid.sh > + ../../scripts/format-uuid.awk > ../../scripts/make-gpt.sh > ../../scripts/sfdisk-field.awk > ]); > diff --git a/scripts/format-uuid.awk b/scripts/format-uuid.awk > new file mode 100644 > index 0000000000000000000000000000000000000000..a5349d68a4d29be5f75065023= 6420c9b5a7257eb > --- /dev/null > +++ b/scripts/format-uuid.awk > @@ -0,0 +1,35 @@ > +# SPDX-License-Identifier: EUPL-1.2+ > +# SPDX-FileCopyrightText: 2025 Demi Marie Obenour > +function format_uuid(arg) { > + if (arg in found_so_far) { > + fail("Duplicate UUID, try changing the image (by even 1 bit)"); > + } This doesn't really feel like the right place for this check? If duplicate UUIDs are broken that should be detected when assembling the partition table. > + found_so_far[arg] =3D 1; > + print (substr(arg, 1, 8) "-" \ > + substr(arg, 9, 4) "-" \ > + substr(arg, 13, 4) "-" \ > + substr(arg, 17, 4) "-" \ > + substr(arg, 21, 12)); > +} > + > +function fail(msg) { > + print msg > "/dev/stderr"; > + exit 1; > +} > + > +BEGIN { > + FS =3D ""; > + RS =3D "\n"; RS is \n by default. > + if ((getline) !=3D 1) No need for the inner parens. > + fail("Empty input file"); > + roothash =3D $0; > + if (roothash !~ /^[a-f0-9]{64}$/) > + fail("Invalid root hash"); > + if (getline) > + fail("Junk after root hash"); This will only ever be used by our build system. It'll be readily apparent if it's providing junk even without these validations, and without them the script would be shorter and easier to fit in my brain. > + found_so_far[""] =3D ""; What does this do? Won't this just cause the script to falsely claim an empty string is a duplicate UUID if it ever ends up being passed to format_uuid()? > + for (i =3D 1; i !=3D 49; i +=3D 16) { > + format_uuid(substr($0, i, 32)); > + } Either unrolling the loop, or using a modulo inside the loop and getting rid of the format_uuid() call afterwards, would have helped me figure out what this does a lot quicker, but I see now that we're generating the two UUIDs we had before, and then two additional UUIDs offset into the string. I guess this is something to do with having multiple copies of the OS installed, but I wish I understood how the offset ones will be used without having to go hunting in later patches and come back here afterwards. > + format_uuid(substr($0, 49, 16) substr($0, 1, 16)); > +} --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEARYKAB0WIQQGoGac7QfI+H5ZtFCZddwkt31pFQUCaSWo+wAKCRCZddwkt31p FXI3AP9vn3iSE7TcBHkNvtIVJHT+cYRZd+EC2VBSL7GLyo4LqQEA3AtcV2kqnIWv 5ZGH92Jd/M0U9nRJ+QsWcdrj/x9VKgI= =VLui -----END PGP SIGNATURE----- --=-=-=--