Add Container Runner purpose build and installed serial-console policy

This commit is contained in:
Pavel Isaev 2026-11-10 01:01:56 +03:00
parent 6f65019dbb
commit 5a287d9fdf
8 changed files with 281 additions and 10 deletions

View file

@ -6,10 +6,10 @@ binary=$(realpath "$3")
profile=${4:-core}
output_kind=${ARCHIPELAGO_BUILD_OUTPUT:-iso}
[[ $output_kind == iso || $output_kind == ostree ]] || { echo 'Invalid build output' >&2; exit 1; }
[[ $profile == core || $profile == gnome-probe ]]
[[ $profile == core || $profile == gnome-probe || $profile == container-runner ]]
core_bind=()
if [[ $profile == gnome-probe ]]; then
core_input=$(realpath "${ARCHIPELAGO_CORE_BUILD:?GNOME requires an existing Core build artifact}")
if [[ $profile != core ]]; then
core_input=$(realpath "${ARCHIPELAGO_CORE_BUILD:?Purpose builds require an existing Core build artifact}")
test -d "$core_input/repo"
core_bind=(--bind-ro="$core_input:/core-input")
fi
@ -73,7 +73,7 @@ fi
grep -q '^DisableSandbox' "$toolroot/etc/pacman.conf" || sed -i '/\[options\]/a DisableSandbox\nNoProgressBar' "$toolroot/etc/pacman.conf"
install -m755 "$binary" "$work/archipelago"
printf '%s\n' "$profile" > "$work/build-profile"
if [[ $profile == gnome-probe ]]; then
if [[ $profile != core ]]; then
test -f "$core_input/repo/refs/heads/layers/core"
cp "$core_input/repo/refs/heads/layers/core" "$work/core-layer.commit"
cat > "$work/layer-delta.py" <<'ARCHIPELAGO_LAYER_DELTA'
@ -105,6 +105,11 @@ PACKAGES
printf '%s %s\n' 3371dd250e61d9e1633630073fefda153cd4426f72f4afa0c3373ae2e8fea03a "$work/flathub.flatpakrepo" | sha256sum -c -
fi
fi
if [[ $profile == container-runner ]]; then
cat > "$work/container-runner-packages.txt" <<'PACKAGES'
# CONTAINER_RUNNER_PACKAGE_LIST
PACKAGES
fi
cat > "$work/build-in-container.sh" <<'BUILD'
set -euxo pipefail
export LC_ALL=C
@ -126,7 +131,9 @@ mkdir -p /job/core /job/evidence /job/output
cat > /job/package.sh <<'PACKAGE'
@@PACKAGE_SCRIPT@@
PACKAGE
if [[ $ARCHIPELAGO_BUILD_PROFILE == gnome-probe ]]; then
if [[ $ARCHIPELAGO_BUILD_PROFILE == container-runner ]]; then
@@CONTAINER_RUNNER_LAYER_BUILD@@
elif [[ $ARCHIPELAGO_BUILD_PROFILE == gnome-probe ]]; then
@@GNOME_LAYER_BUILD@@
else
bash /job/package.sh
@ -179,7 +186,7 @@ ln -sfn /usr/share/zoneinfo/UTC /job/core/etc/localtime
mkdir -p /job/core/etc/systemd/network
cp /job/core/usr/lib/archipelago/defaults/20-wired.network /job/core/etc/systemd/network/
ln -sfn /run/systemd/resolve/stub-resolv.conf /job/core/etc/resolv.conf
systemctl --root=/job/core enable systemd-networkd systemd-resolved systemd-timesyncd sshd archipelago-ssh-keys archipelago-keyring archipelago-firstboot@tty1 archipelago-firstboot@ttyS0 getty@tty1 serial-getty@ttyS0 ostree-remount
systemctl --root=/job/core enable systemd-networkd systemd-resolved systemd-timesyncd sshd archipelago-ssh-keys archipelago-keyring archipelago-firstboot@tty1 getty@tty1 ostree-remount
# Generate every locale supplied by glibc, including non-UTF-8 variants. This
# shared Core output is inherited by every Purpose; never borrow host locales.
sed -i -E 's/^#[[:space:]]*([a-z][a-z][a-z]?_[A-Z][A-Z][^[:space:]]*[[:space:]]+[^[:space:]#]+)[[:space:]]*$/\1/' /job/core/etc/locale.gen
@ -271,6 +278,8 @@ EOF
rm -rf /job/profile/airootfs
if [[ $ARCHIPELAGO_BUILD_PROFILE == gnome-probe ]]; then
sed -i 's/iso_name="archipelago-core"/iso_name="archipelago-gnome-probe"/; s/Archipelago experimental lab/Archipelago private GNOME integration probe/' /job/profile/profiledef.sh
elif [[ $ARCHIPELAGO_BUILD_PROFILE == container-runner ]]; then
sed -i 's/iso_name="archipelago-core"/iso_name="archipelago-container-runner"/; s/Archipelago experimental lab/Archipelago Container Runner/' /job/profile/profiledef.sh
fi
mkdir -p /job/profile/airootfs/etc/mkinitcpio.conf.d /job/profile/airootfs/root
mkdir -p /job/profile/airootfs/etc/pacman.d
@ -334,6 +343,7 @@ iso=$(find /job/output -maxdepth 1 -name '*.iso' -print -quit)
[[ -n $iso ]]
output_name=archipelago-core-latest.iso
if [[ $ARCHIPELAGO_BUILD_PROFILE == gnome-probe ]]; then output_name=archipelago-gnome-probe.iso; fi
if [[ $ARCHIPELAGO_BUILD_PROFILE == container-runner ]]; then output_name=archipelago-container-runner.iso; fi
if [[ $iso != /job/output/$output_name ]]; then mv "$iso" "/job/output/$output_name"; fi
cd /job/output
sha256sum "$output_name" > SHA256SUMS

View file

@ -0,0 +1,24 @@
# Container Runner installed-system defaults. No graphical target or desktop stack.
systemctl --root=/job/core disable systemd-networkd archipelago-firstboot@ttyS0 getty@tty1 serial-getty@ttyS0
# Keep the console onboarding path; the installed system is a multi-user server.
systemctl --root=/job/core enable NetworkManager cockpit.socket
systemctl --root=/job/core set-default multi-user.target
mkdir -p /job/core/etc/cockpit /job/core/etc/NetworkManager/conf.d /job/core/etc/sudoers.d
# Cockpit's stock self-signed certificate; never allow plaintext or unauthenticated use.
printf '[WebService]\nAllowUnencrypted = false\n' > /job/core/etc/cockpit/cockpit.conf
printf '[main]\ndns=systemd-resolved\n' > /job/core/etc/NetworkManager/conf.d/20-archipelago.conf
printf '%%wheel ALL=(ALL:ALL) ALL\n' > /job/core/etc/sudoers.d/10-archipelago-wheel
chmod 0440 /job/core/etc/sudoers.d/10-archipelago-wheel
arch-chroot /job/core visudo -c
# binfmt registrations are applied by the statically enabled systemd-binfmt.service.
compgen -G '/job/core/usr/lib/binfmt.d/qemu-*.conf' >/dev/null
# Tailscale and firewalld are installed but deliberately not enabled; no keys,
# accounts or firewall rules are baked into the image.
test "$(systemctl --root=/job/core is-enabled tailscaled.service 2>/dev/null || true)" != enabled
test "$(systemctl --root=/job/core is-enabled firewalld.service 2>/dev/null || true)" != enabled
arch-chroot /job/core pacman --config /dev/null --dbpath /usr/lib/archipelago/package-db -Qq > /job/evidence/container-runner-package-names.txt
if grep -Ei '^(packagekit($|-)|libpackagekit)' /job/evidence/container-runner-package-names.txt; then
echo 'D-095: PackageKit is excluded from Container Runner' >&2
exit 1
fi
printf 'Container Runner: Cockpit enabled; Tailscale and firewall are operator actions\n' > /job/core/usr/lib/archipelago/container-runner-status

View file

@ -0,0 +1,149 @@
# Container Runner purpose layer; runs inside the isolated Arch builder.
# Composes a server Purpose from the cycle's immutable Core; no desktop stack.
test -f /core-input/evidence/databases.sha256
test -d /core-input/repo
rmdir /job/core
pacman -S --needed --noconfirm python
ostree --repo=/job/repo init --mode=archive
core_layer=$(cat /job/core-layer.commit)
ostree --repo=/job/repo pull-local /core-input/repo "$core_layer"
ostree --repo=/job/repo refs --create=layers/core "$core_layer"
ostree --repo=/job/repo checkout --force-copy --subpath=payload "$core_layer" /job/core-base
snapshot=$(cat /job/core-base/usr/lib/archipelago/snapshot)
printf '%s\n' "$core_layer" > /job/evidence/reused-core.commit
cp -a /core-input/evidence/*.db /job/evidence/
cp -a /core-input/package-repo /job/package-repo
cp -a /core-input/private-package-cache /job/private-package-cache
pacman-key --add /core-input/evidence/package-signer.asc
pacman-key --lsign-key "$(cat /core-input/evidence/package-signer.txt)"
cat >> /etc/pacman.conf <<'CORE_PACKAGE_REPOSITORY'
[archipelago]
SigLevel = Required
Server = file:///job/package-repo
CORE_PACKAGE_REPOSITORY
pacman -Sy --noconfirm
# Preserve the exact Core repository universe; never refresh target sync databases.
cp -a --reflink=auto /job/core-base /job/purpose-stage
stage=/job/purpose-stage
mv "$stage/usr/etc" "$stage/etc"
mkdir -p "$stage/var/lib" "$stage/dev" "$stage/proc" "$stage/sys" "$stage/run" "$stage/tmp"
mv "$stage/usr/lib/archipelago/package-db" "$stage/var/lib/pacman"
sed -i '/^DBPath = /d' "$stage/etc/pacman.conf"
test -f "$stage/var/lib/pacman/sync/multilib.db"
test -f "$stage/etc/pacman.d/archipelago-repos/base.conf"
printf '[multilib]\nInclude = /etc/pacman.d/mirrorlist\n' > "$stage/etc/pacman.d/archipelago-repos/multilib.conf"
cp -a /etc/pacman.d/gnupg "$stage/etc/pacman.d/"
mkdir -p "$stage/etc/pacman.d/hooks"
ln -sf /dev/null "$stage/etc/pacman.d/hooks/90-mkinitcpio-install.hook"
rm "$stage/etc/resolv.conf"
cp -L /etc/resolv.conf "$stage/etc/resolv.conf"
cp /etc/pacman.d/mirrorlist "$stage/etc/pacman.d/mirrorlist"
# Core intentionally contains factory accounts, reconciled by sysusers on boot.
# This isolated build root is not booted; provision its package-manager identity
# before pacman enables the standard alpm download sandbox. Factory accounts are
# restored below before capturing the Purpose payload.
arch-chroot "$stage" systemd-sysusers
printf 'ARCHIPELAGO_PHASE\tpackages\n'
mapfile -t purpose_packages < /job/container-runner-packages.txt
mkdir -p "$stage/var/cache/pacman/pkg"
# libalpm CheckSpace needs a mountpoint visible as / inside the chroot. Bind the
# disposable root and shared verified archive cache instead of disabling checks.
mount --bind "$stage" "$stage"
trap 'umount "$stage/var/cache/pacman/pkg" 2>/dev/null || true; umount "$stage" 2>/dev/null || true' EXIT
mount --bind /var/cache/pacman/pkg "$stage/var/cache/pacman/pkg"
# Local repository packages are part of the Core snapshot too. Expose its exact
# signed bytes at the file:// URL used by the preserved target pacman configuration.
test ! -e "$stage/job"
mkdir -p "$stage/job/package-repo"
cp -a /job/package-repo/. "$stage/job/package-repo/"
# Same-version private builds can have different bytes and signing keys. Match
# Core's cache ordering so stale shared-cache signatures cannot shadow this run.
cp -a /job/private-package-cache "$stage/job/private-package-cache"
sed -i '/\[options\]/a CacheDir = /job/private-package-cache\nCacheDir = /var/cache/pacman/pkg' "$stage/etc/pacman.conf"
arch-chroot "$stage" pacman -S --needed --noconfirm -- "${purpose_packages[@]}" 2>&1 | tee /job/evidence/purpose-transaction.log
rm -rf "$stage/job/package-repo" "$stage/job/private-package-cache"
rmdir "$stage/job"
umount "$stage/var/cache/pacman/pkg"
umount "$stage"
trap - EXIT
if grep -Ei 'error:|==> ERROR:' /job/evidence/purpose-transaction.log; then
echo 'Required Purpose transaction action failed' >&2; exit 1
fi
rm "$stage/etc/pacman.d/hooks/90-mkinitcpio-install.hook"
cp -a /job/core-base/usr/etc/pacman.d/hooks/. "$stage/etc/pacman.d/hooks/"
rm "$stage/etc/resolv.conf"
cp -a /job/core-base/usr/etc/resolv.conf "$stage/etc/resolv.conf"
for database in passwd shadow group gshadow; do
cp -a "/job/core-base/usr/etc/$database" "$stage/etc/$database"
# Shadow utilities also write backup databases containing staging identities.
rm -f "$stage/etc/$database-"
if [[ -e /job/core-base/usr/etc/$database- ]]; then
cp -a "/job/core-base/usr/etc/$database-" "$stage/etc/$database-"
fi
done
cp -a /job/core-base/usr/etc/pacman.conf "$stage/etc/pacman.conf"
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"
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.
pkg=/job/purpose-assets
mkdir -p "$pkg/runtime/usr/lib/archipelago/defaults" "$pkg/runtime/usr/lib/systemd/system" \
"$pkg/runtime/usr/lib/tmpfiles.d" "$pkg/runtime/usr/lib/systemd/system-preset"
cp /job/core-base/usr/lib/archipelago/defaults/os-release "$pkg/runtime/usr/lib/archipelago/defaults/"
cp /job/core-base/usr/lib/archipelago/mkinitcpio-core.conf "$pkg/runtime/usr/lib/archipelago/"
@@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/"
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 -b layers/purpose/server/container-runner --tree=dir=/job/purpose-layer \
--add-metadata-string=archipelago.snapshot="$snapshot")
printf '%s\n' "$purpose_layer" > /job/evidence/purpose-layer.commit
# Retain the original transaction output until commit checkout and composition
# have both validated the payload. A failed copy must not destroy its source.
ostree --repo=/job/repo checkout --force-copy "$purpose_layer" /job/purpose-input
python /job/layer-delta.py compose /job/core-base /job/purpose-input /job/composed
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
mv /job/core/usr/etc /job/core/etc
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.
# Match that representation before checking the package's reproducible mtree.
find /job/core/usr -exec touch -h -d @0 '{}' +
# A staging root has factory accounts and no machine keyring. Query only the local
# package DB, retaining the exact same integrity/permissions check as on the host.
cp -a /job/core/etc/pacman.conf /job/finalize-pacman.conf
printf '[options]\nDBPath = /usr/lib/archipelago/package-db/\n' > /job/core/etc/pacman.conf
arch-chroot /job/core archipelago self-check
mv /job/finalize-pacman.conf /job/core/etc/pacman.conf
arch-chroot /job/core /bin/bash -euxc 'k=$(basename /usr/lib/modules/*); depmod "$k"; mkinitcpio -c /usr/lib/archipelago/mkinitcpio-container-runner.conf -k "$k" -g "/usr/lib/modules/$k/initramfs.img"; ldconfig; systemd-hwdb update --usr'
arch-chroot /job/core /bin/bash -euc 'k=$(basename /usr/lib/modules/*); lsinitcpio "/usr/lib/modules/$k/initramfs.img"' > /job/evidence/container-runner-initramfs-files.txt
test -x /job/core/usr/bin/podman
test -f /job/core/usr/lib/systemd/system/cockpit.socket
test -f /job/core/usr/lib/systemd/system/tailscaled.service
# Inventory is a read-only local DB query: do not initialize repository trust or
# the download sandbox in a finalized root containing factory accounts.
arch-chroot /job/core pacman --config /dev/null --dbpath /usr/lib/archipelago/package-db -Q > /job/evidence/core-packages.txt
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
mv /job/core/etc /job/core/usr/etc
mv /job/core /job/composed
ostree --repo=/job/repo commit -b core --tree=dir=/job/composed \
--add-metadata-string=archipelago.snapshot="$snapshot" \
--add-metadata-string=archipelago.layer-core="$core_layer" \
--add-metadata-string=archipelago.layer-purpose="$purpose_layer"
ostree --repo=/job/repo pull-local /core-input/repo test-marker
test "$(ostree --repo=/core-input/repo rev-parse "$core_layer")" = "$core_layer"
printf 'Core reused: %s\nPurpose: %s\n' "$core_layer" "$purpose_layer" > /job/evidence/composition.txt
# Both trees are now reproducible from retained commits. Release scratch space
# before archiso creates its live root, squashfs and ISO concurrently.
rm -rf /job/composed /job/core-base

View file

@ -0,0 +1,35 @@
# Container Runner integration assets. Server Purpose; no desktop stack.
# Runs inside the isolated builder with $pkg pointing at the purpose assets.
sed 's/Archipelago Core/Archipelago Container Runner/g' \
"$pkg/runtime/usr/lib/archipelago/defaults/os-release" > "$pkg/runtime/usr/lib/archipelago/defaults/os-release-container-runner"
# Server initramfs: keep the Core profile, add keyboard/vconsole for rescue consoles.
sed -e 's/modconf block/modconf kms keyboard sd-vconsole block/' \
"$pkg/runtime/usr/lib/archipelago/mkinitcpio-core.conf" > "$pkg/runtime/usr/lib/archipelago/mkinitcpio-container-runner.conf"
printf 'Container Runner; operator-managed container host\n' > "$pkg/runtime/usr/lib/archipelago/container-runner"
mkdir -p "$pkg/runtime/usr/lib/systemd/system-preset" "$pkg/runtime/usr/share/archipelago/container-runner"
cat > "$pkg/runtime/usr/lib/systemd/system-preset/10-archipelago-container-runner.preset" <<'PRESET'
enable cockpit.socket
enable systemd-binfmt.service
disable tailscaled.service
disable firewalld.service
PRESET
# The Purpose owns its update ref: updates follow stable/container, never Core.
cat > "$pkg/runtime/usr/lib/archipelago/update.json" <<'JSON'
{
"version": 1,
"url": "https://mirror.nw-sys.ru/archipelago/ostree/images",
"refs": {"core": "stable/container"},
"public_key_file": "/usr/share/archipelago/keys/ostree.asc"
}
JSON
cat > "$pkg/runtime/usr/share/archipelago/container-runner/README" <<'EOF'
Container Runner defaults
- Cockpit is enabled on 9090 with its self-signed certificate.
- Tailscale is installed but intentionally disabled; connect it manually:
systemctl enable --now tailscaled && tailscale up
- firewalld is installed but intentionally disabled and carries no rules.
The operator decides which zones, services and ports to open.
- qemu-user-static binfmt registrations are enabled for foreign-architecture images.
- Container data is workload state in /var; OS updates and rollback do not remove it.
EOF

View file

@ -1,5 +1,5 @@
# Initial clean GNOME integration profile only; not a generic rebase adapter.
systemctl --root=/job/core disable systemd-networkd archipelago-firstboot@tty1 archipelago-firstboot@ttyS0 getty@tty1
systemctl --root=/job/core disable systemd-networkd archipelago-firstboot@tty1 archipelago-firstboot@ttyS0 getty@tty1 serial-getty@ttyS0
systemctl --root=/job/core enable NetworkManager gdm bluetooth cups.socket power-profiles-daemon switcheroo-control \
archipelago-gnome-onboarding.timer
systemctl --root=/job/core set-default graphical.target

View file

@ -1,5 +1,5 @@
# Clean Core + KDE composition; existing-machine rebase is a separate workflow.
systemctl --root=/job/core disable systemd-networkd archipelago-firstboot@tty1 archipelago-firstboot@ttyS0 getty@tty1
systemctl --root=/job/core disable systemd-networkd archipelago-firstboot@tty1 archipelago-firstboot@ttyS0 getty@tty1 serial-getty@ttyS0
systemctl --root=/job/core enable NetworkManager sddm plasma-setup bluetooth cups.socket power-profiles-daemon \
archipelago-kde-onboarding.timer archipelago-software-refresh.timer
systemctl --root=/job/core set-default graphical.target

View file

@ -133,6 +133,27 @@ RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
EOF
# D-100 follow-up: installed systems without a serial port must not keep
# starting ttyS0 getty/firstboot units. The drop-in makes an already-enabled
# Core service the rollout vector, so hosts updated from an older deployment
# receive the policy without a new preset run. The condition keeps the live ISO
# usable as a serial console, and the marker makes this a post-provision action.
cat > "$pkg/runtime/usr/lib/systemd/system/archipelago-serial-off.service" <<'EOF'
[Unit]
Description=Disable unused ttyS0 units on provisioned installed systems
ConditionPathExists=/run/ostree-booted
ConditionPathExists=!/run/archipelago-live
ConditionPathExists=/etc/archipelago/provisioned
After=systemd-user-sessions.service
[Service]
Type=oneshot
ExecStart=/usr/bin/bash -eu -c 'for unit in serial-getty@ttyS0.service getty@ttyS0.service archipelago-firstboot@ttyS0.service; do systemctl disable --now "$unit" >/dev/null 2>&1 || true; ln -sfn /dev/null "/etc/systemd/system/$unit"; done; systemctl daemon-reload'
EOF
mkdir -p "$pkg/runtime/usr/lib/systemd/system/multi-user.target.d"
cat > "$pkg/runtime/usr/lib/systemd/system/multi-user.target.d/30-archipelago-serial-off.conf" <<'EOF'
[Unit]
Wants=archipelago-serial-off.service
EOF
cat > "$pkg/runtime/usr/lib/tmpfiles.d/archipelago.conf" <<'EOF'
d /var/home 0755 root root -
d /var/roothome 0700 root root -
@ -156,7 +177,6 @@ AbortOnFail
EOF
cat > "$pkg/runtime/usr/lib/systemd/system-preset/20-archipelago.preset" <<'EOF'
enable archipelago-firstboot@tty1.service
enable archipelago-firstboot@ttyS0.service
enable archipelago-keyring.service
enable archipelago-ssh-keys.service
enable ostree-remount.service

View file

@ -41,6 +41,38 @@ fn render_iso(kde: bool) -> String {
}
/// KDE uses the same private composition path and the cycle's immutable Core.
/// Container Runner: server Purpose composed from the cycle's immutable Core.
pub fn build_container_runner_script() -> Result<String, String> {
let manifest = include_str!("../../purposes/proposals/container-runner.yaml");
let data = archipelago_contracts::layer::validate(manifest)?;
let packages = data["spec"]["packages"]["runtime"].as_array().ok_or("Missing Container Runner packages")?
.iter().map(|p| p["name"].as_str().ok_or("Invalid Container Runner package"))
.collect::<Result<Vec<_>, _>>()?.join("\n");
let assets = include_str!("../adapters/container-runner-package.sh");
let layer = include_str!("../adapters/container-runner-layer.sh")
.replace("@@CONTAINER_RUNNER_ASSETS@@", assets)
.replace("@@CONTAINER_RUNNER_FINALIZE@@", include_str!("../adapters/container-runner-finalize.sh"));
let package = include_str!("../adapters/package.sh")
.replace("@@PKGBUILD@@", include_str!("../../cli/packaging/PKGBUILD"))
.replace("@@SYSTEM_SERVICE@@", include_str!("../../system/integrations/dbus/archipelagod.service"))
.replace("@@SYSTEM_BUS_ACTIVATION@@", include_str!("../../system/integrations/dbus/org.archipelago.System1.service"))
.replace("@@SYSTEM_BUS_POLICY@@", include_str!("../../system/integrations/dbus/org.archipelago.System1.conf"))
.replace("@@SYSTEM_POLKIT_ACTIONS@@", include_str!("../../system/integrations/dbus/org.archipelago.system.policy"))
.replace("@@SYSTEM_POLKIT_RULES@@", include_str!("../../system/integrations/dbus/50-archipelago-system.rules"))
.replace("@@SYSTEM_BUS_XML@@", include_str!("../../contracts/dbus/org.archipelago.System1.xml"))
.replace("@@GNOME_PACKAGE@@", "");
Ok(include_str!("../adapters/build-iso.sh")
.replace("@@PACKAGE_SCRIPT@@", &package)
.replace("@@CONTAINER_RUNNER_LAYER_BUILD@@", &layer)
.replace("@@GNOME_LAYER_BUILD@@", ": # Container Runner does not use the GNOME layer")
.replace("@@GNOME_FINALIZE@@", ": # Container Runner finalizes inside its layer")
.replace("@@LAYER_DELTA@@", include_str!("../../composer/layer_delta.py"))
.replace("@@UPDATE_PROFILE@@", include_str!("../defaults/update.json"))
.replace("@@UPDATE_PUBLIC_KEY@@", include_str!("../../system/archipelago-stable.asc"))
.replace("@@FLATPAK_IMPORT@@", "# Container Runner does not import a Flatpak seed")
.replace("# CONTAINER_RUNNER_PACKAGE_LIST", &packages))
}
pub fn build_kde_probe_script() -> Result<String, String> {
let data = archipelago_contracts::layer::validate(include_str!("../../purposes/proposals/kde.yaml"))?;
let packages = data["spec"]["packages"]["runtime"].as_array().ok_or("Missing KDE packages")?
@ -65,7 +97,8 @@ mod tests {
use std::{io::Write, process::{Command, Stdio}};
#[test]
fn generated_profiles_are_valid_shell() {
for script in [build_iso_script(), build_gnome_probe_script().unwrap()] {
for script in [build_iso_script(), build_gnome_probe_script().unwrap(),
build_container_runner_script().unwrap()] {
assert!(!script.contains("@@"), "unexpanded source adapter placeholder");
let mut child = Command::new("bash").arg("-n").stdin(Stdio::piped()).spawn().unwrap();
child.stdin.take().unwrap().write_all(script.as_bytes()).unwrap();