From 82829ca470acfc20ef6af8525327035cc14cfc25 Mon Sep 17 00:00:00 2001 From: Archipelago Date: Fri, 13 Nov 2026 23:06:05 +0300 Subject: [PATCH] Purpose layers: merge /etc payload into usr/etc instead of nesting it A purpose asset package (or any package shipping usr/etc) made 'mv etc usr/etc' move one tree inside the other, so the composed root /etc appeared and the finalizer lost /etc/pacman.conf: 'cp: cannot stat /job/core/etc/pacman.conf'. This is why plasma-meta and the KDE keyboard defaults could not be composed. - Merge the two trees when both exist, and assert the invariant that the layer payload has no root /etc and keeps usr/etc/pacman.conf. - Do the same defense in depth after composition and before the final mv. - Apply the identical fix to the Container Runner layer. --- adapters/container-runner-layer.sh | 28 +++++++++++++++++++++++++++- adapters/gnome-layer.sh | 28 +++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/adapters/container-runner-layer.sh b/adapters/container-runner-layer.sh index 161bb37..cd306af 100644 --- a/adapters/container-runner-layer.sh +++ b/adapters/container-runner-layer.sh @@ -87,7 +87,15 @@ cp -a /job/core-base/usr/etc/pacman.d/mirrorlist "$stage/etc/pacman.d/mirrorlist rm -rf "$stage/etc/pacman.d/gnupg" rm -f "$stage/etc/.pwd.lock" mv "$stage/var/lib/pacman" "$stage/usr/lib/archipelago/package-db" -mv "$stage/etc" "$stage/usr/etc" +# The layer payload stores machine configuration at /usr/etc (Core's layout). +# A plain rename nests the trees when a package already created usr/etc, which +# would push every Core default one level down instead of merging the two. +if [[ -d $stage/usr/etc ]]; then + cp -a "$stage/etc/." "$stage/usr/etc/" + rm -rf "$stage/etc" +else + mv "$stage/etc" "$stage/usr/etc" +fi for db in /job/evidence/*.db; do cmp "$db" "$stage/usr/lib/archipelago/package-db/sync/$(basename "$db")"; done # Distribution integration is a separately indexed Purpose contribution. Preserve # Core package bytes and use distinct Purpose configuration paths. @@ -99,6 +107,15 @@ cp /job/core-base/usr/lib/archipelago/mkinitcpio-core.conf "$pkg/runtime/usr/lib @@CONTAINER_RUNNER_ASSETS@@ rm "$pkg/runtime/usr/lib/archipelago/defaults/os-release" "$pkg/runtime/usr/lib/archipelago/mkinitcpio-core.conf" cp -a "$pkg/runtime/." "$stage/" +# Purpose assets are package payload too. Anything they ship under /etc belongs +# to the layer's /usr/etc; a root /etc here would collide with the composed +# machine configuration and make finalization lose pacman.conf (D-110 follow-up). +if [[ -d $stage/etc ]]; then + cp -a "$stage/etc/." "$stage/usr/etc/" + rm -rf "$stage/etc" +fi +test ! -e "$stage/etc" +test -f "$stage/usr/etc/pacman.conf" printf 'ARCHIPELAGO_PHASE\tcompose\n' python /job/layer-delta.py capture /job/core-base "$stage" /job/purpose-layer purpose/server/container-runner purpose_layer=$(ostree --repo=/job/repo commit --fsync=0 -b layers/purpose/server/container-runner --tree=dir=/job/purpose-layer \ @@ -112,7 +129,15 @@ printf 'ARCHIPELAGO_PHASE\tfinalize\n' rm -rf /job/purpose-stage /job/purpose-layer /job/purpose-input # All work below operates on the composition, never the immutable input layers. mv /job/composed /job/core +# Defense in depth: a composed root /etc (a payload that bypassed the layer +# normalization) is merged, never nested. `mv` into an existing directory would +# quietly bury the Core defaults as /etc/etc and lose pacman.conf. +if [[ -d /job/core/etc ]]; then + cp -a "/job/core/etc/." /job/core/usr/etc/ + rm -rf /job/core/etc +fi mv /job/core/usr/etc /job/core/etc +test -f /job/core/etc/pacman.conf cp /job/core/usr/lib/archipelago/defaults/os-release-container-runner /job/core/etc/os-release @@CONTAINER_RUNNER_FINALIZE@@ # Force-copy checkout timestamps are host-local; deployments use OSTree's epoch. @@ -135,6 +160,7 @@ arch-chroot /job/core pacman --config /dev/null --dbpath /usr/lib/archipelago/pa cp /job/evidence/core-packages.txt /job/core/usr/lib/archipelago/packages.txt (cd /job/core; sha256sum usr/share/libalpm/hooks/*.hook) > /job/core/usr/lib/archipelago/hook-policy/hooks.sha256 find /job/core/usr/lib/archipelago/package-db/local -name install -exec sha256sum '{}' + > /job/core/usr/lib/archipelago/hook-policy/scriptlets.sha256 +test ! -e /job/core/usr/etc mv /job/core/etc /job/core/usr/etc mv /job/core /job/composed ostree --repo=/job/repo commit --fsync=0 -b core --tree=dir=/job/composed \ diff --git a/adapters/gnome-layer.sh b/adapters/gnome-layer.sh index 9d284db..c501ea7 100644 --- a/adapters/gnome-layer.sh +++ b/adapters/gnome-layer.sh @@ -87,7 +87,15 @@ cp -a /job/core-base/usr/etc/pacman.d/mirrorlist "$stage/etc/pacman.d/mirrorlist rm -rf "$stage/etc/pacman.d/gnupg" rm -f "$stage/etc/.pwd.lock" mv "$stage/var/lib/pacman" "$stage/usr/lib/archipelago/package-db" -mv "$stage/etc" "$stage/usr/etc" +# The layer payload stores machine configuration at /usr/etc (Core's layout). +# A plain rename nests the trees when a package already created usr/etc, which +# would push every Core default one level down instead of merging the two. +if [[ -d $stage/usr/etc ]]; then + cp -a "$stage/etc/." "$stage/usr/etc/" + rm -rf "$stage/etc" +else + mv "$stage/etc" "$stage/usr/etc" +fi for db in /job/evidence/*.db; do cmp "$db" "$stage/usr/lib/archipelago/package-db/sync/$(basename "$db")"; done # Distribution integration is a separately indexed Purpose contribution. Preserve # Core package bytes and use distinct Purpose configuration paths. @@ -99,6 +107,15 @@ cp /job/core-base/usr/lib/archipelago/mkinitcpio-core.conf "$pkg/runtime/usr/lib @@GNOME_ASSETS@@ rm "$pkg/runtime/usr/lib/archipelago/defaults/os-release" "$pkg/runtime/usr/lib/archipelago/mkinitcpio-core.conf" cp -a "$pkg/runtime/." "$stage/" +# Purpose assets are package payload too. Anything they ship under /etc belongs +# to the layer's /usr/etc; a root /etc here would collide with the composed +# machine configuration and make finalization lose pacman.conf (D-110 follow-up). +if [[ -d $stage/etc ]]; then + cp -a "$stage/etc/." "$stage/usr/etc/" + rm -rf "$stage/etc" +fi +test ! -e "$stage/etc" +test -f "$stage/usr/etc/pacman.conf" printf 'ARCHIPELAGO_PHASE\tcompose\n' python /job/layer-delta.py capture /job/core-base "$stage" /job/purpose-layer purpose_layer=$(ostree --repo=/job/repo commit --fsync=0 -b layers/purpose/desktop/gnome --tree=dir=/job/purpose-layer \ @@ -112,7 +129,15 @@ printf 'ARCHIPELAGO_PHASE\tfinalize\n' rm -rf /job/purpose-stage /job/purpose-layer /job/purpose-input # All work below operates on the composition, never the immutable input layers. mv /job/composed /job/core +# Defense in depth: a composed root /etc (a payload that bypassed the layer +# normalization) is merged, never nested. `mv` into an existing directory would +# quietly bury the Core defaults as /etc/etc and lose pacman.conf. +if [[ -d /job/core/etc ]]; then + cp -a "/job/core/etc/." /job/core/usr/etc/ + rm -rf /job/core/etc +fi mv /job/core/usr/etc /job/core/etc +test -f /job/core/etc/pacman.conf cp /job/core/usr/lib/archipelago/defaults/os-release-gnome /job/core/etc/os-release @@GNOME_FINALIZE@@ # Force-copy checkout timestamps are host-local; deployments use OSTree's epoch. @@ -134,6 +159,7 @@ arch-chroot /job/core pacman --config /dev/null --dbpath /usr/lib/archipelago/pa cp /job/evidence/core-packages.txt /job/core/usr/lib/archipelago/packages.txt (cd /job/core; sha256sum usr/share/libalpm/hooks/*.hook) > /job/core/usr/lib/archipelago/hook-policy/hooks.sha256 find /job/core/usr/lib/archipelago/package-db/local -name install -exec sha256sum '{}' + > /job/core/usr/lib/archipelago/hook-policy/scriptlets.sha256 +test ! -e /job/core/usr/etc mv /job/core/etc /job/core/usr/etc mv /job/core /job/composed ostree --repo=/job/repo commit --fsync=0 -b core --tree=dir=/job/composed \