- Follow AGENTS.md style: headers start with the file's name, short notes are full sentences, comments within 80 columns. - Build with mkosi's tools tree, pinned to the image's release (ToolsTreeRelease=%r): rawhide's repositories made the image rawhide. - Incremental builds with mkosi.cache/ for faster local rebuilds. - Hostname= instead of systemd.hostname= on the kernel command line. - mkosi.finalize: bash, no cd, and L+ for /etc/systemd. PID 1 applies the presets at first boot and made /etc/systemd/system, which blocked the link, so /etc/systemd/user (the user's D-Bus) was missing. - Disable homed, userdbd and nsresourced with presets instead of deleting their units. Drop modules the kernel has built in. - mkosi.version adds the git commit to the version. - One dev container per worktree or session in CLAUDE.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
26 files changed
+205
-243
No files matched your search
+28
-22
@@ -1,42 +1,48 @@
|
||||
#!/bin/sh
|
||||
# Factory /etc
|
||||
#
|
||||
# The image ships only /usr (mkosi.repart), so this keeps the /etc that the
|
||||
# packages and mkosi.extra/etc made in /usr/share/factory/etc. It writes
|
||||
# /usr/lib/tmpfiles.d/factory-etc.conf, with which systemd-tmpfiles links each
|
||||
# entry into the writable, empty /etc at boot. Updates to /usr then take
|
||||
# effect in /etc too. /etc itself holds only what the machine writes: passwd,
|
||||
# shadow, group, hostname, machine-id and the ssh host keys.
|
||||
set -eu
|
||||
#!/bin/bash
|
||||
# mkosi.finalize keeps the /etc that the packages and mkosi.extra/etc made in
|
||||
# /usr/share/factory/etc, because the image ships only /usr (mkosi.repart). It
|
||||
# writes /usr/lib/tmpfiles.d/factory-etc.conf, with which systemd-tmpfiles
|
||||
# links each entry into the writable, empty /etc at boot. Updates to /usr then
|
||||
# take effect in /etc too. /etc itself holds only what the machine writes:
|
||||
# passwd, shadow, group, machine-id and the ssh host keys.
|
||||
set -euo pipefail
|
||||
|
||||
factory=$BUILDROOT/usr/share/factory/etc
|
||||
cp -a --no-target-directory --update=none "$BUILDROOT/etc" "$factory"
|
||||
|
||||
# skip holds what /etc keeps for itself, and what other tmpfiles.d files
|
||||
# already set up, such as /etc/os-release.
|
||||
skip=$(printf '%s\n' passwd group shadow gshadow hostname machine-id ssh
|
||||
skip=$(printf '%s\n' passwd group shadow gshadow machine-id ssh
|
||||
sed -n 's|^[^#][^ ]* */etc/\([^/ ]*\).*|\1|p' "$BUILDROOT"/usr/lib/tmpfiles.d/*.conf)
|
||||
|
||||
# link prints the tmpfiles line for /etc/$1. Some entries are copied instead:
|
||||
# a symlink, because a relative one would point somewhere else from the
|
||||
# factory, and subuid and subgid, because shadow-utils won't read them through
|
||||
# a link.
|
||||
#
|
||||
# systemd gets L+, which replaces a directory. At first boot, PID 1 applies the
|
||||
# presets before systemd-tmpfiles runs, and so makes /etc/systemd/system. That
|
||||
# would block the link, and with it /etc/systemd/user and later updates.
|
||||
link() {
|
||||
case "$1" in
|
||||
subuid|subgid) echo "C /etc/$1" ;;
|
||||
*) if [ -L "$factory/$1" ]; then echo "C /etc/$1"; else echo "L /etc/$1"; fi ;;
|
||||
esac
|
||||
if [[ $1 == subuid || $1 == subgid || -L $factory/$1 ]]; then
|
||||
echo "C /etc/$1"
|
||||
elif [[ $1 == systemd ]]; then
|
||||
echo "L+ /etc/$1"
|
||||
else
|
||||
echo "L /etc/$1"
|
||||
fi
|
||||
}
|
||||
|
||||
{
|
||||
echo "# Generated by mkosi.finalize."
|
||||
for f in $(ls -A "$factory"); do
|
||||
case "$f" in *-|.*) continue ;; esac
|
||||
echo "$skip" | grep -qxF "$f" || link "$f"
|
||||
# Entries ending in - are backups, such as passwd-.
|
||||
for path in "$factory"/*; do
|
||||
f=${path##*/}
|
||||
[[ $f == *- ]] || grep -qxF "$f" <<< "$skip" || link "$f"
|
||||
done
|
||||
# /etc/ssh is a directory of its own, because sshd-keygen writes the host
|
||||
# keys there.
|
||||
# /etc/ssh is a writable directory instead of one link, because sshd-keygen
|
||||
# writes the host keys there at first boot. Its other entries are linked one
|
||||
# by one, so they still get updates from /usr.
|
||||
echo "d /etc/ssh 0755"
|
||||
for f in $(ls -A "$factory/ssh"); do link "ssh/$f"; done
|
||||
for path in "$factory"/ssh/*; do link "ssh/${path##*/}"; done
|
||||
} > "$BUILDROOT/usr/lib/tmpfiles.d/factory-etc.conf"
|
||||
|
||||
Reference in new issue
Block a user