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 452E8CB42; Sat, 22 Nov 2025 01:22:38 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 993) id 5F9E2CB21; Sat, 22 Nov 2025 01:22:35 +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.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DMARC_PASS,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=4.0.1 Received: from mail-yw1-x112f.google.com (mail-yw1-x112f.google.com [IPv6:2607:f8b0:4864:20::112f]) by atuin.qyliss.net (Postfix) with ESMTPS id 15C52CAFB for ; Sat, 22 Nov 2025 01:22:34 +0000 (UTC) Received: by mail-yw1-x112f.google.com with SMTP id 00721157ae682-787ff3f462bso40222387b3.0 for ; Fri, 21 Nov 2025 17:22:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763774551; x=1764379351; darn=spectrum-os.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=doI23jFITG3lV8T+G9tV1D/xIhoCFyWmm7VMwkKkVb4=; b=eEmn3hSvS3wKefTsNXI/bMTT+/4C4o/rwUBBf84vG9IxoK+PNTC75UP66eRs+8Skaj uoalGzvHm/QNKgbzCWMH9z4Tj9D0Vv2kmbHln2Ver+MhsvIJwouKtmlfnSxTrtY+Qykc n+J1RDi12kf3Ig5OyRpTcSkSllEtm2PLIIoCzE6MIgO8voW7H+Y4RN9zcMbm9srXtlaq zMpEHps7Om2bldsKFfkzkAO5NVaeTGHTt7MAdDrWNI+r6JMDNEHRJyD3Jzc+K5+z8Tw4 BSUMvmGefGOntAoUUf48B41P9nOEIntMIonZzIbi/2qcPvF3uAS0vS0b/u9qZ0jZCO6Q Y60w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763774551; x=1764379351; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=doI23jFITG3lV8T+G9tV1D/xIhoCFyWmm7VMwkKkVb4=; b=iD46RBJYRLThnRk0enBzyCuKZu+b7udBJI25a7/vYiholNaDwGriPobkNlCy1KQg16 YUY0g8LwJXD+0mtjFEQQe7DaYj0mO/0lh8KbZvtnLKVIAZk5DQFHTPkYcrO+/9x21fv7 RwgSCEeH1w1IDSKDuE4HzR+lxQhr3JPYt3fZGblBquabDjBAEDEGaor1xjM6RYGO1fDU +bJrXmoBF9jPI63I2PreIrhlg4bJ92WrpcBUMlxJH1ODfMtSh02+YF516U2KnmSrfjOf qNSMqsIo1tsj3TrmnStROQIly7HQy0Unue9lBKR9KeNocGaJvs7bOtC+Ot28xH7nrxcT PRDQ== X-Gm-Message-State: AOJu0Yy6hx0jGxC/kSCC+dbxtnrgluqoUz/4A7X0jeMB+uqrQdQ/AYWz s21MJW76MEn4915RX5li4BSW/tBl8q14oqyum40WCwglJ2sUsJBIz5+3PNl2Hw== X-Gm-Gg: ASbGnctsVIzdgMC2PQ5vjZmnGSZ88RrrC28jeeYZ3UNd9MYFs0pbXAwa+PXVUwaycPP QlwHiGPR+1KFdcWkm/9O+xdt7Y1MbuTEWifzjUl7c4V71/+KBCVqSnFye1agyaTwl6vwgP55r26 WlzEiDNBGN8pmlA77TZMziMzs13K534rqtKwNR1rurmx3CTlVQEa9f0m6Q6TKdhH6nIjtGbfRQY Tluh526vEqUtymsvQCbfuSeEzMB883cyD+uuPPlU1tFB+TjTUY4OSGRaFxCl8NBE/xWXt/3cxBI Sf2bhnekSmNiQbydMJfl6e8IVypW1GD7v4+vwIroOK/AyOz+T5T9dEs+j7fzg9sxaWjw6K3mqX5 BrWiHupE4rmKCXXauslPM2jD/emq3rhrBy9yxM8l21Uy1siqoac/Fs5zfs3sS2EcgeGPPFQwhhH M+MlAyJuWoc1y0rp/287VBETceaX0DzG4FGQUqX1UHfN/SLkYIhYFECaO3mQ4FA/+lftbyO91Je HwWAFcu61KZuEexDV7v1XoraAnKKW+mm4I= X-Google-Smtp-Source: AGHT+IF8rnJJgBy9EB41OaU+ivAm1ennFEMkmW/hKXkNJ2JSWyAjdppaZZ6FaGKpyfIFYqYQvzKrAg== X-Received: by 2002:a05:690e:1905:b0:63e:1113:bde2 with SMTP id 956f58d0204a3-642f8e2dbbamr6429691d50.20.1763774550875; Fri, 21 Nov 2025 17:22:30 -0800 (PST) Received: from localhost.localdomain (h96-60-249-169.cncrtn.broadband.dynamic.tds.net. [96.60.249.169]) by smtp.gmail.com with UTF8SMTPSA id 956f58d0204a3-642f7178819sm2230348d50.13.2025.11.21.17.22.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Nov 2025 17:22:30 -0800 (PST) From: Demi Marie Obenour Date: Fri, 21 Nov 2025 20:21:51 -0500 Subject: [PATCH v5 1/2] Build verity images in rootfs Nix derivation MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20251121-refactor-verity-v5-1-938fc95f9752@gmail.com> References: <20251121-refactor-verity-v5-0-938fc95f9752@gmail.com> In-Reply-To: <20251121-refactor-verity-v5-0-938fc95f9752@gmail.com> To: Spectrum OS Development X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1763774511; l=15127; i=demiobenour@gmail.com; s=20250729; h=from:subject:message-id; bh=Zw3D3AD/V221iXvaT+CpNuXCAYxZKOMaPXNjwNOgVDg=; b=YVHWhJHD3DzLVnnSCAZdBUeJS/YJ3gwp31wRv/+vkcUUwUCPzAdEMgtJYmGacc2MYBrzEJIeV eHucXhLyeYJC0oZp77/hynmP+giztFOb+WXomdTe8f77eqEIq+0KcFL X-Developer-Key: i=demiobenour@gmail.com; a=ed25519; pk=X57Q4/YQDj9t4SBeKaDwvXYKB6quZJVx/DE2Ly2out0= Message-ID-Hash: VBTAWWSSFZSLTJTNIN7436OQZF3O4SJL X-Message-ID-Hash: VBTAWWSSFZSLTJTNIN7436OQZF3O4SJL X-MailFrom: demiobenour@gmail.com 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: Demi Marie Obenour , Alyssa Ross 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: Avoid redundant rebuilds of the rootfs verity superblock and roothash. Remove duplicate code. Clean up Makefile to avoid temporary files. Signed-off-by: Demi Marie Obenour --- host/initramfs/Makefile | 26 +++++-------------------- host/initramfs/default.nix | 1 + host/initramfs/shell.nix | 2 +- host/rootfs/Makefile | 47 ++++++++++++++++++++++------------------------ host/rootfs/default.nix | 6 ++++-- host/rootfs/shell.nix | 2 +- lib/common.mk | 4 ++++ release/live/Makefile | 26 +++++-------------------- release/live/default.nix | 2 +- release/live/shell.nix | 3 ++- 10 files changed, 46 insertions(+), 73 deletions(-) diff --git a/host/initramfs/Makefile b/host/initramfs/Makefile index cb13fbb35f065b67d291d4a35591d6f12720060c..13bb548d6146684a25dab1e31228c0b9a4ca8db7 100644 --- a/host/initramfs/Makefile +++ b/host/initramfs/Makefile @@ -35,26 +35,10 @@ build/mountpoints: cd build/mountpoints && mkdir -p $(MOUNTPOINTS) find build/mountpoints -mindepth 1 -exec touch -d @0 {} ';' -# veritysetup format produces two files, but Make only (portably) -# supports one output per rule, so we combine the two outputs then -# define two more rules to separate them again. -build/rootfs.verity: $(ROOT_FS) - mkdir -p build - $(VERITYSETUP) format $(ROOT_FS) build/rootfs.verity.superblock.tmp \ - | awk -F ':[[:blank:]]*' '$$1 == "Root hash" {print $$2; exit}' \ - > build/rootfs.verity.roothash.tmp - cat build/rootfs.verity.roothash.tmp build/rootfs.verity.superblock.tmp \ - > $@ - rm build/rootfs.verity.roothash.tmp build/rootfs.verity.superblock.tmp -build/rootfs.verity.roothash: build/rootfs.verity - head -n 1 build/rootfs.verity > $@ -build/rootfs.verity.superblock: build/rootfs.verity - tail -n +2 build/rootfs.verity > $@ - -build/live.img: ../../scripts/format-uuid.sh ../../scripts/make-gpt.sh ../../scripts/sfdisk-field.awk build/rootfs.verity.superblock build/rootfs.verity.roothash $(ROOT_FS) +build/live.img: ../../scripts/format-uuid.sh ../../scripts/make-gpt.sh ../../scripts/sfdisk-field.awk $(ROOT_FS_IMAGES) ../../scripts/make-gpt.sh $@.tmp \ - build/rootfs.verity.superblock:verity:$$(../../scripts/format-uuid.sh "$$(dd if=build/rootfs.verity.roothash bs=32 skip=1 count=1 status=none)") \ - $(ROOT_FS):root:$$(../../scripts/format-uuid.sh "$$(head -c 32 build/rootfs.verity.roothash)") + $(ROOT_FS_VERITY):verity:$$(../../scripts/format-uuid.sh "$$(dd if=$(ROOT_FS_VERITY_ROOTHASH) bs=32 skip=1 count=1 status=none)") \ + $(ROOT_FS):root:$$(../../scripts/format-uuid.sh "$$(head -c 32 $(ROOT_FS_VERITY_ROOTHASH))") mv $@.tmp $@ build/loop.tar: build/live.img @@ -69,12 +53,12 @@ clean: rm -rf build .PHONY: clean -run: $(dest) build/rootfs.verity.roothash $(RUN_IMAGE) +run: $(dest) $(RUN_IMAGE) $(ROOT_FS_VERITY_ROOTHASH) @../../scripts/run-qemu.sh -m 4G \ -machine virtualization=on \ -kernel $(KERNEL) \ -initrd $(dest) \ - -append "ro earlycon console=hvc0 intel_iommu=on roothash=$$(< build/rootfs.verity.roothash) nokaslr" \ + -append "ro earlycon console=hvc0 intel_iommu=on roothash=$$(< "$$ROOT_FS_VERITY_ROOTHASH") nokaslr" \ -cpu max \ -gdb unix:build/gdb.sock,server,nowait \ -parallel none \ diff --git a/host/initramfs/default.nix b/host/initramfs/default.nix index d35e1b514ec48015f5110e65e5ae944b28244c4f..88f9379444148a071ef0de45132415fba0f6c12e 100644 --- a/host/initramfs/default.nix +++ b/host/initramfs/default.nix @@ -105,6 +105,7 @@ stdenvNoCC.mkDerivation { env = { PACKAGES_CPIO = packagesCpio; + ROOT_FS_DIR = rootfs; } // lib.optionalAttrs stdenvNoCC.hostPlatform.isx86_64 { MICROCODE = microcode; }; diff --git a/host/initramfs/shell.nix b/host/initramfs/shell.nix index 8b47aa53bc19a818ebf563e281f22e82202a8ea5..ff067354881b480656fae9b339a0a9068475d85f 100644 --- a/host/initramfs/shell.nix +++ b/host/initramfs/shell.nix @@ -17,6 +17,6 @@ initramfs.overrideAttrs ({ nativeBuildInputs ? [], env ? {}, ... }: { env = env // { KERNEL = "${rootfs.kernel}/${stdenv.hostPlatform.linux-kernel.target}"; - ROOT_FS = rootfs; + ROOT_FS_DIR = rootfs; }; })) (_: {}) diff --git a/host/rootfs/Makefile b/host/rootfs/Makefile index 4067be0c45cc83ce4670ed76e956db58f8e93e02..5e3c9238f0e00f86aa5943212b8fc8fd896ce54a 100644 --- a/host/rootfs/Makefile +++ b/host/rootfs/Makefile @@ -1,12 +1,12 @@ # SPDX-License-Identifier: EUPL-1.2+ # SPDX-FileCopyrightText: 2021-2024 Alyssa Ross +# SPDX-FileCopyrightText: 2025 Demi Marie Obenour .POSIX: include ../../lib/common.mk include file-list.mk - -dest = build/rootfs.erofs +ROOT_FS_DIR = build DIRS = \ dev \ @@ -40,15 +40,27 @@ FIFOS = etc/s6-linux-init/run-image/service/s6-svscan-log/fifo BUILD_FILES = build/etc/s6-rc -$(dest): ../../scripts/make-erofs.sh $(PACKAGES_FILE) $(FILES) $(BUILD_FILES) build/empty build/fifo file-list.mk - set -euo pipefail; \ +build/verity-timestamp: $(ROOT_FS) + $(VERITYSETUP) format \ + --root-hash-file $(ROOT_FS_VERITY_ROOTHASH) \ + -- $(ROOT_FS) $(ROOT_FS_VERITY) + # Add trailing newline + echo >> $(ROOT_FS_VERITY_ROOTHASH) + touch -- $(ROOT_FS_DIR)/verity-timestamp + +# This rule produces three files but Make only (portably) +# supports one output per rule. Instead of resorting to temporary +# files, a timestamp file is created as the last step. The actual +# outputs are produced as side-effects. +$(ROOT_FS): ../../scripts/make-erofs.sh $(PACKAGES_FILE) $(FILES) $(BUILD_FILES) build/empty build/fifo file-list.mk + mkdir -p $(ROOT_FS_DIR) && \ { \ cat $(PACKAGES_FILE) ;\ for file in $(FILES) $(LINKS); do printf '%s\n%s\n' $$file "$${file#image/}"; done ;\ for file in $(BUILD_FILES); do printf '%s\n%s\n' $$file $${file#build/}; done ;\ printf 'build/empty\n%s\n' $(DIRS) ;\ printf 'build/fifo\n%s\n' $(FIFOS) ;\ - } | ../../scripts/make-erofs.sh $@ + } | ../../scripts/make-erofs.sh $(ROOT_FS) build/fifo: mkdir -p build @@ -77,25 +89,10 @@ clean: rm -rf build .PHONY: clean -# veritysetup format produces two files, but Make only (portably) -# supports one output per rule, so we combine the two outputs then -# define two more rules to separate them again. -build/rootfs.verity: $(dest) - $(VERITYSETUP) format $(dest) build/rootfs.verity.superblock.tmp \ - | awk -F ':[[:blank:]]*' '$$1 == "Root hash" {print $$2; exit}' \ - > build/rootfs.verity.roothash.tmp - cat build/rootfs.verity.roothash.tmp build/rootfs.verity.superblock.tmp \ - > $@ - rm build/rootfs.verity.roothash.tmp build/rootfs.verity.superblock.tmp -build/rootfs.verity.roothash: build/rootfs.verity - head -n 1 build/rootfs.verity > $@ -build/rootfs.verity.superblock: build/rootfs.verity - tail -n +2 build/rootfs.verity > $@ - -build/live.img: ../../scripts/format-uuid.sh ../../scripts/make-gpt.sh ../../scripts/sfdisk-field.awk build/rootfs.verity.superblock build/rootfs.verity.roothash $(dest) +build/live.img: ../../scripts/format-uuid.sh ../../scripts/make-gpt.sh ../../scripts/sfdisk-field.awk $(ROOT_FS_DIR)/verity-timestamp $(ROOT_FS) ../../scripts/make-gpt.sh $@.tmp \ - build/rootfs.verity.superblock:verity:$$(../../scripts/format-uuid.sh "$$(dd if=build/rootfs.verity.roothash bs=32 skip=1 count=1 status=none)") \ - $(dest):root:$$(../../scripts/format-uuid.sh "$$(head -c 32 build/rootfs.verity.roothash)") + $(ROOT_FS)/rootfs.verity.superblock:verity:$$(../../scripts/format-uuid.sh "$$(dd if=$(ROOT_FS_VERITY_ROOTHASH) bs=32 skip=1 count=1 status=none)") \ + $(ROOT_FS)/rootfs:root:$$(../../scripts/format-uuid.sh "$$(head -c 32 $(ROOT_FS_VERITY_ROOTHASH)") mv $@.tmp $@ debug: @@ -105,7 +102,7 @@ debug: $(VMLINUX) .PHONY: debug -run: build/live.img build/rootfs.verity.roothash +run: build/live.img @set -x && \ ext="$$(mktemp build/spectrum-rootfs-extfs.XXXXXXXXXX.img)" && \ truncate -s 10G "$$ext" && \ @@ -126,7 +123,7 @@ run: build/live.img build/rootfs.verity.roothash -device virtconsole,chardev=virtiocon0 \ -drive file=build/live.img,if=virtio,format=raw,readonly=on \ -drive file=/proc/self/fd/3,if=virtio,format=raw \ - -append "earlycon console=hvc0 roothash=$$(< build/rootfs.verity.roothash) intel_iommu=on nokaslr" \ + -append "earlycon console=hvc0 roothash=$$(< $(ROOT_FS_VERITY_ROOTHASH)) intel_iommu=on nokaslr" \ -device virtio-keyboard \ -device virtio-mouse \ -device virtio-gpu \ diff --git a/host/rootfs/default.nix b/host/rootfs/default.nix index 0ac70c7c077c0656c5820a5d8b3c7ce0e7c78e54..1578155fa0fb9a4df3fb4884e21ed7d8d8f821dc 100644 --- a/host/rootfs/default.nix +++ b/host/rootfs/default.nix @@ -138,7 +138,7 @@ stdenvNoCC.mkDerivation { }; sourceRoot = "source/host/rootfs"; - nativeBuildInputs = [ erofs-utils spectrum-build-tools s6-rc ]; + nativeBuildInputs = [ cryptsetup erofs-utils spectrum-build-tools s6-rc ]; env = { PACKAGES = runCommand "packages" {} '' @@ -147,7 +147,9 @@ stdenvNoCC.mkDerivation { ''; }; - makeFlags = [ "dest=$(out)" ]; + # The Makefile uses $(ROOT_FS_DIR), not $(dest), so it can share code + # with other Makefiles that also use this variable. + makeFlags = [ "ROOT_FS_DIR=$(out)" ]; dontInstall = true; diff --git a/host/rootfs/shell.nix b/host/rootfs/shell.nix index 1bf61bebf418333624e799cc8ca231f5783206f4..6df2f575fdfc7cdf8067ccfdb5fecaad9f6ea5e6 100644 --- a/host/rootfs/shell.nix +++ b/host/rootfs/shell.nix @@ -12,7 +12,7 @@ rootfs.overrideAttrs ( { nativeBuildInputs = nativeBuildInputs ++ [ - btrfs-progs cryptsetup jq netcat qemu_kvm reuse util-linux + btrfs-progs jq netcat qemu_kvm reuse util-linux ]; env = env // { diff --git a/lib/common.mk b/lib/common.mk index 277c3544036d9a9057f8ba4ad37fe2207548cc59..d1cc4d0514070cc3f418c4d1b7e929abd40d985c 100644 --- a/lib/common.mk +++ b/lib/common.mk @@ -11,6 +11,10 @@ GDB = gdb MCOPY = mcopy MKFS_FAT = mkfs.fat MMD = mmd +ROOT_FS = $(ROOT_FS_DIR)/rootfs +ROOT_FS_IMAGES = $(ROOT_FS) $(ROOT_FS_VERITY_ROOTHASH) $(ROOT_FS_VERITY) +ROOT_FS_VERITY = $(ROOT_FS_DIR)/rootfs.verity.superblock +ROOT_FS_VERITY_ROOTHASH = $(ROOT_FS_DIR)/rootfs.verity.roothash S6_IPCSERVER_SOCKETBINDER = s6-ipcserver-socketbinder TAR = tar TRUNCATE = truncate diff --git a/release/live/Makefile b/release/live/Makefile index 6dcbdeedda5d6ccf293f60dc62043f46c81ecf83..7372b41d94bfb10f7761955d9d1a246e9785b7f8 100644 --- a/release/live/Makefile +++ b/release/live/Makefile @@ -9,17 +9,17 @@ DTBS ?= build/empty dest = build/live.img -$(dest): ../../scripts/format-uuid.sh ../../scripts/make-gpt.sh ../../scripts/sfdisk-field.awk build/boot.fat build/rootfs.verity.superblock build/rootfs.verity.roothash $(ROOT_FS) +$(dest): ../../scripts/format-uuid.sh ../../scripts/make-gpt.sh ../../scripts/sfdisk-field.awk build/boot.fat $(ROOT_FS_IMAGES) ../../scripts/make-gpt.sh $@.tmp \ build/boot.fat:c12a7328-f81f-11d2-ba4b-00a0c93ec93b \ - build/rootfs.verity.superblock:verity:$$(../../scripts/format-uuid.sh "$$(dd if=build/rootfs.verity.roothash bs=32 skip=1 count=1 status=none)") \ - $(ROOT_FS):root:$$(../../scripts/format-uuid.sh "$$(head -c 32 build/rootfs.verity.roothash)") + $(ROOT_FS_VERITY):verity:$$(../../scripts/format-uuid.sh "$$(dd if=$(ROOT_FS_VERITY_ROOTHASH) bs=32 skip=1 count=1 status=none)") \ + $(ROOT_FS):root:$$(../../scripts/format-uuid.sh "$$(head -c 32 $(ROOT_FS_VERITY_ROOTHASH))") mv $@.tmp $@ build/empty: mkdir -p $@ -build/spectrum.efi: build/rootfs.verity.roothash $(DTBS) $(KERNEL) $(INITRAMFS) +build/spectrum.efi: $(DTBS) $(KERNEL) $(INITRAMFS) $(ROOT_FS_VERITY_ROOTHASH) { \ printf "[UKI]\nDeviceTreeAuto=" && \ find $(DTBS) -name '*.dtb' -print0 | tr '\0' ' ' ;\ @@ -29,7 +29,7 @@ build/spectrum.efi: build/rootfs.verity.roothash $(DTBS) $(KERNEL) $(INITRAMFS) --linux $(KERNEL) \ --initrd $(INITRAMFS) \ --os-release $$'NAME="Spectrum"\n' \ - --cmdline "ro intel_iommu=on roothash=$$(cat build/rootfs.verity.roothash)" + --cmdline "ro intel_iommu=on roothash=$$(cat $(ROOT_FS_VERITY_ROOTHASH))" build/boot.fat: $(SYSTEMD_BOOT_EFI) build/spectrum.efi $(TRUNCATE) -s 440401920 $@ @@ -38,22 +38,6 @@ build/boot.fat: $(SYSTEMD_BOOT_EFI) build/spectrum.efi $(MCOPY) -i $@ build/spectrum.efi ::/EFI/Linux $(MCOPY) -i $@ $(SYSTEMD_BOOT_EFI) ::/EFI/BOOT/$(EFINAME) -# veritysetup format produces two files, but Make only (portably) -# supports one output per rule, so we combine the two outputs then -# define two more rules to separate them again. -build/rootfs.verity: $(ROOT_FS) - mkdir -p build - $(VERITYSETUP) format $(ROOT_FS) build/rootfs.verity.superblock.tmp \ - | awk -F ':[[:blank:]]*' '$$1 == "Root hash" {print $$2; exit}' \ - > build/rootfs.verity.roothash.tmp - cat build/rootfs.verity.roothash.tmp build/rootfs.verity.superblock.tmp \ - > $@ - rm build/rootfs.verity.roothash.tmp build/rootfs.verity.superblock.tmp -build/rootfs.verity.roothash: build/rootfs.verity - head -n 1 build/rootfs.verity > $@ -build/rootfs.verity.superblock: build/rootfs.verity - tail -n +2 build/rootfs.verity > $@ - clean: rm -rf build .PHONY: clean diff --git a/release/live/default.nix b/release/live/default.nix index 2a1dc3e1dd939f21edac582bf39737eb4d46eb0c..7adaefef330daf11372cff0d2d04cca400efba1f 100644 --- a/release/live/default.nix +++ b/release/live/default.nix @@ -46,7 +46,7 @@ stdenv.mkDerivation { env = { INITRAMFS = initramfs; KERNEL = "${rootfs.kernel}/${stdenv.hostPlatform.linux-kernel.target}"; - ROOT_FS = rootfs; + ROOT_FS_DIR = rootfs; SYSTEMD_BOOT_EFI = "${systemd}/lib/systemd/boot/efi/systemd-boot${efiArch}.efi"; EFINAME = "BOOT${toUpper efiArch}.EFI"; } // lib.optionalAttrs stdenv.hostPlatform.linux-kernel.DTB or false { diff --git a/release/live/shell.nix b/release/live/shell.nix index 5acaa8c5b113fd2789aaea9268487b193bab37af..c5db7b732ef048b4c0cb87a4c5ea614e993db516 100644 --- a/release/live/shell.nix +++ b/release/live/shell.nix @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # SPDX-FileCopyrightText: 2021-2024 Alyssa Ross -import ../../lib/call-package.nix ({ callSpectrumPackage, stdenv, qemu_kvm }: +import ../../lib/call-package.nix ({ callSpectrumPackage, stdenv, qemu_kvm, rootfs }: (callSpectrumPackage ./. {}).overrideAttrs ( { nativeBuildInputs ? [], env ? {}, ... }: @@ -10,6 +10,7 @@ import ../../lib/call-package.nix ({ callSpectrumPackage, stdenv, qemu_kvm }: env = env // { OVMF_CODE = "${qemu_kvm}/share/qemu/edk2-${stdenv.hostPlatform.qemuArch}-code.fd"; + ROOT_FS_DIR = rootfs; }; } )) (_: {}) -- 2.52.0