diff --git a/README.md b/README.md index 6c18c8f..b1f33a7 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,7 @@ sudo make install DISK=/dev/nvme0n1 - A ForgeOS-native `neofetch` command is included in the overlay with a custom ForgeOS ASCII logo at `/usr/share/neofetch/ascii/distro/forgeos`. - The console starts an immediate root shell on `tty1` and `ttyS0` through native systemd units instead of BusyBox `inittab`. - The system bus is provided by source-built `dbus-daemon` and socket-activated at `/run/dbus/system_bus_socket`. +- `systemd-logind` is included in the source-built systemd layer, owns `org.freedesktop.login1` on the system bus, and provides `loginctl` plus the logind varlink socket. - DHCP networking is handled by `systemd-networkd`; DNS is handled by `systemd-resolved`, with `/etc/resolv.conf` linked to `/run/systemd/resolve/resolv.conf`. - `ENABLE_DESKTOP=1` adds an Openbox/tint2/PCManFM desktop layer to the normal ForgeOS rootfs by extracting a minimal Debian package payload while preserving the source-built systemd and D-Bus daemons. - `DESKTOP=gnome` switches rootfs assembly to a Debian package bootstrap because GNOME depends on a large desktop stack that ForgeOS does not source-build yet. diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 8db007c..e0fb444 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -24,7 +24,7 @@ ForgeOS currently targets UEFI systems. 4. The built kernel EFI stub is copied to `EFI/BOOT/FORGEOS.EFI`. 5. UEFI firmware executes GRUB from `EFI/BOOT/BOOTX64.EFI`, and GRUB starts the kernel. 6. The built-in kernel command line mounts `PARTLABEL=root` as the real root filesystem. -7. systemd starts as `/sbin/init`, activates the D-Bus system bus, starts `systemd-resolved` and `systemd-networkd`, reaches `multi-user.target`, and launches ForgeOS root-shell services on `tty1` and `ttyS0`. +7. systemd starts as `/sbin/init`, activates the D-Bus system bus, starts `systemd-logind`, `systemd-resolved`, and `systemd-networkd`, reaches `multi-user.target`, and launches ForgeOS root-shell services on `tty1` and `ttyS0`. ## Root Filesystem Model @@ -37,7 +37,7 @@ The root filesystem is assembled in `staging/rootfs` from: - kernel modules from the kernel build - the repository overlay in `overlay/rootfs` -The default network path uses DHCP through `systemd-networkd`. DNS servers learned from DHCP are exposed through `systemd-resolved`, and `/etc/resolv.conf` is a symlink to the resolved-managed compatibility file at `/run/systemd/resolve/resolv.conf`. Tools that query systemd over D-Bus use the system bus at `/run/dbus/system_bus_socket`. +The default network path uses DHCP through `systemd-networkd`. DNS servers learned from DHCP are exposed through `systemd-resolved`, and `/etc/resolv.conf` is a symlink to the resolved-managed compatibility file at `/run/systemd/resolve/resolv.conf`. Tools that query systemd over D-Bus use the system bus at `/run/dbus/system_bus_socket`. The source-built systemd layer also includes `systemd-logind`, `loginctl`, the `org.freedesktop.login1` system-bus policy, and the logind varlink socket. The default console build also generates `out/rootfs.cpio.gz` for quick QEMU smoke tests. Desktop-enabled rootfs builds skip the initramfs artifact and boot through the ext4 root partition image. diff --git a/overlay/rootfs/etc/systemd/system-preset/00-forgeos.preset b/overlay/rootfs/etc/systemd/system-preset/00-forgeos.preset index 400e0b4..2c2ccff 100644 --- a/overlay/rootfs/etc/systemd/system-preset/00-forgeos.preset +++ b/overlay/rootfs/etc/systemd/system-preset/00-forgeos.preset @@ -5,6 +5,8 @@ enable forgeos-bootdiag.service enable forgeos-console-banner.service enable dbus.service enable dbus.socket +enable systemd-logind.service +enable systemd-logind-varlink.socket enable systemd-networkd.service enable systemd-networkd.socket enable systemd-resolved.service diff --git a/overlay/rootfs/etc/systemd/system/forgeos-console-banner.service b/overlay/rootfs/etc/systemd/system/forgeos-console-banner.service index 7bd8b62..7a40fa5 100644 --- a/overlay/rootfs/etc/systemd/system/forgeos-console-banner.service +++ b/overlay/rootfs/etc/systemd/system/forgeos-console-banner.service @@ -1,7 +1,7 @@ [Unit] Description=Print ForgeOS console banner Documentation=man:systemd.service(5) -After=systemd-user-sessions.service +After=systemd-logind.service systemd-user-sessions.service ConditionPathExists=/sbin/forgeos-console-banner [Service] diff --git a/overlay/rootfs/etc/systemd/system/forgeos-shell@.service b/overlay/rootfs/etc/systemd/system/forgeos-shell@.service index 9158a34..75824fb 100644 --- a/overlay/rootfs/etc/systemd/system/forgeos-shell@.service +++ b/overlay/rootfs/etc/systemd/system/forgeos-shell@.service @@ -1,7 +1,7 @@ [Unit] Description=ForgeOS root shell on %I Documentation=man:systemd.service(5) -After=systemd-user-sessions.service +After=systemd-logind.service systemd-user-sessions.service Before=getty.target IgnoreOnIsolate=yes diff --git a/scripts/build-rootfs.sh b/scripts/build-rootfs.sh index c4e52f0..a619544 100755 --- a/scripts/build-rootfs.sh +++ b/scripts/build-rootfs.sh @@ -12,7 +12,7 @@ require_cmd make rsync cpio gzip ensure_dirs [[ -x "$BUSYBOX_BUILD_DIR/busybox" ]] || "$ROOT_DIR/scripts/build-busybox.sh" -[[ -x "$SYSTEMD_STAGING_DIR/usr/lib/systemd/systemd" && -f "$SYSTEMD_STAGING_DIR/.forgeos-systemd-complete" ]] || "$ROOT_DIR/scripts/build-systemd.sh" +[[ -x "$SYSTEMD_STAGING_DIR/usr/lib/systemd/systemd" && -x "$SYSTEMD_STAGING_DIR/usr/lib/systemd/systemd-logind" && -f "$SYSTEMD_STAGING_DIR/.forgeos-systemd-complete" ]] || "$ROOT_DIR/scripts/build-systemd.sh" [[ -x "$DBUS_STAGING_DIR/usr/bin/dbus-daemon" && -f "$DBUS_STAGING_DIR/.forgeos-dbus-complete" ]] || "$ROOT_DIR/scripts/build-dbus.sh" [[ -f "$OUT_DIR/bzImage" ]] || "$ROOT_DIR/scripts/build-kernel.sh" @@ -48,6 +48,16 @@ ln -sfn /etc/systemd/system/forgeos-bootdiag.service \ "$ROOTFS_STAGING_DIR/etc/systemd/system/multi-user.target.wants/forgeos-bootdiag.service" ln -sfn /etc/systemd/system/forgeos-console-banner.service \ "$ROOTFS_STAGING_DIR/etc/systemd/system/multi-user.target.wants/forgeos-console-banner.service" +ln -sfn /usr/lib/systemd/system/dbus.service \ + "$ROOTFS_STAGING_DIR/etc/systemd/system/multi-user.target.wants/dbus.service" +ln -sfn /usr/lib/systemd/system/dbus.socket \ + "$ROOTFS_STAGING_DIR/etc/systemd/system/sockets.target.wants/dbus.socket" +ln -sfn /usr/lib/systemd/system/systemd-logind.service \ + "$ROOTFS_STAGING_DIR/etc/systemd/system/multi-user.target.wants/systemd-logind.service" +ln -sfn /usr/lib/systemd/system/systemd-logind.service \ + "$ROOTFS_STAGING_DIR/etc/systemd/system/dbus-org.freedesktop.login1.service" +ln -sfn /usr/lib/systemd/system/systemd-logind-varlink.socket \ + "$ROOTFS_STAGING_DIR/etc/systemd/system/sockets.target.wants/systemd-logind-varlink.socket" ln -sfn /usr/lib/systemd/system/systemd-networkd.service \ "$ROOTFS_STAGING_DIR/etc/systemd/system/multi-user.target.wants/systemd-networkd.service" ln -sfn /usr/lib/systemd/system/systemd-resolved.service \ diff --git a/scripts/build-systemd.sh b/scripts/build-systemd.sh index 5e24f96..569c843 100755 --- a/scripts/build-systemd.sh +++ b/scripts/build-systemd.sh @@ -4,7 +4,7 @@ set -euo pipefail source "$(dirname "$0")/common.sh" -require_cmd meson ninja pkg-config "$CC" file ldd ldconfig install tar gzip +require_cmd meson ninja pkg-config "$CC" gperf file ldd ldconfig install tar gzip ensure_dirs [[ -z "$CROSS_COMPILE" ]] || die "systemd rootfs staging currently requires a native build; CROSS_COMPILE is not supported" @@ -44,9 +44,10 @@ copy_elf_deps() { copy_named_library() { local soname=$1 - local path + local ldconfig_output path - path=$(ldconfig -p 2>/dev/null | awk -v soname="$soname" '$1 == soname { print $NF; exit }') + ldconfig_output=$(ldconfig -p 2>/dev/null || true) + path=$(awk -v soname="$soname" '$1 == soname { print $NF; exit }' <<< "$ldconfig_output") [[ -n "$path" ]] || die "could not locate runtime library: $soname" copy_runtime_dep "$path" copy_elf_deps "$path" @@ -102,7 +103,7 @@ meson setup "$SYSTEMD_BUILD_DIR" "$SYSTEMD_SRC_DIR" \ -Dcoredump=false \ -Dpstore=false \ -Doomd=false \ - -Dlogind=false \ + -Dlogind=true \ -Dhostnamed=false \ -Dlocaled=false \ -Dmachined=false \ @@ -194,5 +195,8 @@ done < <(find "$SYSTEMD_STAGING_DIR" -type f \( -perm /111 -o -name '*.so' -o -n copy_named_library libmount.so.1 [[ -x "$SYSTEMD_STAGING_DIR/usr/lib/systemd/systemd" ]] || die "systemd binary was not installed" +[[ -x "$SYSTEMD_STAGING_DIR/usr/lib/systemd/systemd-logind" ]] || die "systemd-logind binary was not installed" +[[ -x "$SYSTEMD_STAGING_DIR/usr/bin/loginctl" ]] || die "loginctl binary was not installed" +[[ -f "$SYSTEMD_STAGING_DIR/usr/share/dbus-1/system.d/org.freedesktop.login1.conf" ]] || die "logind D-Bus policy was not installed" touch "$SYSTEMD_STAGING_DIR/.forgeos-systemd-complete" msg "systemd staging tree: $SYSTEMD_STAGING_DIR" diff --git a/scripts/stage-openbox-desktop.sh b/scripts/stage-openbox-desktop.sh index 162cc46..ebbe24f 100755 --- a/scripts/stage-openbox-desktop.sh +++ b/scripts/stage-openbox-desktop.sh @@ -183,8 +183,8 @@ EOF cat > "$ROOTFS_STAGING_DIR/etc/systemd/system/forgeos-desktop.service" <<'EOF' [Unit] Description=ForgeOS Openbox desktop -Wants=dbus.service systemd-udevd.service -After=dbus.service systemd-udevd.service systemd-user-sessions.service +Wants=dbus.service systemd-logind.service systemd-udevd.service +After=dbus.service systemd-logind.service systemd-udevd.service systemd-user-sessions.service Conflicts=forgeos-shell@tty1.service getty@tty1.service [Service]