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 7A31C1B28; Sat, 11 Jul 2026 20:14:21 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 993) id 3923A1A4B; Sat, 11 Jul 2026 20:14:17 +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-yx1-xb130.google.com (mail-yx1-xb130.google.com [IPv6:2607:f8b0:4864:20::b130]) by atuin.qyliss.net (Postfix) with ESMTPS id 54E1C1A49 for ; Sat, 11 Jul 2026 20:14:16 +0000 (UTC) Received: by mail-yx1-xb130.google.com with SMTP id 956f58d0204a3-664db84f074so2965290d50.0 for ; Sat, 11 Jul 2026 13:14:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783800855; x=1784405655; darn=spectrum-os.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=HflqOFYYI4edBmaFvgYMXVwL3VPchAB7mLxD1kqAwA8=; b=SsQOp5ERLRXObPMquuunrP7dbu88jTyDtzfq9R6s0NQNw56DiVaLuUlVA5txsNPALV GueXGEqnLhPkvHkiOkFi+6j2vrET6i7GxsLpdSlO1t+tRZkpAQmTU2EXLvJ4UrTGwGdq d5NxIpz6jw64AJ4006v5bNu88I/FZVyZTYhFXULUSCajOJxR6+V2gXQFdo921gEB6ui2 ckMTX0WfoKs8tT0eX6XTA5o79fli2CWeZI7Zu3im/kSyRo8cDt06Gq5do2MIdbFVqP9w cb43phKIyaDpRDbJdatDHMdBxPRDw48pq1XSoXE9coajrInygpGXlJchDxcS/7X9tuyI o/ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783800855; x=1784405655; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=HflqOFYYI4edBmaFvgYMXVwL3VPchAB7mLxD1kqAwA8=; b=svoXnprP5V69giE+6/ooa3DQpbEM3mUGaiWaj6B55S97H0uLbOf436sIi+b+fazMfG 8rcW4JPDYLiDkxb4uECwLKPh9TIij/A4Be4wxUHUG3FV803ZrsBkScUxFCh4JQGS7VYl t5HMcTuY50eauhFpqQsC7RdTBWHwxW/pTJp9O1Uc1ZrN0dGlrxxpZaDdWqtjz0RpU4Ot IbnuElWaaq7JcKs2QpUbKBx5X4TNz1RLrYGOkm/fGThMFKh14bHVrF8E+0GQzEzMy4OD iGYE1i9YUjwC6IN3bGz5ji3LRAw+ojfLVG5V+gf+swFXCY12og4p9i2iamQvdIQO1T/C k3qg== X-Gm-Message-State: AOJu0YxQ1Fo3HTT3iGsSzifnrWB6iaSVQHDWHRuCljrPnEmqifaDU65i CcG4HcDqdSNk/vOSGij049ENt9MFStJSsvINEjKFcECEcgZfvemNW/dGieJ7lg== X-Gm-Gg: AfdE7cl8CCoG+P8zM6WYVyKm2tE1pWQk/o7/WHaYc7EHK59aSfPNTgSKJscsV2lliII gYBXuw3bLJoH5228xGwVNKhSGHYZLDbqkXkZaKO1eFWlJvI0eel8uLtuE+KVvMBPIfu+dRLeala eooIZGk6YegqJ3P1QrHFS7J6HpPhIwb+n9IZj4DMyVLslK7j7LlEvAvGwpVp2JWdtRk+VMqkeKf t/5tWy5NrH6P2r6AHuYaT1eSAnFnG1fmj8AuOxnWuGD9lno5Kp7tnFszF9/W2uAi+2+cybqqZUd u/QHqEpBtceZOT+efmFLiIDNU1wkD7ID8w2Ona4Tutet1uTemGpdwo5uXx5WnkiS0qCQqQYSTjt IQpriebBdD/LP/n27JmrfF9ILwGHB32mJQAk3/48N9qTi73PY9Qh6ygRHGpXuNqDFOr4Oc7fuHT RVFdu5WvwYbsNmhfg+hiGmzuejQiBF4/eP2YPa X-Received: by 2002:a05:690c:360a:b0:814:651e:a553 with SMTP id 00721157ae682-81e900a3c9bmr28862867b3.28.1783800855015; Sat, 11 Jul 2026 13:14:15 -0700 (PDT) Received: from localhost.localdomain ([185.98.168.14]) by smtp.gmail.com with UTF8SMTPSA id 00721157ae682-81e6bf7ab9bsm77570797b3.20.2026.07.11.13.14.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jul 2026 13:14:14 -0700 (PDT) From: Demi Marie Obenour Date: Sat, 11 Jul 2026 16:12:06 -0400 Subject: [PATCH v3 02/22] scripts: Support symlinks in s6-rc-compile inputs MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260711-cgroups-v3-2-5cba61a20cba@gmail.com> References: <20260711-cgroups-v3-0-5cba61a20cba@gmail.com> In-Reply-To: <20260711-cgroups-v3-0-5cba61a20cba@gmail.com> To: Spectrum OS Development X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1783800724; l=12546; i=demiobenour@gmail.com; s=20250729; h=from:subject:message-id; bh=fFfMPtQTS+STRfllIQKDEkaATERYlGCjm3WmFW7Q0oo=; b=8S34R4erioEwLyR7sseecSnAcwhW3+UcLOJk+UzNUAXnYcNhzlyrRvLVrcUPgsGqyQtBhJHgf BKdo5s9QnJeDIYk5cyNNdpv1sW9fQ/HZfU8x5Fo/c7tYI5U8MByQAHR X-Developer-Key: i=demiobenour@gmail.com; a=ed25519; pk=X57Q4/YQDj9t4SBeKaDwvXYKB6quZJVx/DE2Ly2out0= Message-ID-Hash: UA53DIHKZDF4H4O22ESES5ZJGOZICR3W X-Message-ID-Hash: UA53DIHKZDF4H4O22ESES5ZJGOZICR3W X-MailFrom: demiobenour@gmail.com X-Mailman-Rule-Hits: member-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; 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; emergency CC: Demi Marie Obenour , Alyssa Ross X-Mailman-Version: 3.3.10 Precedence: list List-Id: Patches and low-level development discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Finish scripts can (and often will) be symbolic links to /usr/bin/cgroup-setup. This requires makefile changes, so take the opportunity to move some of the make code to a new lib/targets.mk. Signed-off-by: Demi Marie Obenour --- host/rootfs/Makefile | 32 ++++---------------------------- host/rootfs/default.nix | 1 + host/rootfs/file-list.mk | 2 ++ img/app/Makefile | 23 +++-------------------- img/app/default.nix | 1 + img/app/file-list.mk | 2 ++ lib/targets.mk | 30 ++++++++++++++++++++++++++++++ release/live/Makefile | 12 ++++-------- release/live/default.nix | 1 + scripts/genfiles.awk | 13 ++++++++++++- vm/sys/net/Makefile | 19 ++++--------------- vm/sys/net/default.nix | 1 + vm/sys/net/file-list.mk | 2 ++ 13 files changed, 67 insertions(+), 72 deletions(-) diff --git a/host/rootfs/Makefile b/host/rootfs/Makefile index 4f01e3ecce83558b786542ebbeedb7ff3b4c17a5..4c6233ba355ed7208de64df6c1b929aacfb52bbe 100644 --- a/host/rootfs/Makefile +++ b/host/rootfs/Makefile @@ -4,7 +4,8 @@ .POSIX: -include ../../lib/common.mk +ROOT = ../.. +include $(ROOT)/lib/common.mk include file-list.mk ROOT_FS = build @@ -85,33 +86,6 @@ build/etc/os-release: mkdir -p build/etc sed 's/@VERSION@/$(VERSION)/g' < os-release.in > build/etc/os-release -build/fifo: - mkdir -p build - mkfifo -m 0600 $@ - -build/empty: - mkdir -p $@ - -# s6-rc-compile's input is a directory, but that doesn't play nice -# with Make, because it won't know to update if some file in the -# directory is changed, or a file is created or removed in a -# subdirectory. Using the whole source directory could also end up -# including files that aren't intended to be part of the input, like -# temporary editor files or .license files. So for all these reasons, -# only explicitly listed files are made available to s6-rc-compile. -build/etc/s6-rc: $(S6_RC_FILES) file-list.mk - mkdir -p $$(dirname $@) - rm -rf $@ - set -uo pipefail && dir=$$(mktemp -d) && \ - { tar -c $(S6_RC_FILES) | tar -C $$dir -x --strip-components 3; } && \ - s6-rc-compile $@ $$dir; \ - exit=$$?; rm -r $$dir; exit $$exit - -clean: - -chmod -Rf +w build - rm -rf build -.PHONY: clean - build/live.img: ../../scripts/format-uuid.sh ../../scripts/make-gpt.sh ../../scripts/sfdisk-field.awk build/verity-timestamp $(ROOT_FS_IMAGES) ../../scripts/make-gpt.sh $@.tmp \ $(ROOT_FS_VERITY):verity:$$(../../scripts/format-uuid.sh "$$(dd if=$(ROOT_FS_VERITY_ROOTHASH) bs=32 skip=1 count=1 status=none)"):Spectrum_'$(VERSION).verity' \ @@ -155,3 +129,5 @@ run: build/empty build/live.img $(ROOTFS_VERITY_ROOTHASH) -vga none \ -device vhost-vsock-pci,guest-cid=3 .PHONY: run + +include $(ROOT)/lib/targets.mk diff --git a/host/rootfs/default.nix b/host/rootfs/default.nix index 6bfeefbe0a5f76c1538ccb40e5eb8f291f5d3592..4dcc10b9933cdfaf87f87417db1de0daa57b73f5 100644 --- a/host/rootfs/default.nix +++ b/host/rootfs/default.nix @@ -116,6 +116,7 @@ stdenvNoCC.mkDerivation { fileset = fileset.intersection src (fileset.unions [ ./. ../../lib/common.mk + ../../lib/targets.mk ../../scripts/make-erofs.sh ]); }; diff --git a/host/rootfs/file-list.mk b/host/rootfs/file-list.mk index 3899d620717fc97f42e669e5313c4100dcf5b1cd..7e44fc612a5a9ac8767be9148cdc71869ef16964 100644 --- a/host/rootfs/file-list.mk +++ b/host/rootfs/file-list.mk @@ -111,3 +111,5 @@ S6_RC_FILES = \ image/etc/s6-rc/weston/notification-fd \ image/etc/s6-rc/weston/run \ image/etc/s6-rc/weston/type + +S6_RC_LINKS = diff --git a/img/app/Makefile b/img/app/Makefile index 3996831120c1aa831e44a18579b1f5bbac7cb776..42793725f26af43605c5ae95a2dc78ca1c49efe9 100644 --- a/img/app/Makefile +++ b/img/app/Makefile @@ -4,7 +4,8 @@ .POSIX: -include ../../lib/common.mk +ROOT = ../.. +include $(ROOT)/lib/common.mk include file-list.mk prefix = build/host @@ -39,13 +40,6 @@ FIFOS = etc/s6-linux-init/run-image/service/s6-linux-init-shutdownd/fifo BUILD_FILES = build/etc/s6-rc -build/fifo: - mkdir -p build - mkfifo -m 0600 $@ - -build/empty: - mkdir -p $@ - build/rootfs.erofs: ../../scripts/make-erofs.sh $(PACKAGES_FILE) $(FILES) $(BUILD_FILES) build/empty build/fifo file-list.mk set -euo pipefail; \ { \ @@ -56,15 +50,6 @@ build/rootfs.erofs: ../../scripts/make-erofs.sh $(PACKAGES_FILE) $(FILES) $(BUIL printf 'build/fifo\n%s\n' $(FIFOS) ;\ } | ../../scripts/make-erofs.sh $@ - -build/etc/s6-rc: $(S6_RC_FILES) file-list.mk - mkdir -p $$(dirname $@) - rm -rf $@ - set -uo pipefail && dir=$$(mktemp -d) && \ - { tar -c $(S6_RC_FILES) | tar -C $$dir -x --strip-components 3; } && \ - s6-rc-compile $@ $$dir; \ - exit=$$?; rm -r $$dir; exit $$exit - debug: $(GDB) -q \ -ex 'set substitute-path .. $(LINUX_SRC)' \ @@ -144,6 +129,4 @@ run-crosvm: $(imgdir)/appvm/blk/root.img start-vhost-user-gpu start-virtiofsd run: run-$(VMM) .PHONY: run -clean: - rm -rf build -.PHONY: clean +include $(ROOT)/lib/targets.mk diff --git a/img/app/default.nix b/img/app/default.nix index 71e6fa02e78553d027d59f5b2ff728830276d480..97f4cc75d620c93c6f5a6de7c7069cf3d39f25b5 100644 --- a/img/app/default.nix +++ b/img/app/default.nix @@ -104,6 +104,7 @@ stdenvNoCC.mkDerivation { fileset = lib.fileset.intersection src (lib.fileset.unions [ ./. ../../lib/common.mk + ../../lib/targets.mk ../../scripts/make-erofs.sh ../../scripts/make-gpt.sh ../../scripts/sfdisk-field.awk diff --git a/img/app/file-list.mk b/img/app/file-list.mk index 815b63ab2a4f2d11f63ce5593fecefa979c13eba..6312c361b629430629661be30332fac38ca0be73 100644 --- a/img/app/file-list.mk +++ b/img/app/file-list.mk @@ -71,3 +71,5 @@ S6_RC_FILES = \ image/etc/s6-rc/wireplumber/dependencies.d/pipewire \ image/etc/s6-rc/wireplumber/run \ image/etc/s6-rc/wireplumber/type + +S6_RC_LINKS = diff --git a/lib/targets.mk b/lib/targets.mk new file mode 100644 index 0000000000000000000000000000000000000000..2d6d2682df2ed070b3f6075913fcfc0e6a803bbb --- /dev/null +++ b/lib/targets.mk @@ -0,0 +1,30 @@ +# SPDX-License-Identifier: EUPL-1.2+ +# SPDX-FileCopyrightText: 2021, 2023, 2024, 2025 Alyssa Ross +# SPDX-FileCopyrightText: 2025 Demi Marie Obenour + +build/fifo: + mkdir -p build + mkfifo -m 0600 $@ + +build/empty: + mkdir -p $@ + +# s6-rc-compile's input is a directory, but that doesn't play nice +# with Make, because it won't know to update if some file in the +# directory is changed, or a file is created or removed in a +# subdirectory. Using the whole source directory could also end up +# including files that aren't intended to be part of the input, like +# temporary editor files or .license files. So for all these reasons, +# only explicitly listed files are made available to s6-rc-compile. +build/etc/s6-rc: $(S6_RC_FILES) file-list.mk + mkdir -p $$(dirname $@) + rm -rf $@ + set -uo pipefail && dir=$$(mktemp -d) && \ + { tar -c $(S6_RC_FILES) $(S6_RC_LINKS) | tar -C $$dir -x --strip-components 3; } && \ + s6-rc-compile $@ $$dir; \ + exit=$$?; rm -r $$dir; exit $$exit + +clean: + -chmod -Rf +w build + rm -rf build +.PHONY: clean diff --git a/release/live/Makefile b/release/live/Makefile index 85319d0eec06df4e7ab1e28030e3bb78608194df..f984bc8d5a93733a246ccc901674be06bbcbb69e 100644 --- a/release/live/Makefile +++ b/release/live/Makefile @@ -3,7 +3,8 @@ .POSIX: -include ../../lib/common.mk +ROOT = ../.. +include $(ROOT)/lib/common.mk dest = build/live.img @@ -24,13 +25,6 @@ build/boot.fat: $(SYSTEMD_BOOT_EFI) $(SPECTRUM_EFI) $(MCOPY) -i $@ $(SPECTRUM_EFI) ::/EFI/Linux/'Spectrum_$(VERSION).efi' $(MCOPY) -i $@ $(SYSTEMD_BOOT_EFI) ::/EFI/BOOT/$(EFINAME) -build/empty: - mkdir -p $@ - -clean: - rm -rf build -.PHONY: clean - run: build/empty $(dest) @set -xueo pipefail && \ img="$$(mktemp build/spectrum-rootfs.XXXXXXXXX.img)" && \ @@ -61,3 +55,5 @@ run: build/empty $(dest) -drive file=/proc/self/fd/3,id=drive1,format=raw,if=none \ -drive file=/proc/self/fd/4,if=virtio,format=raw .PHONY: run + +include $(ROOT)/lib/targets.mk diff --git a/release/live/default.nix b/release/live/default.nix index aa8dddd68497ced322961a6b551b73fe5ab4c475..403183226570ec318fbf7fddecfd52fd7c133c7e 100644 --- a/release/live/default.nix +++ b/release/live/default.nix @@ -28,6 +28,7 @@ stdenv.mkDerivation { fileset = lib.fileset.intersection src (lib.fileset.unions [ ./. ../../lib/common.mk + ../../lib/targets.mk ../../scripts/format-uuid.sh ../../scripts/make-gpt.sh ../../scripts/sfdisk-field.awk diff --git a/scripts/genfiles.awk b/scripts/genfiles.awk index 2d32016b5e6d6773685b71cc04e49cf24e842ba9..35e8538e75cc67f0a2ec8bc7b1be403a3f6604f0 100644 --- a/scripts/genfiles.awk +++ b/scripts/genfiles.awk @@ -6,6 +6,7 @@ BEGIN { modes["120000"] = "symlink"; modes["100644"] = "regular"; modes["100755"] = "regular"; + rc_count = rc_link_count = file_count = symlink_count = 0; } function fail(msg) { @@ -34,6 +35,10 @@ filename !~ /^[[:alnum:]_./-]+$/ { filename ~ /\.license$/ { next } filename ~ /^image\/etc\/s6-rc\// { + if (mode == "symlink") { + rc_links[rc_link_count++] = filename; + next; + } if (mode != "regular") { fail("s6-rc-compile input '" filename "' isn't a regular file"); } @@ -77,9 +82,15 @@ END { for (array_index = 0; array_index < symlink_count; array_index += 1) { printf " \\\n\t%s", symlinks[array_index]; } - printf "\n\nS6_RC_FILES ="; + printf "\n\n" \ +"S6_RC_FILES ="; for (array_index = 0; array_index < rc_count; array_index += 1) { printf " \\\n\t%s", rc_files[array_index]; } + printf "\n\n" \ +"S6_RC_LINKS ="; + for (array_index = 0; array_index < rc_link_count; array_index += 1) { + printf " \\\n\t%s", rc_links[array_index]; + } print ""; } diff --git a/vm/sys/net/Makefile b/vm/sys/net/Makefile index e37fe8ca161106f9c6492b2f8b5d68d48ae945de..a1258432b39175839b7f2f6c2535e75197910679 100644 --- a/vm/sys/net/Makefile +++ b/vm/sys/net/Makefile @@ -3,7 +3,9 @@ .POSIX: -include ../../../lib/common.mk +ROOT = ../../.. +ROOT_FS = build +include $(ROOT)/lib/common.mk include file-list.mk prefix = build/host @@ -33,9 +35,6 @@ DIRS = dev etc/s6-linux-init/env proc run sys BUILD_FILES = build/etc/s6-rc -build/empty: - mkdir -p $@ - build/rootfs.erofs: ../../../scripts/make-erofs.sh $(PACKAGES_FILE) $(FILES) $(BUILD_FILES) build/empty file-list.mk set -euo pipefail; \ { \ @@ -45,14 +44,6 @@ build/rootfs.erofs: ../../../scripts/make-erofs.sh $(PACKAGES_FILE) $(FILES) $(B printf 'build/empty\n%s\n' $(DIRS) ;\ } | ../../../scripts/make-erofs.sh $@ -build/etc/s6-rc: $(S6_RC_FILES) file-list.mk - mkdir -p $$(dirname $@) - rm -rf $@ - set -uo pipefail && dir=$$(mktemp -d) && \ - { tar -c $(S6_RC_FILES) | tar -C $$dir -x --strip-components 3; } && \ - s6-rc-compile $@ $$dir; \ - exit=$$?; rm -r $$dir; exit $$exit - debug: $(GDB) -q \ -ex 'set substitute-path .. $(LINUX_SRC)' \ @@ -108,6 +99,4 @@ run-crosvm: $(vmdir)/netvm/blk/root.img start-vhost-user-net run: run-$(VMM) .PHONY: run -clean: - rm -rf build -.PHONY: clean +include $(ROOT)/lib/targets.mk diff --git a/vm/sys/net/default.nix b/vm/sys/net/default.nix index a722b021dc30f80e01dc626393a2f0311a75dc9d..df5fe7b1aa370c8b620dc18e565ca7fabde25f38 100644 --- a/vm/sys/net/default.nix +++ b/vm/sys/net/default.nix @@ -110,6 +110,7 @@ stdenvNoCC.mkDerivation { fileset = lib.fileset.intersection src (lib.fileset.unions [ ./. ../../../lib/common.mk + ../../../lib/targets.mk ../../../scripts/make-erofs.sh ../../../scripts/make-gpt.sh ../../../scripts/sfdisk-field.awk diff --git a/vm/sys/net/file-list.mk b/vm/sys/net/file-list.mk index c8d6d8ccb569c988f5de804244d800fe05784d05..e13bf1c32a290e6d0a9465d14bed8da2049a65f7 100644 --- a/vm/sys/net/file-list.mk +++ b/vm/sys/net/file-list.mk @@ -33,3 +33,5 @@ S6_RC_FILES = \ image/etc/s6-rc/nftables/up \ image/etc/s6-rc/ok-all/contents.d/mdevd-coldplug \ image/etc/s6-rc/ok-all/type + +S6_RC_LINKS = -- 2.55.0