feat: add ARM64 OS flavor

Use an ARM64 Debian rootfs bootstrap because the original source-built userspace path depends on native x86_64 host runtime libraries.
This commit is contained in:
blazblue547-afk committed 2026-06-17 12:16:09 -04:00
1 parent eb8038ef4c
commit 9e86817361
28 files changed
+629 -1409

No files matched your search

+17 -48
View File
@@ -1,19 +1,13 @@
SHELL := /usr/bin/env bash
export ARCH ?= x86_64
export ARCH ?= arm64
export KERNEL_VERSION ?= 7.1
export BUSYBOX_VERSION ?= 1.38.0
export SYSTEMD_VERSION ?= 260
export DBUS_VERSION ?= 1.16.2
export PAM_VERSION ?= 1.7.2
export NIX_VERSION ?= 2.34.0
export NIX_SYSTEM ?= x86_64-linux
export NIX_SYSTEM ?= aarch64-linux
export DESKTOP ?= console
export ENABLE_DESKTOP ?= 0
export ROOT_LABEL ?= FORGE_ROOT
export EFI_LABEL ?= FORGE_EFI
desktop_enabled := $(filter 1 true TRUE yes YES on ON,$(ENABLE_DESKTOP))
export IMAGE_SIZE_MIB ?= $(if $(filter gnome,$(DESKTOP)),12288,$(if $(desktop_enabled),6144,4096))
export IMAGE_SIZE_MIB ?= $(if $(filter gnome,$(DESKTOP)),12288,4096)
export ESP_SIZE_MIB ?= 256
export JOBS ?= $(shell getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)
export SECURE_BOOT ?= 0
@@ -22,32 +16,25 @@ export SECURE_BOOT_CERT ?=
export GNOME_SUITE ?= trixie
export GNOME_MIRROR ?= http://deb.debian.org/debian
.PHONY: help deps image-deps fetch kernel busybox pam systemd dbus rootfs gnome-rootfs image gnome-image secure-boot-keys run run-image run-desktop run-gnome list-disks install clean distclean
.PHONY: help deps image-deps fetch kernel rootfs gnome-rootfs image gnome-image secure-boot-keys run run-image run-gnome list-disks install clean distclean
help:
@printf '%s\n' \
'ForgeOS targets:' \
' make deps - install Debian/Ubuntu host deps for rootfs + run' \
' make image-deps - install Debian/Ubuntu host deps for image + run-image' \
' make fetch - download upstream source tarballs' \
' make kernel - build the Linux kernel and stage modules' \
' make pam - build Linux-PAM for login/session tracking' \
' make busybox - build BusyBox rescue utilities' \
' make systemd - build systemd PID 1' \
' make dbus - build the D-Bus system bus daemon' \
' make rootfs - assemble the systemd rootfs and initramfs' \
' make rootfs includes Nix as the core package manager' \
' ENABLE_DESKTOP=1 make rootfs - add Openbox/tint2/PCManFM desktop' \
' make gnome-rootfs - assemble a Debian GNOME desktop rootfs' \
' make image - build a bootable GPT/UEFI disk image' \
' make gnome-image - build a bootable GPT/UEFI GNOME disk image' \
'ForgeOS ARM64 targets:' \
' make deps - install Debian/Ubuntu host deps for ARM64 builds' \
' make image-deps - install ARM64 image + QEMU deps' \
' make fetch - download Linux and ARM64 Nix payloads' \
' make kernel - build the ARM64 Linux kernel and modules' \
' make rootfs - assemble the ARM64 console rootfs and initramfs' \
' make gnome-rootfs - assemble an ARM64 Debian GNOME rootfs' \
' make image - build a bootable ARM64 GPT/UEFI disk image' \
' make gnome-image - build a bootable ARM64 GNOME disk image' \
' make secure-boot-keys - generate a local Secure Boot signing keypair' \
' make run - boot kernel + initramfs in QEMU' \
' make run-image - boot the UEFI disk image in QEMU' \
' ENABLE_DESKTOP=1 make run-desktop - boot the Openbox desktop image' \
' make run-gnome - boot the GNOME image in graphical QEMU' \
' make run - boot kernel + initramfs in qemu-system-aarch64' \
' make run-image - boot the ARM64 UEFI disk image in QEMU' \
' make run-gnome - boot the ARM64 GNOME image in graphical QEMU' \
' make list-disks - list candidate installation disks' \
' sudo make install DISK=/dev/sdX - install ForgeOS to a real disk' \
' sudo make install DISK=/dev/sdX - install ForgeOS ARM64 to a real disk' \
' make clean - remove build, staging, and output artifacts' \
' make distclean - also remove downloaded and extracted sources'
@@ -63,18 +50,6 @@ fetch:
kernel: fetch
@./scripts/build-kernel.sh
busybox: fetch
@./scripts/build-busybox.sh
pam: fetch
@./scripts/build-pam.sh
systemd: fetch
@./scripts/build-systemd.sh
dbus: fetch
@./scripts/build-dbus.sh
rootfs:
@./scripts/build-rootfs.sh
@@ -100,12 +75,6 @@ run:
run-image:
@./scripts/run-qemu.sh image
run-desktop: ENABLE_DESKTOP = 1
run-desktop: IMAGE_SIZE_MIB = 4096
run-desktop: MEMORY_MB = 3072
run-desktop: image
@./scripts/run-qemu.sh image-gui
run-gnome: DESKTOP = gnome
run-gnome: IMAGE_SIZE_MIB = 12288
run-gnome: MEMORY_MB = 4096
+47 -116
View File
@@ -1,156 +1,87 @@
# ForgeOS
# ForgeOS ARM64
ForgeOS is a custom `x86_64` operating system project that defaults to a CLI-only source-built userspace instead of an existing Linux distribution tree. It uses the Linux kernel as the kernel layer, systemd as PID 1, BusyBox as a compact shell/rescue utility set, a custom root filesystem overlay, and direct UEFI boot through the kernel EFI stub. An optional GNOME desktop image flavor is available through a Debian package bootstrap.
ForgeOS ARM64 is the 64-bit ARM/AArch64 flavor of ForgeOS. It keeps the ForgeOS
UEFI disk-image flow, Linux kernel build, Nix integration, default `forge` user,
and optional GNOME image path, but targets ARM64 firmware and hardware instead
of x86_64.
As of `2026-06-17`, the project defaults to:
As of `2026-06-17`, this flavor defaults to:
- Linux kernel `7.1`
- systemd `260`
- D-Bus `1.16.2`
- BusyBox `1.38.0`
- Linux-PAM `1.7.2`
- Nix `2.34.0` as the core package manager
- `amd64` / `x86_64` only
- ARM64 / AArch64 only
- 64-bit only
- UEFI boot
- text console only
- optional GNOME desktop image using Debian `trixie` packages
- UEFI boot through `EFI/BOOT/BOOTAA64.EFI`
- Debian `arm64` console rootfs using `trixie`
- Nix `2.34.0` using the official `aarch64-linux` binary tarball
- serial console on `ttyAMA0`
- optional Debian GNOME desktop rootfs
## What This Repository Produces
- a reproducible build pipeline for a from-scratch OS image
- a minimal root filesystem with systemd as `/sbin/init`
- a ForgeOS ARM64 build pipeline
- a bootable GPT disk image with:
- an EFI system partition
- an ext4 root partition
- a faster QEMU smoke-test path using `kernel + initramfs`
## Layout
- `config/`: kernel and BusyBox configuration fragments
- `docs/`: architecture and limitations
- `overlay/rootfs/`: files copied into the root filesystem
- `scripts/`: fetch, build, image, and run scripts
- a direct QEMU smoke-test path using `qemu-system-aarch64`
- an optional GNOME ARM64 image flavor
## Quick Start
```bash
cd /home/joe/forgeos
cd ForgeOS-ARM64
sudo scripts/install-deps.sh
make rootfs
make run
```
That dependency script is for Debian/Ubuntu hosts and installs only the packages needed for the console rootfs plus direct QEMU boot path. The build path then builds the kernel, Linux-PAM, systemd, D-Bus, BusyBox rescue tools, and a compressed initramfs, then boots it directly in QEMU over serial.
The default console accounts are `forge` and `root`; both use the password
`forge`. Nix is staged into the rootfs as the package manager, with
`nix-daemon` enabled after the bootstrap service registers the bundled store
closure.
The default console accounts are `forge` and `root`; both use the password `forge`. Console logins go through BusyBox `login`, Linux-PAM, and `pam_systemd.so`, so `systemd-logind` tracks real per-user sessions.
Nix is staged into the normal ForgeOS rootfs as the core package manager. On first boot, `forgeos-nix-bootstrap.service` registers the initial `/nix/store` closure, creates the default Nix profile, and starts `nix-daemon`. Log in as `forge` and install packages with the modern profile command:
To build a bootable ARM64 UEFI disk image:
```bash
nix profile install nixpkgs#hello
hello
```
To build a UEFI disk image:
```bash
cd /home/joe/forgeos
cd ForgeOS-ARM64
sudo scripts/install-image-deps.sh
make image
make run-image
```
To add a lightweight desktop to the normal ForgeOS rootfs, enable the Openbox desktop layer:
The disk image is written to `out/forgeos-arm64-7.1.img`.
To build the optional ARM64 GNOME image:
```bash
cd /home/joe/forgeos
ENABLE_DESKTOP=1 make image
ENABLE_DESKTOP=1 make run-desktop
```
This keeps the regular ForgeOS rootfs path and stages Openbox, tint2, PCManFM, Xorg, fonts, icons, and a terminal into it. The serial login prompt remains on `ttyS0`; `tty1` starts the desktop session.
To build a GNOME desktop image, install `mmdebstrap` on the host and use the GNOME targets:
```bash
cd /home/joe/forgeos
cd ForgeOS-ARM64
make gnome-image
make run-gnome
```
The GNOME image uses ForgeOS's kernel and boot image flow with a Debian `trixie` GNOME userspace. The default desktop account is `forge` with password `forge`, and GDM autologin is enabled by default. Override `GNOME_USER`, `GNOME_USER_PASSWORD`, `GNOME_AUTOLOGIN=0`, `GNOME_SUITE`, `GNOME_MIRROR`, or `IMAGE_SIZE_MIB` when building if needed.
To list candidate installation disks:
```bash
cd /home/joe/forgeos
make list-disks
```
To install ForgeOS to a real disk from a Linux host:
```bash
cd /home/joe/forgeos
sudo make install DISK=/dev/nvme0n1
```
## Build Notes
- The root filesystem is not copied from a distro. It is assembled from upstream systemd, upstream D-Bus, upstream Linux-PAM, upstream BusyBox rescue tools, copied runtime library dependencies for systemd, D-Bus, PAM, and BusyBox, and the files in `overlay/rootfs/`.
- The default removable-media boot path uses GRUB at `EFI/BOOT/BOOTX64.EFI` and keeps the kernel EFI stub at `EFI/BOOT/FORGEOS.EFI`.
- The built-in kernel command line targets `PARTLABEL=root` and keeps Intel graphics modesetting enabled, with a couple of laptop display workarounds for newer firmware.
- For default direct QEMU testing, `scripts/run-qemu.sh direct` uses the generated `rootfs.cpio.gz`.
- The host-side installer expands the root partition to fill larger target disks.
- systemd is installed as `/sbin/init`. BusyBox remains available for `/bin/sh`, PAM-backed `/bin/login`, early switch-root support, and emergency command-line tools.
- Nix `2.34.0` is staged from the official `x86_64-linux` binary tarball and configured in multi-user daemon mode with `/nix`, `nixbld` build users, `cache.nixos.org`, and `nix-command`/`flakes` enabled. Override `NIX_VERSION` or `NIX_SYSTEM` if you intentionally want a different upstream tarball.
- 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 PAM-backed login prompts 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. `pam_systemd.so` registers console logins as logind sessions.
- 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.
Set `BOOTLOADER=stub` when building an image to use the direct kernel EFI-stub fallback path instead of GRUB.
## Secure Boot Signing
ForgeOS can build a Secure Boot-compatible fallback loader by signing the kernel EFI stub before it is copied to `EFI/BOOT/BOOTX64.EFI`.
Generate a local signing keypair:
```bash
cd /home/joe/forgeos
make secure-boot-keys
```
Build a signed disk image:
```bash
cd /home/joe/forgeos
SECURE_BOOT=1 \
SECURE_BOOT_KEY=out/secure-boot/ForgeOS.key \
SECURE_BOOT_CERT=out/secure-boot/ForgeOS.crt \
make image
```
The host needs `sbsign` for signed builds. Enroll `out/secure-boot/ForgeOS.cer` in the target firmware Secure Boot database, or import it through a trusted shim/MOK flow, before booting the image with Secure Boot enabled. The generated private key should stay private; anyone with it can sign EFI binaries trusted by machines where the certificate is enrolled.
## Toolchain Notes
Linux-PAM, systemd, and D-Bus are built with Meson/Ninja and staged dynamically. BusyBox is also built dynamically so its `login` applet can load PAM modules. The build copies the ELF runtime library closure from the native build host into the root filesystem, so cross-building the userspace is not supported yet.
- The kernel is built with Linux `ARCH=arm64` and defaults to the ARM64
`defconfig` plus ForgeOS options for EFI, virtio, PL011 serial, ext4, vfat,
initramfs, and common QEMU `virt` devices.
- On non-AArch64 hosts, the build defaults to `CROSS_COMPILE=aarch64-linux-gnu-`.
- The console rootfs is bootstrapped from Debian `arm64` packages with
`mmdebstrap` or root-run `debootstrap`; this avoids pretending the original
x86_64-native source-built PAM/systemd/D-Bus path can cross-build safely.
- GRUB is built for `arm64-efi` and installed at `EFI/BOOT/BOOTAA64.EFI`.
- The ARM64 Linux `Image` is also copied to `EFI/BOOT/FORGEOS.EFI` for GRUB to
load through the EFI stub.
- The default QEMU path uses `qemu-system-aarch64 -machine virt`.
- Nix `2.34.0` is staged from the official `aarch64-linux` binary tarball.
## Current Limits
- UEFI only for now; BIOS boot is not implemented.
- The kernel config includes common desktop, laptop, and QEMU storage/input paths, but not every vendor driver.
- Wireless firmware, GPU acceleration, stock Microsoft-trusted Secure Boot/shim integration, audio, and power-management polish are not bundled yet.
- Nix is the package manager for the normal ForgeOS rootfs, but ForgeOS does not yet have a declarative NixOS-style system rebuild/update flow.
- Account management is limited to the built-in `forge` and `root` accounts.
- The Openbox desktop layer is a staged runtime payload, not an in-OS package manager.
- GNOME support is currently a package-bootstrapped desktop flavor, not a source-built ForgeOS desktop stack.
- The installer is host-side only; there is no in-OS guided installer yet.
- ARM64 UEFI only; BIOS and 32-bit ARM are not supported.
- The default rootfs is Debian-bootstrapped rather than source-built.
- Cross-host bootstrap of Debian `arm64` packages may require `qemu-user-static`
and binfmt support on the host.
- Secure Boot still requires enrolling your generated local signing certificate.
- Hardware support beyond the QEMU `virt` platform depends on kernel config work
for the target board or machine.
More detail is in [docs/ARCHITECTURE.md](/home/joe/forgeos/docs/ARCHITECTURE.md).
Installer usage is documented in [docs/INSTALLER.md](/home/joe/forgeos/docs/INSTALLER.md).
More detail is in [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md).
Installer usage is documented in [docs/INSTALLER.md](docs/INSTALLER.md).
-79
View File
@@ -1,79 +0,0 @@
# CONFIG_STATIC is not set
CONFIG_PAM=y
CONFIG_FEATURE_INSTALLER=y
# CONFIG_FEATURE_SH_STANDALONE is not set
# CONFIG_FEATURE_PREFER_APPLETS is not set
CONFIG_SH_IS_ASH=y
CONFIG_ASH=y
CONFIG_ASH_OPTIMIZE_FOR_SIZE=y
CONFIG_ASH_BASH_COMPAT=y
CONFIG_ASH_JOB_CONTROL=y
CONFIG_ASH_ALIAS=y
CONFIG_CAT=y
CONFIG_CHMOD=y
CONFIG_CHOWN=y
CONFIG_CP=y
CONFIG_CUT=y
CONFIG_DATE=y
CONFIG_DD=y
CONFIG_DF=y
CONFIG_DMESG=y
CONFIG_ECHO=y
CONFIG_ENV=y
CONFIG_FIND=y
CONFIG_FREE=y
CONFIG_GREP=y
CONFIG_GUNZIP=y
CONFIG_GZIP=y
CONFIG_HOSTNAME=y
# CONFIG_INIT is not set
CONFIG_IP=y
CONFIG_IPADDR=y
CONFIG_IPLINK=y
CONFIG_IPROUTE=y
CONFIG_KLOGD=y
CONFIG_LESS=y
CONFIG_LN=y
CONFIG_LOGIN=y
CONFIG_LOGIN_SESSION_AS_CHILD=y
CONFIG_LS=y
CONFIG_MDEV=y
CONFIG_FEATURE_MDEV_CONF=y
CONFIG_MKDIR=y
CONFIG_MKNOD=y
CONFIG_MOUNT=y
CONFIG_UMOUNT=y
CONFIG_MV=y
CONFIG_PIDOF=y
CONFIG_PRINTF=y
CONFIG_PS=y
CONFIG_PWD=y
CONFIG_REBOOT=y
CONFIG_ROUTE=y
CONFIG_RM=y
CONFIG_RMDIR=y
CONFIG_SED=y
CONFIG_SLEEP=y
CONFIG_SORT=y
CONFIG_SWITCH_ROOT=y
CONFIG_SYNC=y
CONFIG_SYSLOGD=y
CONFIG_TAIL=y
CONFIG_TAR=y
CONFIG_TEE=y
# CONFIG_TC is not set
CONFIG_TEST=y
CONFIG_TOUCH=y
CONFIG_TR=y
CONFIG_TRUE=y
CONFIG_UDHCPC=y
CONFIG_UDHCPC_DEFAULT_SCRIPT="/usr/share/udhcpc/default.script"
CONFIG_UNAME=y
CONFIG_UNZIP=y
CONFIG_VI=y
CONFIG_XARGS=y
CONFIG_GETTY=y
CONFIG_FEATURE_UTMP=y
CONFIG_FEATURE_WTMP=y
CONFIG_FEATURE_SHADOWPASSWDS=y
CONFIG_USE_BB_SHADOW=y
+9 -9
View File
@@ -31,7 +31,6 @@ CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y
CONFIG_EFI=y
CONFIG_EFI_STUB=y
CONFIG_EFI_MIXED=y
CONFIG_FB_EFI=y
CONFIG_EFI_PARTITION=y
CONFIG_VT=y
@@ -39,18 +38,15 @@ CONFIG_VT_CONSOLE=y
CONFIG_FRAMEBUFFER_CONSOLE=y
CONFIG_DRM=y
CONFIG_DRM_SIMPLEDRM=y
CONFIG_DRM_NOUVEAU=y
CONFIG_DRM_NOUVEAU_BACKLIGHT=y
CONFIG_VGA_SWITCHEROO=y
CONFIG_DRM_VIRTIO_GPU=y
CONFIG_SYSFB_SIMPLEFB=y
CONFIG_INPUT_EVDEV=y
CONFIG_SERIO_I8042=y
CONFIG_KEYBOARD_ATKBD=y
CONFIG_SERIAL_8250=y
CONFIG_SERIAL_8250_CONSOLE=y
CONFIG_SERIAL_AMBA_PL011=y
CONFIG_SERIAL_AMBA_PL011_CONSOLE=y
CONFIG_UNIX98_PTYS=y
CONFIG_PCI=y
CONFIG_PCI_MSI=y
CONFIG_PCI_HOST_GENERIC=y
CONFIG_ATA=y
CONFIG_SATA_AHCI=y
CONFIG_SCSI=y
@@ -67,6 +63,8 @@ CONFIG_USB_UHCI_HCD=y
CONFIG_USB_STORAGE=y
CONFIG_VIRTIO=y
CONFIG_VIRTIO_PCI=y
CONFIG_VIRTIO_MMIO=y
CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES=y
CONFIG_VIRTIO_BLK=y
CONFIG_VIRTIO_NET=y
CONFIG_VIRTIO_CONSOLE=y
@@ -87,6 +85,8 @@ CONFIG_R8169=y
CONFIG_IGB=y
CONFIG_IGC=y
CONFIG_TG3=y
CONFIG_RTC_CLASS=y
CONFIG_RTC_DRV_PL031=y
CONFIG_CMDLINE_BOOL=y
CONFIG_CMDLINE="root=PARTLABEL=root rootfstype=ext4 rootwait rw console=tty0 console=ttyS0,115200n8 loglevel=7 ignore_loglevel i915.enable_psr=0 i915.fastboot=0"
CONFIG_CMDLINE="root=PARTLABEL=root rootfstype=ext4 rootwait rw console=tty0 console=ttyAMA0,115200 loglevel=7 ignore_loglevel"
# CONFIG_CMDLINE_OVERRIDE is not set
+44 -83
View File
@@ -1,106 +1,67 @@
# ForgeOS Architecture
# ForgeOS ARM64 Architecture
## Goal
ForgeOS defaults to a CLI-only operating system for `x86_64` desktops and laptops that does not use an existing Linux distribution as its base. It composes upstream projects directly:
ForgeOS ARM64 is the AArch64 flavor of ForgeOS. It targets 64-bit ARM systems
with UEFI firmware and keeps the ForgeOS image builder, boot layout, kernel
configuration style, default user setup, and Nix integration.
- Linux kernel for the kernel layer
- systemd for PID 1 and service supervision
- D-Bus for the system message bus
- Linux-PAM for local login authentication and session hooks
- BusyBox for `/bin/sh`, early switch-root support, and compact rescue tools
- Nix for core package management
- custom units and configuration files from this repository
There is also an optional `DESKTOP=gnome` image flavor. That flavor keeps the ForgeOS kernel, GRUB/EFI boot flow, image builder, and kernel modules, but uses a Debian `trixie` GNOME userspace because GNOME's dependency closure is much larger than the current source-built ForgeOS userspace.
The normal ForgeOS rootfs can also be built with `ENABLE_DESKTOP=1`. That does not switch to a new OS flavor: it keeps the source-built ForgeOS userspace and stages an Openbox/tint2/PCManFM desktop layer into the same rootfs.
The original x86_64 ForgeOS source-built userspace path depends on native host
runtime libraries for PAM, systemd, D-Bus, and BusyBox. This ARM64 flavor uses a
Debian `arm64` rootfs bootstrap instead, which gives the architecture flavor a
real ARM64 userspace while the source-built cross-sysroot work remains future
work.
## Boot Model
ForgeOS currently targets UEFI systems.
1. The disk image contains a GPT.
2. Partition 1 is a FAT32 EFI System Partition labeled `FORGE_EFI`.
3. By default, `out/BOOTX64.EFI` is a standalone GRUB UEFI fallback loader with a small debug boot menu.
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-logind`, `systemd-resolved`, and `systemd-networkd`, reaches `multi-user.target`, and launches PAM-backed login prompts on `tty1` and `ttyS0`.
3. `out/BOOTAA64.EFI` is a standalone GRUB UEFI fallback loader built for
`arm64-efi`.
4. The ARM64 Linux `Image` with EFI stub support is copied to
`EFI/BOOT/FORGEOS.EFI`.
5. UEFI firmware executes GRUB from `EFI/BOOT/BOOTAA64.EFI`.
6. GRUB starts the kernel with `root=PARTLABEL=root`.
7. systemd starts from the ARM64 rootfs and launches console login on `tty1` and
serial login on `ttyAMA0`.
## Root Filesystem Model
The root filesystem is assembled in `staging/rootfs` from:
The default rootfs is assembled in `staging/rootfs` from:
- systemd install output from `staging/systemd`
- D-Bus install output from `staging/dbus`
- Linux-PAM install output from `staging/pam`
- runtime library dependencies copied from the native build host for systemd, D-Bus, PAM, and BusyBox binaries
- BusyBox install output for shell and rescue utilities
- the official Nix `x86_64-linux` binary tarball staged into `/nix/store`
- kernel modules from the kernel build
- the repository overlay in `overlay/rootfs`
- Debian `trixie` ARM64 packages
- ForgeOS identity, user, network, and systemd defaults
- kernel modules from the ARM64 kernel build
- the official Nix `aarch64-linux` binary tarball staged into `/nix/store`
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`, `pam_systemd.so`, the `org.freedesktop.login1` system-bus policy, and the logind varlink socket. Console login uses BusyBox `getty` and `login`; `/etc/pam.d/login` authenticates against `/etc/shadow` with `pam_unix.so` and registers sessions with `pam_systemd.so`.
The default package set is intentionally console-focused. It includes systemd,
D-Bus, sudo, locales, CA certificates, kmod, iproute2, ping, procps, resolved,
and timesyncd. The optional `DESKTOP=gnome` flavor uses the same ARM64 kernel and
image flow with a larger Debian GNOME rootfs.
Nix is integrated as a multi-user daemon package manager in the normal ForgeOS rootfs. `scripts/stage-nix.sh` copies the official Nix store closure into `/nix/store`, stages `nix.conf`, adds `nixbld` build accounts, enables `forgeos-nix-bootstrap.service`, and exposes `nix-daemon.service` plus `nix-daemon.socket`. On first boot, the bootstrap service fixes `/nix` ownership, loads the bundled `.reginfo` into the Nix database, and creates the default profile with Nix, Nix manual pages, and the bundled CA certificate package. ForgeOS enables `nix-command` and `flakes`, uses `cache.nixos.org`, and leaves Nix build sandboxing disabled until the OS has a verified sandbox policy.
## QEMU Model
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.
The run scripts use `qemu-system-aarch64` with:
For `DESKTOP=gnome`, `scripts/build-gnome-rootfs.sh` uses `mmdebstrap` or root-run `debootstrap` to assemble a Debian GNOME root filesystem in `staging/rootfs`, adds ForgeOS identity defaults, creates the initial desktop user, enables GDM and NetworkManager, and copies ForgeOS kernel modules. The GNOME image path deliberately does not copy `rootfs.cpio.gz` into the EFI System Partition because a desktop rootfs is too large for the initramfs-based smoke-test flow.
For `ENABLE_DESKTOP=1`, `scripts/stage-openbox-desktop.sh` asks apt to download the Openbox desktop package closure, extracts only the runtime payloads into `staging/rootfs`, skips base daemon packages that would replace source-built systemd or D-Bus, and enables `forgeos-desktop.service` on `tty1`.
## Why EFI Stub Boot
The project can still boot the kernel EFI stub directly with `BOOTLOADER=stub`, which keeps the implementation smaller and more direct:
- no external distro boot stack
- no dependency on GRUB or systemd-boot
- one kernel artifact doubles as the EFI executable
The tradeoff is that the current implementation depends on a built-in kernel command line.
## Secure Boot Model
ForgeOS supports a signed EFI-stub loader path for machines where the signing certificate has been enrolled in firmware Secure Boot `db`, or imported through a trusted shim/MOK flow.
This does not make ForgeOS trusted by stock Microsoft Secure Boot keys. That would require a Microsoft-signed shim or another trusted first-stage loader. The current project keeps the direct EFI-stub model and signs that EFI executable with a user-controlled key.
## Hardware Scope
The kernel fragment forces built-in support for:
- UEFI boot
- serial and virtual terminals
- devtmpfs
- ext4 and vfat
- GPT partition tables
- AHCI / SATA
- NVMe
- USB storage
- common keyboard and USB input paths
- common QEMU virtio paths
This is enough for a first CLI OS image and a development boot path, but not yet a broad hardware certification matrix.
- `-machine virt`
- `-cpu max`
- PL011 serial console through `ttyAMA0`
- AAVMF firmware for UEFI image boots
- virtio block, network, rng, and GPU devices where appropriate
## Known Gaps
- BIOS boot path
- Microsoft/shim-signed Secure Boot chain
- measured boot and full verified boot
- full laptop Wi-Fi and firmware coverage
- declarative NixOS-style system rebuilds and rollback management
- source-built GNOME and graphical desktop dependency closure
- source-built Openbox/Xorg/GTK graphical dependency closure
- source-built dependency closure for systemd and D-Bus runtime libraries
- account management beyond the built-in `forge` and `root` users
- in-OS guided installer and update system
- hardening review of the kernel and userspace defaults
- Source-built ARM64 systemd/PAM/D-Bus userspace.
- Board-specific kernel profiles beyond QEMU `virt`.
- Microsoft/shim-signed Secure Boot chain.
- Declarative NixOS-style system rebuilds and rollback management.
- In-OS guided installer and update system.
## Suggested Next Steps
1. Add a source-built libc and dependency sysroot so systemd no longer needs copied host libraries.
2. Teach the installer to support target-specific kernel command lines so multiple ForgeOS disks can coexist more safely.
3. Add network profiles, SSH, and a ForgeOS system update mechanism on top of Nix.
4. Expand kernel coverage for Wi-Fi, Bluetooth, audio, suspend, and vendor input devices.
1. Add a cross-built ARM64 sysroot for source-built systemd, PAM, D-Bus, and
BusyBox.
2. Add hardware profiles for common ARM64 laptops, SBCs, and servers.
3. Add CI that builds `make kernel`, `make rootfs`, and `make image` on an
x86_64 host with the AArch64 cross toolchain.
4. Add an ARM64 Secure Boot/shim story for real hardware deployment.
+8 -8
View File
@@ -1,8 +1,8 @@
# ForgeOS Installer
# ForgeOS ARM64 Installer
ForgeOS currently ships with a host-side installer script:
- [scripts/install-to-disk.sh](/home/joe/forgeos/scripts/install-to-disk.sh)
- [scripts/install-to-disk.sh](../scripts/install-to-disk.sh)
It installs the built raw ForgeOS image to a real block device from an existing Linux host.
@@ -21,28 +21,28 @@ It installs the built raw ForgeOS image to a real block device from an existing
List candidate disks:
```bash
cd /home/joe/forgeos
cd ForgeOS-ARM64
make list-disks
```
Install to a disk:
```bash
cd /home/joe/forgeos
cd ForgeOS-ARM64
sudo make install DISK=/dev/nvme0n1
```
Non-interactive install:
```bash
cd /home/joe/forgeos
cd ForgeOS-ARM64
sudo make install DISK=/dev/sdc INSTALL_ARGS="--yes --unmount"
```
Install without expanding the root filesystem:
```bash
cd /home/joe/forgeos
cd ForgeOS-ARM64
sudo make install DISK=/dev/sdc INSTALL_ARGS="--no-expand-root"
```
@@ -65,7 +65,7 @@ Optional arguments:
To install a Secure Boot-compatible image, build it with a signed EFI loader first:
```bash
cd /home/joe/forgeos
cd ForgeOS-ARM64
make secure-boot-keys
SECURE_BOOT=1 \
SECURE_BOOT_KEY=out/secure-boot/ForgeOS.key \
@@ -74,7 +74,7 @@ make image
sudo make install DISK=/dev/sdc
```
Enroll `out/secure-boot/ForgeOS.cer` in the target firmware Secure Boot database, or through a trusted shim/MOK flow, before booting with Secure Boot enabled. Without that enrollment, firmware should reject `EFI/BOOT/BOOTX64.EFI` even though it is signed.
Enroll `out/secure-boot/ForgeOS.cer` in the target firmware Secure Boot database, or through a trusted shim/MOK flow, before booting with Secure Boot enabled. Without that enrollment, firmware should reject `EFI/BOOT/BOOTAA64.EFI` even though it is signed.
## Safety Notes
@@ -1,6 +1,6 @@
disable *
enable forgeos-login@tty1.service
enable forgeos-login@ttyS0.service
enable serial-getty@ttyAMA0.service
enable forgeos-bootdiag.service
enable forgeos-console-banner.service
enable dbus.service
@@ -2,7 +2,7 @@
Description=Repair ForgeOS user home ownership
Documentation=man:systemd.service(5)
After=local-fs.target
Before=systemd-user-sessions.service getty.target forgeos-login@tty1.service forgeos-login@ttyS0.service
Before=systemd-user-sessions.service getty.target getty@tty1.service serial-getty@ttyAMA0.service
[Service]
Type=oneshot
+1 -1
View File
@@ -149,7 +149,7 @@ write_marker() {
print_file "proc consoles" /proc/consoles
print_file "active console" /sys/class/tty/console/active
print_cmd "foreground vt" fgconsole
print_cmd "tty devices" ls -l /dev/console /dev/tty /dev/tty0 /dev/tty1 /dev/ttyS0
print_cmd "tty devices" ls -l /dev/console /dev/tty /dev/tty0 /dev/tty1 /dev/ttyAMA0
print_cmd "block devices" ls -l /dev/sd* /dev/vd* /dev/nvme* /dev/mmcblk*
print_cmd "disk labels" ls -l /dev/disk/by-label /dev/disk/by-partlabel
print_cmd "blkid" blkid
+2 -2
View File
@@ -3,12 +3,12 @@
PATH=/bin:/sbin:/usr/bin:/usr/sbin
export PATH
for tty in /dev/tty0 /dev/tty1 /dev/ttyS0 /dev/console; do
for tty in /dev/tty0 /dev/tty1 /dev/ttyAMA0 /dev/console; do
[ -w "$tty" ] || continue
{
echo
echo "ForgeOS boot complete: $(uname -r) on $(uname -m)"
echo "Login prompts are available on tty1 and ttyS0."
echo "Login prompts are available on tty1 and ttyAMA0."
echo
} > "$tty" 2>/dev/null || true
done
+378
View File
@@ -0,0 +1,378 @@
#!/usr/bin/env bash
set -euo pipefail
source "$(dirname "$0")/common.sh"
require_cmd find openssl rsync cpio gzip grep sed date seq
ensure_dirs
ARM64_BOOTSTRAP_TOOL=${ARM64_BOOTSTRAP_TOOL:-auto}
ARM64_COMPONENTS=${ARM64_COMPONENTS:-main,contrib,non-free-firmware}
ARM64_USER=${ARM64_USER:-forge}
ARM64_USER_UID=${ARM64_USER_UID:-1000}
ARM64_USER_PASSWORD=${ARM64_USER_PASSWORD:-forge}
ARM64_PACKAGES=${ARM64_PACKAGES:-systemd-sysv dbus dbus-user-session sudo locales ca-certificates kmod iproute2 iputils-ping procps systemd-resolved systemd-timesyncd}
normalize_packages_csv() {
local package_csv
package_csv=${ARM64_PACKAGES//$'\n'/ }
package_csv=${package_csv//$'\t'/ }
package_csv=${package_csv// /,}
while [[ "$package_csv" == *",,"* ]]; do
package_csv=${package_csv//,,/,}
done
package_csv=${package_csv#,}
package_csv=${package_csv%,}
printf '%s\n' "$package_csv"
}
choose_bootstrap_tool() {
case "$ARM64_BOOTSTRAP_TOOL" in
auto)
if command -v mmdebstrap >/dev/null 2>&1; then
printf 'mmdebstrap\n'
elif command -v debootstrap >/dev/null 2>&1; then
printf 'debootstrap\n'
else
die "install mmdebstrap, or install debootstrap and run this target as root"
fi
;;
mmdebstrap|debootstrap)
command -v "$ARM64_BOOTSTRAP_TOOL" >/dev/null 2>&1 || die "missing required command: $ARM64_BOOTSTRAP_TOOL"
printf '%s\n' "$ARM64_BOOTSTRAP_TOOL"
;;
*)
die "unsupported ARM64_BOOTSTRAP_TOOL=$ARM64_BOOTSTRAP_TOOL"
;;
esac
}
cleanup_chroot_mounts() {
local mountpoint
for mountpoint in \
"$ROOTFS_STAGING_DIR/dev/pts" \
"$ROOTFS_STAGING_DIR/dev" \
"$ROOTFS_STAGING_DIR/proc" \
"$ROOTFS_STAGING_DIR/sys"; do
if mountpoint -q "$mountpoint"; then
umount -R "$mountpoint"
fi
done
}
write_apt_sources() {
cat > "$ROOTFS_STAGING_DIR/etc/apt/sources.list" <<EOF
deb $GNOME_MIRROR $GNOME_SUITE ${ARM64_COMPONENTS//,/ }
deb http://security.debian.org/debian-security ${GNOME_SUITE}-security ${ARM64_COMPONENTS//,/ }
deb $GNOME_MIRROR ${GNOME_SUITE}-updates ${ARM64_COMPONENTS//,/ }
EOF
}
bootstrap_with_mmdebstrap() {
local package_csv
require_cmd mmdebstrap
package_csv=$(normalize_packages_csv)
msg "bootstrapping Debian $GNOME_SUITE ARM64 console rootfs with mmdebstrap"
DEBIAN_FRONTEND=noninteractive mmdebstrap \
--mode=auto \
--variant=apt \
--architectures="$DEBIAN_ARCH" \
--components="$ARM64_COMPONENTS" \
--include="$package_csv" \
"$GNOME_SUITE" \
"$ROOTFS_STAGING_DIR" \
"$GNOME_MIRROR"
write_apt_sources
}
bootstrap_with_debootstrap() {
require_cmd apt-get chroot debootstrap mount mountpoint umount
[[ "$EUID" -eq 0 ]] || die "debootstrap mode must run as root; install mmdebstrap for rootless builds"
msg "bootstrapping Debian $GNOME_SUITE ARM64 console rootfs with debootstrap"
debootstrap \
--arch="$DEBIAN_ARCH" \
--components="$ARM64_COMPONENTS" \
"$GNOME_SUITE" \
"$ROOTFS_STAGING_DIR" \
"$GNOME_MIRROR"
write_apt_sources
mount -t proc proc "$ROOTFS_STAGING_DIR/proc"
mount -t sysfs sysfs "$ROOTFS_STAGING_DIR/sys"
mount --rbind /dev "$ROOTFS_STAGING_DIR/dev"
mount --make-rslave "$ROOTFS_STAGING_DIR/dev"
trap cleanup_chroot_mounts EXIT
msg "installing ARM64 console package set"
chroot "$ROOTFS_STAGING_DIR" env DEBIAN_FRONTEND=noninteractive apt-get update
chroot "$ROOTFS_STAGING_DIR" env DEBIAN_FRONTEND=noninteractive apt-get install -y $ARM64_PACKAGES
chroot "$ROOTFS_STAGING_DIR" env DEBIAN_FRONTEND=noninteractive apt-get clean
cleanup_chroot_mounts
trap - EXIT
}
unit_path() {
local unit=$1
if [[ -e "$ROOTFS_STAGING_DIR/lib/systemd/system/$unit" ]]; then
printf '/lib/systemd/system/%s\n' "$unit"
else
printf '/usr/lib/systemd/system/%s\n' "$unit"
fi
}
enable_unit() {
local unit=$1
local target=$2
local source
source=$(unit_path "$unit")
if [[ -e "$ROOTFS_STAGING_DIR$source" ]]; then
mkdir -p "$ROOTFS_STAGING_DIR/etc/systemd/system/$target.wants"
ln -sfn "$source" "$ROOTFS_STAGING_DIR/etc/systemd/system/$target.wants/$unit"
fi
}
ensure_group() {
local group=$1
local gid=$2
local group_file="$ROOTFS_STAGING_DIR/etc/group"
grep -q "^${group}:" "$group_file" || printf '%s:x:%s:\n' "$group" "$gid" >> "$group_file"
}
add_group_member() {
local group=$1
local member=$2
local group_file="$ROOTFS_STAGING_DIR/etc/group"
local line
local name
local password
local gid
local members
line=$(grep "^${group}:" "$group_file" || true)
[[ -n "$line" ]] || return 0
IFS=: read -r name password gid members <<< "$line"
case ",$members," in
*",$member,"*) return 0 ;;
esac
members=${members:+$members,}$member
sed -i "s|^${group}:.*|${name}:${password}:${gid}:${members}|" "$group_file"
}
ensure_shadow_entry() {
local user=$1
local shadow_file="$ROOTFS_STAGING_DIR/etc/shadow"
local today
today=$(($(date +%s) / 86400))
if ! grep -q "^${user}:" "$shadow_file"; then
printf '%s:!:%s:0:99999:7:::\n' "$user" "$today" >> "$shadow_file"
fi
}
ensure_gshadow_group() {
local group=$1
local members=$2
local gshadow_file="$ROOTFS_STAGING_DIR/etc/gshadow"
[[ -f "$gshadow_file" ]] || return 0
if grep -q "^${group}:" "$gshadow_file"; then
sed -i "s|^${group}:.*|${group}:*::${members}|" "$gshadow_file"
else
printf '%s:*::%s\n' "$group" "$members" >> "$gshadow_file"
fi
}
configure_user() {
local passwd_file="$ROOTFS_STAGING_DIR/etc/passwd"
local shadow_file="$ROOTFS_STAGING_DIR/etc/shadow"
local password_hash
local today
local home_dir="$ROOTFS_STAGING_DIR/home/$ARM64_USER"
ensure_group "$ARM64_USER" "$ARM64_USER_UID"
if ! grep -q "^${ARM64_USER}:" "$passwd_file"; then
printf '%s:x:%s:%s:ForgeOS ARM64 User:/home/%s:/bin/bash\n' \
"$ARM64_USER" "$ARM64_USER_UID" "$ARM64_USER_UID" "$ARM64_USER" >> "$passwd_file"
fi
password_hash=$(openssl passwd -6 -salt "$ARM64_USER" "$ARM64_USER_PASSWORD")
today=$(($(date +%s) / 86400))
if grep -q "^${ARM64_USER}:" "$shadow_file"; then
sed -i "s|^${ARM64_USER}:.*|${ARM64_USER}:${password_hash}:${today}:0:99999:7:::|" "$shadow_file"
else
printf '%s:%s:%s:0:99999:7:::\n' "$ARM64_USER" "$password_hash" "$today" >> "$shadow_file"
fi
for group in sudo adm cdrom dip plugdev users video audio netdev; do
add_group_member "$group" "$ARM64_USER"
done
mkdir -p "$home_dir"
chmod 0700 "$home_dir"
if [[ "$EUID" -eq 0 ]]; then
chown -R "$ARM64_USER_UID:$ARM64_USER_UID" "$home_dir"
fi
mkdir -p "$ROOTFS_STAGING_DIR/etc/sudoers.d"
printf '%s ALL=(ALL:ALL) ALL\n' "$ARM64_USER" > "$ROOTFS_STAGING_DIR/etc/sudoers.d/forgeos"
chmod 0440 "$ROOTFS_STAGING_DIR/etc/sudoers.d/forgeos"
}
configure_nix_build_users() {
local passwd_file="$ROOTFS_STAGING_DIR/etc/passwd"
local group_file="$ROOTFS_STAGING_DIR/etc/group"
local user
local uid
local members=
ensure_group nixbld 30000
for index in $(seq 1 32); do
user="nixbld$index"
uid=$((30000 + index))
members=${members:+$members,}$user
if ! grep -q "^${user}:" "$passwd_file"; then
printf '%s:x:%s:30000:Nix build user %s:/var/empty:/sbin/nologin\n' \
"$user" "$uid" "$index" >> "$passwd_file"
fi
ensure_shadow_entry "$user"
done
sed -i "s|^nixbld:.*|nixbld:x:30000:${members}|" "$group_file"
ensure_gshadow_group nixbld "$members"
}
configure_identity() {
mkdir -p "$ROOTFS_STAGING_DIR/etc/default"
printf 'forgeos-arm64\n' > "$ROOTFS_STAGING_DIR/etc/hostname"
cat > "$ROOTFS_STAGING_DIR/etc/os-release" <<EOF
NAME=ForgeOS ARM64
ID=forgeos-arm64
ID_LIKE=debian
PRETTY_NAME="ForgeOS ARM64 ($GNOME_SUITE userland)"
VERSION_CODENAME=$GNOME_SUITE
EOF
printf 'LANG=en_US.UTF-8\n' > "$ROOTFS_STAGING_DIR/etc/default/locale"
rm -f "$ROOTFS_STAGING_DIR/etc/machine-id"
: > "$ROOTFS_STAGING_DIR/etc/machine-id"
}
configure_console_services() {
local multi_user_target
local getty_service
local serial_getty_service
multi_user_target=$(unit_path multi-user.target)
getty_service=$(unit_path getty@.service)
serial_getty_service=$(unit_path serial-getty@.service)
mkdir -p \
"$ROOTFS_STAGING_DIR/etc/systemd/network" \
"$ROOTFS_STAGING_DIR/etc/systemd/system" \
"$ROOTFS_STAGING_DIR/etc/systemd/system/getty.target.wants" \
"$ROOTFS_STAGING_DIR/etc/systemd/system/multi-user.target.wants" \
"$ROOTFS_STAGING_DIR/etc/systemd/system/sockets.target.wants" \
"$ROOTFS_STAGING_DIR/etc/systemd/system/sysinit.target.wants"
ln -sfn "$multi_user_target" "$ROOTFS_STAGING_DIR/etc/systemd/system/default.target"
ln -sfn "$getty_service" "$ROOTFS_STAGING_DIR/etc/systemd/system/getty.target.wants/getty@tty1.service"
ln -sfn "$serial_getty_service" "$ROOTFS_STAGING_DIR/etc/systemd/system/getty.target.wants/serial-getty@ttyAMA0.service"
enable_unit dbus.service multi-user.target
enable_unit dbus.socket sockets.target
enable_unit systemd-networkd.service multi-user.target
enable_unit systemd-networkd.socket sockets.target
enable_unit systemd-resolved.service sysinit.target
enable_unit systemd-resolved-varlink.socket sockets.target
enable_unit systemd-timesyncd.service sysinit.target
cat > "$ROOTFS_STAGING_DIR/etc/systemd/network/20-dhcp.network" <<'EOF'
[Match]
Name=en* eth*
[Network]
DHCP=yes
IPv6AcceptRA=yes
EOF
rm -f "$ROOTFS_STAGING_DIR/etc/resolv.conf"
ln -s ../run/systemd/resolve/resolv.conf "$ROOTFS_STAGING_DIR/etc/resolv.conf"
if [[ -f "$OVERLAY_DIR/etc/systemd/system/forgeos-home-ownership.service" ]]; then
install -Dm644 \
"$OVERLAY_DIR/etc/systemd/system/forgeos-home-ownership.service" \
"$ROOTFS_STAGING_DIR/etc/systemd/system/forgeos-home-ownership.service"
ln -sfn /etc/systemd/system/forgeos-home-ownership.service \
"$ROOTFS_STAGING_DIR/etc/systemd/system/multi-user.target.wants/forgeos-home-ownership.service"
fi
}
enable_nix_services() {
ln -sfn /etc/systemd/system/forgeos-nix-bootstrap.service \
"$ROOTFS_STAGING_DIR/etc/systemd/system/sysinit.target.wants/forgeos-nix-bootstrap.service"
ln -sfn /etc/systemd/system/nix-daemon.service \
"$ROOTFS_STAGING_DIR/etc/systemd/system/multi-user.target.wants/nix-daemon.service"
ln -sfn /etc/systemd/system/nix-daemon.socket \
"$ROOTFS_STAGING_DIR/etc/systemd/system/sockets.target.wants/nix-daemon.socket"
}
msg "assembling ARM64 root filesystem"
BOOTSTRAP_TOOL=$(choose_bootstrap_tool)
[[ "$ARCH" == "arm64" ]] || die "ARM64 rootfs requires ARCH=arm64"
[[ -f "$KERNEL_IMAGE" ]] || "$ROOT_DIR/scripts/build-kernel.sh"
[[ -d "$MODULES_STAGING_DIR/lib/modules" ]] || "$ROOT_DIR/scripts/build-kernel.sh"
if [[ -d "$ROOTFS_STAGING_DIR" ]]; then
chmod -R u+w "$ROOTFS_STAGING_DIR" 2>/dev/null || true
rm -rf "$ROOTFS_STAGING_DIR" || die "could not remove $ROOTFS_STAGING_DIR; rerun with sufficient permissions"
fi
mkdir -p "$ROOTFS_STAGING_DIR"
case "$BOOTSTRAP_TOOL" in
mmdebstrap)
bootstrap_with_mmdebstrap
;;
debootstrap)
bootstrap_with_debootstrap
;;
esac
msg "configuring ForgeOS ARM64 defaults"
configure_identity
configure_user
configure_nix_build_users
configure_console_services
"$ROOT_DIR/scripts/stage-nix.sh"
enable_nix_services
mkdir -p "$ROOTFS_STAGING_DIR/lib" "$ROOTFS_STAGING_DIR/boot"
rsync -a "$MODULES_STAGING_DIR/lib/" "$ROOTFS_STAGING_DIR/lib/"
install -Dm644 "$KERNEL_IMAGE" "$ROOTFS_STAGING_DIR/boot/vmlinuz-${KERNEL_VERSION}-forge"
chmod 700 "$ROOTFS_STAGING_DIR/root" "$ROOTFS_STAGING_DIR/home/$ARM64_USER" 2>/dev/null || true
[[ ! -f "$ROOTFS_STAGING_DIR/etc/shadow" ]] || chmod 600 "$ROOTFS_STAGING_DIR/etc/shadow"
[[ ! -f "$ROOTFS_STAGING_DIR/etc/gshadow" ]] || chmod 600 "$ROOTFS_STAGING_DIR/etc/gshadow"
find "$ROOTFS_STAGING_DIR" -printf '%P\n' | LC_ALL=C sort > "$OUT_DIR/rootfs.manifest"
(
cd "$ROOTFS_STAGING_DIR"
find . -print0 | cpio --null -ov --format=newc --owner 0:0 2>/dev/null | gzip -9 > "$OUT_DIR/rootfs.cpio.gz"
)
msg "ARM64 rootfs tree: $ROOTFS_STAGING_DIR"
msg "initramfs: $OUT_DIR/rootfs.cpio.gz"
-31
View File
@@ -1,31 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
source "$(dirname "$0")/common.sh"
require_cmd make "$CC" bzip2
ensure_dirs
[[ -d "$BUSYBOX_SRC_DIR" ]] || "$ROOT_DIR/scripts/fetch-sources.sh"
[[ -f "$PAM_STAGING_DIR/.forgeos-pam-complete" ]] || "$ROOT_DIR/scripts/build-pam.sh"
msg "configuring BusyBox ${BUSYBOX_VERSION}"
rm -rf "$BUSYBOX_BUILD_DIR"
mkdir -p "$BUSYBOX_BUILD_DIR"
make -C "$BUSYBOX_SRC_DIR" O="$BUSYBOX_BUILD_DIR" defconfig
apply_kconfig_fragment "$BUSYBOX_BUILD_DIR/.config" "$ROOT_DIR/config/busybox.fragment"
msg "building BusyBox ${BUSYBOX_VERSION}"
make -C "$BUSYBOX_SRC_DIR" O="$BUSYBOX_BUILD_DIR" \
CROSS_COMPILE="$CROSS_COMPILE" \
CC="$CC" \
EXTRA_CFLAGS="-I$PAM_STAGING_DIR/usr/include" \
EXTRA_LDFLAGS="-L$PAM_STAGING_DIR/usr/lib" \
-j"$JOBS"
install -Dm755 "$BUSYBOX_BUILD_DIR/busybox" "$OUT_DIR/busybox"
install -Dm644 "$BUSYBOX_BUILD_DIR/.config" "$OUT_DIR/busybox.config"
msg "busybox binary is in $OUT_DIR"
-102
View File
@@ -1,102 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
source "$(dirname "$0")/common.sh"
require_cmd meson ninja pkg-config "$CC" file ldd install tar xz
ensure_dirs
[[ -z "$CROSS_COMPILE" ]] || die "D-Bus rootfs staging currently requires a native build; CROSS_COMPILE is not supported"
[[ "$ARCH" == "x86_64" ]] || die "D-Bus rootfs staging currently supports ARCH=x86_64 only"
[[ -d "$DBUS_SRC_DIR" ]] || "$ROOT_DIR/scripts/fetch-sources.sh"
copy_runtime_dep() {
local dep=$1
local dest
[[ -e "$dep" ]] || return 0
dest="$DBUS_STAGING_DIR$dep"
mkdir -p "$(dirname "$dest")"
install -Dm755 "$dep" "$dest"
}
copy_elf_deps() {
local elf=$1
local line dep
ldd "$elf" 2>/dev/null | while IFS= read -r line; do
dep=
case "$line" in
*"=>"*"/"*)
dep=${line#*=> }
dep=${dep%% *}
;;
[[:space:]]/*)
dep=${line#"${line%%[![:space:]]*}"}
dep=${dep%% *}
;;
esac
[[ -n "${dep:-}" && "$dep" = /* ]] || continue
copy_runtime_dep "$dep"
done
}
msg "configuring D-Bus ${DBUS_VERSION}"
rm -rf "$DBUS_BUILD_DIR" "$DBUS_STAGING_DIR"
mkdir -p "$DBUS_BUILD_DIR" "$DBUS_STAGING_DIR"
meson setup "$DBUS_BUILD_DIR" "$DBUS_SRC_DIR" \
--prefix=/usr \
--libdir=lib \
--libexecdir=libexec \
--sysconfdir=/etc \
--localstatedir=/var \
--buildtype=release \
-Dmessage_bus=true \
-Dtools=true \
-Dsystemd=enabled \
-Dsystemd_system_unitdir=/usr/lib/systemd/system \
-Dsystemd_user_unitdir=/usr/lib/systemd/user \
-Duser_session=false \
-Ddbus_user=messagebus \
-Druntime_dir=/run \
-Dsystem_socket=/run/dbus/system_bus_socket \
-Dsystem_pid_file=/run/dbus/pid \
-Dsession_socket_dir=/tmp \
-Dtest_socket_dir=/tmp \
-Dtraditional_activation=false \
-Dapparmor=disabled \
-Dselinux=disabled \
-Dlibaudit=disabled \
-Dlaunchd=disabled \
-Dx11_autolaunch=disabled \
-Dinstalled_tests=false \
-Dintrusive_tests=false \
-Dmodular_tests=disabled \
-Ddoxygen_docs=disabled \
-Dducktype_docs=disabled \
-Dxml_docs=disabled \
-Dqt_help=disabled \
-Drelocation=disabled \
-Dvalgrind=disabled \
-Dstats=false
msg "building D-Bus ${DBUS_VERSION}"
meson compile -C "$DBUS_BUILD_DIR" -j "$JOBS"
msg "installing D-Bus ${DBUS_VERSION}"
DESTDIR="$DBUS_STAGING_DIR" meson install -C "$DBUS_BUILD_DIR" --no-rebuild
msg "copying D-Bus runtime library dependencies"
while IFS= read -r -d '' elf; do
file_type=$(file -b "$elf" 2>/dev/null || true)
case "$file_type" in
*ELF*) copy_elf_deps "$elf" ;;
esac
done < <(find "$DBUS_STAGING_DIR" -type f \( -perm /111 -o -name '*.so' -o -name '*.so.*' \) -print0)
[[ -x "$DBUS_STAGING_DIR/usr/bin/dbus-daemon" ]] || die "dbus-daemon binary was not installed"
[[ -S "$DBUS_STAGING_DIR/run/dbus/system_bus_socket" ]] && die "unexpected build-time system bus socket in staging"
touch "$DBUS_STAGING_DIR/.forgeos-dbus-complete"
msg "D-Bus staging tree: $DBUS_STAGING_DIR"
+7 -7
View File
@@ -7,7 +7,7 @@ source "$(dirname "$0")/common.sh"
require_cmd find openssl rsync
ensure_dirs
GNOME_DEBIAN_ARCH=${GNOME_DEBIAN_ARCH:-amd64}
GNOME_DEBIAN_ARCH=${GNOME_DEBIAN_ARCH:-$DEBIAN_ARCH}
GNOME_COMPONENTS=${GNOME_COMPONENTS:-main,contrib,non-free-firmware}
GNOME_BOOTSTRAP_TOOL=${GNOME_BOOTSTRAP_TOOL:-auto}
GNOME_USER=${GNOME_USER:-forge}
@@ -237,10 +237,10 @@ configure_identity() {
mkdir -p "$ROOTFS_STAGING_DIR/etc/default"
printf 'forgeos\n' > "$ROOTFS_STAGING_DIR/etc/hostname"
cat > "$ROOTFS_STAGING_DIR/etc/os-release" <<EOF
NAME=ForgeOS
ID=forgeos
NAME=ForgeOS ARM64
ID=forgeos-arm64
ID_LIKE=debian
PRETTY_NAME="ForgeOS GNOME ($GNOME_SUITE userland)"
PRETTY_NAME="ForgeOS ARM64 GNOME ($GNOME_SUITE userland)"
VERSION_CODENAME=$GNOME_SUITE
EOF
printf 'LANG=en_US.UTF-8\n' > "$ROOTFS_STAGING_DIR/etc/default/locale"
@@ -251,8 +251,8 @@ EOF
msg "assembling GNOME root filesystem"
BOOTSTRAP_TOOL=$(choose_bootstrap_tool)
[[ "$ARCH" == "x86_64" ]] || die "GNOME rootfs currently supports ARCH=x86_64 only"
[[ -f "$OUT_DIR/bzImage" ]] || "$ROOT_DIR/scripts/build-kernel.sh"
[[ "$ARCH" == "arm64" ]] || die "GNOME rootfs currently supports ARCH=arm64 only"
[[ -f "$KERNEL_IMAGE" ]] || "$ROOT_DIR/scripts/build-kernel.sh"
[[ -d "$MODULES_STAGING_DIR/lib/modules" ]] || "$ROOT_DIR/scripts/build-kernel.sh"
if [[ -d "$ROOTFS_STAGING_DIR" ]]; then
@@ -276,7 +276,7 @@ configure_desktop_services
mkdir -p "$ROOTFS_STAGING_DIR/lib" "$ROOTFS_STAGING_DIR/boot"
rsync -a "$MODULES_STAGING_DIR/lib/" "$ROOTFS_STAGING_DIR/lib/"
install -Dm644 "$OUT_DIR/bzImage" "$ROOTFS_STAGING_DIR/boot/vmlinuz-${KERNEL_VERSION}-forge"
install -Dm644 "$KERNEL_IMAGE" "$ROOTFS_STAGING_DIR/boot/vmlinuz-${KERNEL_VERSION}-forge"
find "$ROOTFS_STAGING_DIR" -printf '%P\n' | LC_ALL=C sort > "$OUT_DIR/rootfs.manifest"
rm -f "$OUT_DIR/rootfs.cpio.gz"
+21 -71
View File
@@ -10,30 +10,19 @@ ensure_dirs
normal_rootfs_matches() {
[[ -d "$ROOTFS_STAGING_DIR" ]] || return 1
[[ -f "$ROOTFS_STAGING_DIR/etc/forgeos-nix" ]] || return 1
if truthy "$ENABLE_DESKTOP"; then
[[ -f "$ROOTFS_STAGING_DIR/etc/forgeos-desktop" ]] || return 1
else
[[ ! -f "$ROOTFS_STAGING_DIR/etc/forgeos-desktop" ]] || return 1
fi
[[ ! -f "$ROOTFS_STAGING_DIR/etc/forgeos-doom-emacs" ]] || return 1
}
[[ -f "$OUT_DIR/bzImage" ]] || "$ROOT_DIR/scripts/build-kernel.sh"
[[ -f "$KERNEL_IMAGE" ]] || "$ROOT_DIR/scripts/build-kernel.sh"
if [[ "$DESKTOP" == "gnome" ]]; then
[[ -d "$ROOTFS_STAGING_DIR" && -f "$ROOTFS_STAGING_DIR/etc/gdm3/daemon.conf" ]] || "$ROOT_DIR/scripts/build-gnome-rootfs.sh"
else
normal_rootfs_matches || "$ROOT_DIR/scripts/build-rootfs.sh"
if ! truthy "$ENABLE_DESKTOP"; then
[[ -f "$OUT_DIR/rootfs.cpio.gz" ]] || "$ROOT_DIR/scripts/build-rootfs.sh"
fi
fi
IMAGE_PATH="$OUT_DIR/forgeos-${KERNEL_VERSION}.img"
EFI_LOADER="$OUT_DIR/BOOTX64.EFI"
EFI_KERNEL="$OUT_DIR/FORGEOS.EFI"
EFI_INITRD="$OUT_DIR/rootfs.cpio.gz"
GRUB_CFG="$OUT_DIR/grub.cfg"
ESP_END_MIB=$((1 + ESP_SIZE_MIB))
@@ -63,69 +52,43 @@ set gfxpayload=keep
insmod all_video
insmod gfxterm
terminal_output gfxterm console
set linux_common="root=PARTLABEL=root rootfstype=ext4 rootwait rw console=tty0 loglevel=7 ignore_loglevel earlyprintk=efi,keep vt.global_cursor_default=1"
set linux_common="root=PARTLABEL=root rootfstype=ext4 rootwait rw console=tty0 console=ttyAMA0,115200 loglevel=7 ignore_loglevel"
set initrd_common="rdinit=/sbin/init"
set handoff_common="rdinit=/init forgeos.switch_root=1"
menuentry "ForgeOS - Dell Precision 7720 default" {
menuentry "ForgeOS ARM64 - default" {
search --no-floppy --file --set=esp /EFI/BOOT/FORGEOS.EFI
linux ($esp)/EFI/BOOT/FORGEOS.EFI $linux_common i915.enable_psr=0 i915.fastboot=0
linux ($esp)/EFI/BOOT/FORGEOS.EFI $linux_common
}
menuentry "ForgeOS - Intel display only" {
search --no-floppy --file --set=esp /EFI/BOOT/FORGEOS.EFI
linux ($esp)/EFI/BOOT/FORGEOS.EFI $linux_common nouveau.modeset=0 i915.enable_psr=0 i915.fastboot=0
}
menuentry "ForgeOS - NVIDIA display only" {
search --no-floppy --file --set=esp /EFI/BOOT/FORGEOS.EFI
linux ($esp)/EFI/BOOT/FORGEOS.EFI $linux_common i915.modeset=0
}
menuentry "ForgeOS - firmware framebuffer safe mode" {
menuentry "ForgeOS ARM64 - firmware framebuffer safe mode" {
search --no-floppy --file --set=esp /EFI/BOOT/FORGEOS.EFI
linux ($esp)/EFI/BOOT/FORGEOS.EFI $linux_common nomodeset
}
EOF
if [[ "$DESKTOP" != "gnome" ]] && ! truthy "$ENABLE_DESKTOP"; then
if [[ "$DESKTOP" != "gnome" ]]; then
cat >> "$GRUB_CFG" <<'EOF'
menuentry "ForgeOS - initramfs-assisted root default display" {
menuentry "ForgeOS ARM64 - initramfs-assisted root" {
search --no-floppy --file --set=esp /EFI/BOOT/FORGEOS.EFI
linux ($esp)/EFI/BOOT/FORGEOS.EFI $linux_common $handoff_common i915.enable_psr=0 i915.fastboot=0
linux ($esp)/EFI/BOOT/FORGEOS.EFI $linux_common $handoff_common
initrd ($esp)/EFI/BOOT/rootfs.cpio.gz
}
menuentry "ForgeOS - initramfs-assisted root fixed GRUB framebuffer" {
menuentry "ForgeOS ARM64 - initramfs framebuffer safe mode" {
search --no-floppy --file --set=esp /EFI/BOOT/FORGEOS.EFI
set gfxmode=1024x768
set gfxpayload=keep
linux ($esp)/EFI/BOOT/FORGEOS.EFI $linux_common $handoff_common nomodeset video=efifb:1024x768 fbcon=map:0 fbcon=font:VGA8x16
linux ($esp)/EFI/BOOT/FORGEOS.EFI $linux_common $handoff_common nomodeset
initrd ($esp)/EFI/BOOT/rootfs.cpio.gz
}
menuentry "ForgeOS - systemd initramfs default display" {
menuentry "ForgeOS ARM64 - systemd initramfs" {
search --no-floppy --file --set=esp /EFI/BOOT/FORGEOS.EFI
linux ($esp)/EFI/BOOT/FORGEOS.EFI $linux_common rdinit=/sbin/init i915.enable_psr=0 i915.fastboot=0
linux ($esp)/EFI/BOOT/FORGEOS.EFI $linux_common rdinit=/sbin/init
initrd ($esp)/EFI/BOOT/rootfs.cpio.gz
}
menuentry "ForgeOS - systemd initramfs framebuffer safe mode" {
search --no-floppy --file --set=esp /EFI/BOOT/FORGEOS.EFI
linux ($esp)/EFI/BOOT/FORGEOS.EFI $linux_common $initrd_common nomodeset
initrd ($esp)/EFI/BOOT/rootfs.cpio.gz
}
menuentry "ForgeOS - systemd initramfs fixed GRUB framebuffer" {
search --no-floppy --file --set=esp /EFI/BOOT/FORGEOS.EFI
set gfxmode=1024x768
set gfxpayload=keep
linux ($esp)/EFI/BOOT/FORGEOS.EFI $linux_common $initrd_common nomodeset video=efifb:1024x768 fbcon=map:0 fbcon=font:VGA8x16
initrd ($esp)/EFI/BOOT/rootfs.cpio.gz
}
menuentry "ForgeOS - EFI stub chainload" {
menuentry "ForgeOS ARM64 - EFI stub chainload" {
search --no-floppy --file --set=esp /EFI/BOOT/FORGEOS.EFI
chainloader ($esp)/EFI/BOOT/FORGEOS.EFI
}
@@ -133,25 +96,12 @@ EOF
elif [[ "$DESKTOP" == "gnome" ]]; then
cat >> "$GRUB_CFG" <<'EOF'
menuentry "ForgeOS GNOME - graphical target" {
menuentry "ForgeOS ARM64 GNOME - graphical target" {
search --no-floppy --file --set=esp /EFI/BOOT/FORGEOS.EFI
linux ($esp)/EFI/BOOT/FORGEOS.EFI $linux_common systemd.unit=graphical.target
}
menuentry "ForgeOS - EFI stub chainload" {
search --no-floppy --file --set=esp /EFI/BOOT/FORGEOS.EFI
chainloader ($esp)/EFI/BOOT/FORGEOS.EFI
}
EOF
else
cat >> "$GRUB_CFG" <<'EOF'
menuentry "ForgeOS Openbox desktop" {
search --no-floppy --file --set=esp /EFI/BOOT/FORGEOS.EFI
linux ($esp)/EFI/BOOT/FORGEOS.EFI $linux_common systemd.unit=multi-user.target
}
menuentry "ForgeOS - EFI stub chainload" {
menuentry "ForgeOS ARM64 - EFI stub chainload" {
search --no-floppy --file --set=esp /EFI/BOOT/FORGEOS.EFI
chainloader ($esp)/EFI/BOOT/FORGEOS.EFI
}
@@ -162,8 +112,8 @@ EOF
prepare_efi_loader() {
case "$BOOTLOADER" in
stub)
"$ROOT_DIR/scripts/sign-efi-loader.sh" "$OUT_DIR/bzImage" "$EFI_LOADER"
install -m 0644 "$OUT_DIR/bzImage" "$EFI_KERNEL"
"$ROOT_DIR/scripts/sign-efi-loader.sh" "$KERNEL_IMAGE" "$EFI_LOADER"
install -m 0644 "$KERNEL_IMAGE" "$EFI_KERNEL"
;;
grub)
if truthy "$SECURE_BOOT"; then
@@ -173,11 +123,11 @@ prepare_efi_loader() {
write_grub_config
msg "building GRUB UEFI fallback loader"
grub-mkstandalone \
-O x86_64-efi \
-O "$GRUB_PLATFORM" \
-o "$EFI_LOADER" \
--modules="part_gpt fat search search_fs_file linux chain all_video efi_gop efi_uga gfxterm font video video_fb" \
"boot/grub/grub.cfg=$GRUB_CFG" >/dev/null
install -m 0644 "$OUT_DIR/bzImage" "$EFI_KERNEL"
install -m 0644 "$KERNEL_IMAGE" "$EFI_KERNEL"
;;
*)
die "unsupported BOOTLOADER=$BOOTLOADER"
@@ -208,9 +158,9 @@ truncate -s "$ESP_SIZE" "$ESP_IMAGE"
mkfs.vfat -F 32 -n "$EFI_LABEL" "$ESP_IMAGE" >/dev/null
mmd -i "$ESP_IMAGE" ::/EFI
mmd -i "$ESP_IMAGE" ::/EFI/BOOT
mcopy -i "$ESP_IMAGE" "$EFI_LOADER" ::/EFI/BOOT/BOOTX64.EFI
mcopy -i "$ESP_IMAGE" "$EFI_LOADER" "::/EFI/BOOT/$EFI_BOOT_NAME"
mcopy -i "$ESP_IMAGE" "$EFI_KERNEL" ::/EFI/BOOT/FORGEOS.EFI
if [[ "$DESKTOP" != "gnome" ]] && ! truthy "$ENABLE_DESKTOP"; then
if [[ "$DESKTOP" != "gnome" ]]; then
mcopy -i "$ESP_IMAGE" "$EFI_INITRD" ::/EFI/BOOT/rootfs.cpio.gz
fi
+7 -7
View File
@@ -4,7 +4,7 @@ set -euo pipefail
source "$(dirname "$0")/common.sh"
require_cmd make gcc xz
require_cmd make "$CC" xz
ensure_dirs
[[ -d "$KERNEL_SRC_DIR" ]] || "$ROOT_DIR/scripts/fetch-sources.sh"
@@ -13,19 +13,19 @@ msg "configuring Linux ${KERNEL_VERSION}"
rm -rf "$MODULES_STAGING_DIR"
mkdir -p "$KERNEL_BUILD_DIR" "$MODULES_STAGING_DIR"
make -C "$KERNEL_SRC_DIR" O="$KERNEL_BUILD_DIR" ARCH="$ARCH" x86_64_defconfig
make -C "$KERNEL_SRC_DIR" O="$KERNEL_BUILD_DIR" ARCH="$KERNEL_MAKE_ARCH" "$KERNEL_DEFCONFIG"
apply_kconfig_fragment "$KERNEL_BUILD_DIR/.config" "$ROOT_DIR/config/kernel.fragment"
cmdline_fragment=$(mktemp)
printf 'CONFIG_CMDLINE="root=PARTLABEL=root rootfstype=ext4 rootwait rw console=tty0 console=ttyS0,115200n8 loglevel=7 ignore_loglevel i915.enable_psr=0 i915.fastboot=0"\n' > "$cmdline_fragment"
printf 'CONFIG_CMDLINE="root=PARTLABEL=root rootfstype=ext4 rootwait rw console=tty0 console=%s loglevel=7 ignore_loglevel"\n' "$SERIAL_CONSOLE" > "$cmdline_fragment"
apply_kconfig_fragment "$KERNEL_BUILD_DIR/.config" "$cmdline_fragment"
rm -f "$cmdline_fragment"
make -C "$KERNEL_SRC_DIR" O="$KERNEL_BUILD_DIR" ARCH="$ARCH" olddefconfig
make -C "$KERNEL_SRC_DIR" O="$KERNEL_BUILD_DIR" ARCH="$KERNEL_MAKE_ARCH" CROSS_COMPILE="$CROSS_COMPILE" olddefconfig
msg "building Linux ${KERNEL_VERSION}"
make -C "$KERNEL_SRC_DIR" O="$KERNEL_BUILD_DIR" ARCH="$ARCH" CROSS_COMPILE="$CROSS_COMPILE" -j"$JOBS" bzImage modules
make -C "$KERNEL_SRC_DIR" O="$KERNEL_BUILD_DIR" ARCH="$ARCH" CROSS_COMPILE="$CROSS_COMPILE" INSTALL_MOD_PATH="$MODULES_STAGING_DIR" modules_install
make -C "$KERNEL_SRC_DIR" O="$KERNEL_BUILD_DIR" ARCH="$KERNEL_MAKE_ARCH" CROSS_COMPILE="$CROSS_COMPILE" -j"$JOBS" "$KERNEL_IMAGE_TARGET" modules
make -C "$KERNEL_SRC_DIR" O="$KERNEL_BUILD_DIR" ARCH="$KERNEL_MAKE_ARCH" CROSS_COMPILE="$CROSS_COMPILE" INSTALL_MOD_PATH="$MODULES_STAGING_DIR" modules_install
install -Dm644 "$KERNEL_BUILD_DIR/arch/x86/boot/bzImage" "$OUT_DIR/bzImage"
install -Dm644 "$KERNEL_BUILD_DIR/$KERNEL_IMAGE_RELATIVE" "$KERNEL_IMAGE"
install -Dm644 "$KERNEL_BUILD_DIR/.config" "$OUT_DIR/kernel.config"
install -Dm644 "$KERNEL_BUILD_DIR/System.map" "$OUT_DIR/System.map"
-107
View File
@@ -1,107 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
source "$(dirname "$0")/common.sh"
require_cmd meson ninja pkg-config "$CC" file ldd ldconfig install bison flex
ensure_dirs
[[ -z "$CROSS_COMPILE" ]] || die "Linux-PAM rootfs staging currently requires a native build; CROSS_COMPILE is not supported"
[[ "$ARCH" == "x86_64" ]] || die "Linux-PAM rootfs staging currently supports ARCH=x86_64 only"
[[ -d "$PAM_SRC_DIR" ]] || "$ROOT_DIR/scripts/fetch-sources.sh"
copy_runtime_dep() {
local dep=$1
local dest
[[ -e "$dep" ]] || return 0
dest="$PAM_STAGING_DIR$dep"
mkdir -p "$(dirname "$dest")"
install -Dm755 "$dep" "$dest"
}
copy_elf_deps() {
local elf=$1
local line dep
LD_LIBRARY_PATH="$PAM_STAGING_DIR/usr/lib:${LD_LIBRARY_PATH:-}" ldd "$elf" 2>/dev/null | while IFS= read -r line; do
dep=
case "$line" in
*"=>"*"/"*)
dep=${line#*=> }
dep=${dep%% *}
;;
[[:space:]]/*)
dep=${line#"${line%%[![:space:]]*}"}
dep=${dep%% *}
;;
esac
[[ -n "${dep:-}" && "$dep" = /* ]] || continue
case "$dep" in
"$PAM_STAGING_DIR"/*)
continue
;;
esac
copy_runtime_dep "$dep"
done
}
msg "configuring Linux-PAM ${PAM_VERSION}"
rm -rf "$PAM_BUILD_DIR" "$PAM_STAGING_DIR"
mkdir -p "$PAM_BUILD_DIR" "$PAM_STAGING_DIR"
meson setup "$PAM_BUILD_DIR" "$PAM_SRC_DIR" \
--prefix=/usr \
--libdir=lib \
--sysconfdir=/etc \
--localstatedir=/var \
-Ddocs=disabled \
-Di18n=disabled \
-Daudit=disabled \
-Deconf=disabled \
-Dlogind=disabled \
-Delogind=disabled \
-Dopenssl=disabled \
-Dpwaccess=disabled \
-Dselinux=disabled \
-Dnis=disabled \
-Dexamples=false \
-Dxtests=false \
-Dpam_userdb=disabled \
-Dpam_lastlog=disabled \
-Dpam_unix=enabled \
-Dsecuredir=/usr/lib/security \
-Dsconfigdir=/etc/security \
-Dvendordir=/usr/share/pam
msg "building Linux-PAM ${PAM_VERSION}"
meson compile -C "$PAM_BUILD_DIR" -j "$JOBS"
msg "installing Linux-PAM ${PAM_VERSION}"
DESTDIR="$PAM_STAGING_DIR" meson install -C "$PAM_BUILD_DIR" --no-rebuild
mkdir -p "$PAM_BUILD_DIR/pkgconfig"
for pc in pam pam_misc pamc; do
sed "s|^prefix=.*|prefix=$PAM_STAGING_DIR/usr|" \
"$PAM_STAGING_DIR/usr/lib/pkgconfig/$pc.pc" > "$PAM_BUILD_DIR/pkgconfig/$pc.pc"
done
msg "copying Linux-PAM runtime library dependencies"
while IFS= read -r -d '' elf; do
file_type=$(file -b "$elf" 2>/dev/null || true)
case "$file_type" in
*ELF*) copy_elf_deps "$elf" ;;
esac
done < <(find "$PAM_STAGING_DIR" -type f \( -perm /111 -o -name '*.so' -o -name '*.so.*' \) -print0)
[[ -e "$PAM_STAGING_DIR/usr/lib/libpam.so" ]] || die "libpam was not installed"
[[ -e "$PAM_STAGING_DIR/usr/lib/libpam_misc.so" ]] || die "libpam_misc was not installed"
[[ -f "$PAM_STAGING_DIR/usr/include/security/pam_appl.h" ]] || die "PAM headers were not installed"
[[ -f "$PAM_STAGING_DIR/usr/lib/pkgconfig/pam.pc" ]] || die "PAM pkg-config file was not installed"
[[ -f "$PAM_STAGING_DIR/usr/lib/security/pam_unix.so" ]] || die "pam_unix module was not installed"
[[ -f "$PAM_STAGING_DIR/usr/lib/security/pam_deny.so" ]] || die "pam_deny module was not installed"
[[ -f "$PAM_STAGING_DIR/usr/lib/security/pam_permit.so" ]] || die "pam_permit module was not installed"
touch "$PAM_STAGING_DIR/.forgeos-pam-complete"
msg "Linux-PAM staging tree: $PAM_STAGING_DIR"
+1 -182
View File
@@ -4,185 +4,4 @@ set -euo pipefail
source "$(dirname "$0")/common.sh"
copy_runtime_dep() {
local dep=$1
local dest
[[ -e "$dep" ]] || return 0
case "$dep" in
"$PAM_STAGING_DIR"/*)
dest="$ROOTFS_STAGING_DIR/${dep#"$PAM_STAGING_DIR"/}"
;;
"$ROOTFS_STAGING_DIR"/*)
dest="$dep"
;;
"$SYSTEMD_STAGING_DIR"/*)
dest="$ROOTFS_STAGING_DIR/${dep#"$SYSTEMD_STAGING_DIR"/}"
;;
"$DBUS_STAGING_DIR"/*)
dest="$ROOTFS_STAGING_DIR/${dep#"$DBUS_STAGING_DIR"/}"
;;
*)
dest="$ROOTFS_STAGING_DIR$dep"
;;
esac
[[ -e "$dest" ]] && return 0
mkdir -p "$(dirname "$dest")"
install -Dm755 "$dep" "$dest"
}
copy_busybox_deps() {
local line dep
LD_LIBRARY_PATH="$ROOTFS_STAGING_DIR/usr/lib:$PAM_STAGING_DIR/usr/lib:$SYSTEMD_STAGING_DIR/usr/lib:$DBUS_STAGING_DIR/usr/lib:${LD_LIBRARY_PATH:-}" ldd "$BUSYBOX_BUILD_DIR/busybox" 2>/dev/null | while IFS= read -r line; do
dep=
case "$line" in
*"=>"*"/"*)
dep=${line#*=> }
dep=${dep%% *}
;;
[[:space:]]/*)
dep=${line#"${line%%[![:space:]]*}"}
dep=${dep%% *}
;;
esac
[[ -n "${dep:-}" && "$dep" = /* ]] || continue
copy_runtime_dep "$dep"
done
}
if [[ "$DESKTOP" == "gnome" ]]; then
exec "$ROOT_DIR/scripts/build-gnome-rootfs.sh"
fi
require_cmd make rsync cpio gzip
ensure_dirs
[[ -f "$PAM_STAGING_DIR/.forgeos-pam-complete" ]] || "$ROOT_DIR/scripts/build-pam.sh"
[[ -x "$BUSYBOX_BUILD_DIR/busybox" && -f "$OUT_DIR/busybox.config" ]] || "$ROOT_DIR/scripts/build-busybox.sh"
grep -qx 'CONFIG_PAM=y' "$OUT_DIR/busybox.config" || "$ROOT_DIR/scripts/build-busybox.sh"
grep -qx 'CONFIG_LOGIN_SESSION_AS_CHILD=y' "$OUT_DIR/busybox.config" || "$ROOT_DIR/scripts/build-busybox.sh"
[[ -x "$SYSTEMD_STAGING_DIR/usr/lib/systemd/systemd" && -x "$SYSTEMD_STAGING_DIR/usr/lib/systemd/systemd-logind" && -f "$SYSTEMD_STAGING_DIR/usr/lib/security/pam_systemd.so" && -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"
msg "assembling root filesystem"
if [[ -d "$ROOTFS_STAGING_DIR" ]]; then
chmod -R u+w "$ROOTFS_STAGING_DIR" 2>/dev/null || true
fi
rm -rf "$ROOTFS_STAGING_DIR"
mkdir -p "$ROOTFS_STAGING_DIR"
make -C "$BUSYBOX_SRC_DIR" O="$BUSYBOX_BUILD_DIR" \
CONFIG_PREFIX="$ROOTFS_STAGING_DIR" \
EXTRA_CFLAGS="-I$PAM_STAGING_DIR/usr/include" \
EXTRA_LDFLAGS="-L$PAM_STAGING_DIR/usr/lib" \
install
rsync -a "$PAM_STAGING_DIR"/ "$ROOTFS_STAGING_DIR"/
rsync -a "$SYSTEMD_STAGING_DIR"/ "$ROOTFS_STAGING_DIR"/
rsync -a "$DBUS_STAGING_DIR"/ "$ROOTFS_STAGING_DIR"/
copy_busybox_deps
mkdir -p "$ROOTFS_STAGING_DIR"/{proc,sys,dev,run/dbus,tmp,var/lib/dbus,var/log,root,home/forge,boot,mnt,etc/systemd/system}
rsync -a "$OVERLAY_DIR"/ "$ROOTFS_STAGING_DIR"/
"$ROOT_DIR/scripts/stage-nix.sh"
rm -f "$ROOTFS_STAGING_DIR/sbin/init"
ln -s ../usr/lib/systemd/systemd "$ROOTFS_STAGING_DIR/sbin/init"
ln -sfn ../../sbin/modprobe "$ROOTFS_STAGING_DIR/usr/bin/modprobe"
ln -sfn ../run/systemd/resolve/resolv.conf "$ROOTFS_STAGING_DIR/etc/resolv.conf"
ln -sfn ../run "$ROOTFS_STAGING_DIR/var/run"
mkdir -p \
"$ROOTFS_STAGING_DIR/etc/systemd/system/getty.target.wants" \
"$ROOTFS_STAGING_DIR/etc/systemd/system/multi-user.target.wants" \
"$ROOTFS_STAGING_DIR/etc/systemd/system/sockets.target.wants" \
"$ROOTFS_STAGING_DIR/etc/systemd/system/sysinit.target.wants"
ln -sfn /usr/lib/systemd/system/multi-user.target \
"$ROOTFS_STAGING_DIR/etc/systemd/system/default.target"
ln -sfn /etc/systemd/system/forgeos-login@.service \
"$ROOTFS_STAGING_DIR/etc/systemd/system/getty.target.wants/forgeos-login@tty1.service"
ln -sfn /etc/systemd/system/forgeos-login@.service \
"$ROOTFS_STAGING_DIR/etc/systemd/system/getty.target.wants/forgeos-login@ttyS0.service"
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 /etc/systemd/system/forgeos-home-ownership.service \
"$ROOTFS_STAGING_DIR/etc/systemd/system/multi-user.target.wants/forgeos-home-ownership.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 \
"$ROOTFS_STAGING_DIR/etc/systemd/system/sysinit.target.wants/systemd-resolved.service"
ln -sfn /usr/lib/systemd/system/systemd-networkd.socket \
"$ROOTFS_STAGING_DIR/etc/systemd/system/sockets.target.wants/systemd-networkd.socket"
ln -sfn /usr/lib/systemd/system/systemd-resolved-monitor.socket \
"$ROOTFS_STAGING_DIR/etc/systemd/system/sockets.target.wants/systemd-resolved-monitor.socket"
ln -sfn /usr/lib/systemd/system/systemd-resolved-varlink.socket \
"$ROOTFS_STAGING_DIR/etc/systemd/system/sockets.target.wants/systemd-resolved-varlink.socket"
ln -sfn /usr/lib/systemd/system/systemd-udevd.service \
"$ROOTFS_STAGING_DIR/etc/systemd/system/sysinit.target.wants/systemd-udevd.service"
ln -sfn /usr/lib/systemd/system/systemd-udevd-control.socket \
"$ROOTFS_STAGING_DIR/etc/systemd/system/sockets.target.wants/systemd-udevd-control.socket"
ln -sfn /usr/lib/systemd/system/systemd-udevd-kernel.socket \
"$ROOTFS_STAGING_DIR/etc/systemd/system/sockets.target.wants/systemd-udevd-kernel.socket"
ln -sfn /etc/systemd/system/forgeos-nix-bootstrap.service \
"$ROOTFS_STAGING_DIR/etc/systemd/system/sysinit.target.wants/forgeos-nix-bootstrap.service"
ln -sfn /etc/systemd/system/nix-daemon.service \
"$ROOTFS_STAGING_DIR/etc/systemd/system/multi-user.target.wants/nix-daemon.service"
ln -sfn /etc/systemd/system/nix-daemon.socket \
"$ROOTFS_STAGING_DIR/etc/systemd/system/sockets.target.wants/nix-daemon.socket"
ln -sfn /dev/null "$ROOTFS_STAGING_DIR/etc/systemd/system/autovt@.service"
ln -sfn /dev/null "$ROOTFS_STAGING_DIR/etc/systemd/system/getty@tty1.service"
ln -sfn /dev/null "$ROOTFS_STAGING_DIR/etc/systemd/system/serial-getty@ttyS0.service"
if [[ -d "$MODULES_STAGING_DIR/lib/modules" ]]; then
mkdir -p "$ROOTFS_STAGING_DIR/lib"
rsync -a "$MODULES_STAGING_DIR/lib/" "$ROOTFS_STAGING_DIR/lib/"
fi
if truthy "$ENABLE_DESKTOP"; then
"$ROOT_DIR/scripts/stage-openbox-desktop.sh"
fi
chmod 755 \
"$ROOTFS_STAGING_DIR/init" \
"$ROOTFS_STAGING_DIR/sbin/forgeos-bootdiag" \
"$ROOTFS_STAGING_DIR/sbin/forgeos-console-banner" \
"$ROOTFS_STAGING_DIR/sbin/forgeos-switch-root" \
"$ROOTFS_STAGING_DIR/usr/lib/forgeos/nix-bootstrap" \
"$ROOTFS_STAGING_DIR/usr/bin/neofetch" \
"$ROOTFS_STAGING_DIR/usr/share/udhcpc/default.script"
chmod 700 "$ROOTFS_STAGING_DIR/root" "$ROOTFS_STAGING_DIR/home/forge"
chown 1000:1000 "$ROOTFS_STAGING_DIR/home/forge"
[[ ! -f "$ROOTFS_STAGING_DIR/etc/shadow" ]] || chmod 600 "$ROOTFS_STAGING_DIR/etc/shadow"
[[ ! -f "$ROOTFS_STAGING_DIR/etc/gshadow" ]] || chmod 600 "$ROOTFS_STAGING_DIR/etc/gshadow"
find "$ROOTFS_STAGING_DIR" -printf '%P\n' | LC_ALL=C sort > "$OUT_DIR/rootfs.manifest"
if truthy "$ENABLE_DESKTOP"; then
rm -f "$OUT_DIR/rootfs.cpio.gz"
msg "rootfs tree: $ROOTFS_STAGING_DIR"
msg "desktop rootfs uses the ext4 image path; initramfs generation skipped"
else
(
cd "$ROOTFS_STAGING_DIR"
find . -print0 | cpio --null -ov --format=newc --owner 0:0 2>/dev/null | gzip -9 > "$OUT_DIR/rootfs.cpio.gz"
)
msg "rootfs tree: $ROOTFS_STAGING_DIR"
msg "initramfs: $OUT_DIR/rootfs.cpio.gz"
fi
exec "$ROOT_DIR/scripts/build-arm64-rootfs.sh"
-218
View File
@@ -1,218 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
source "$(dirname "$0")/common.sh"
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"
[[ "$ARCH" == "x86_64" ]] || die "systemd rootfs staging currently supports ARCH=x86_64 only"
[[ -d "$SYSTEMD_SRC_DIR" ]] || "$ROOT_DIR/scripts/fetch-sources.sh"
[[ -f "$PAM_STAGING_DIR/.forgeos-pam-complete" && -f "$PAM_BUILD_DIR/pkgconfig/pam.pc" ]] || "$ROOT_DIR/scripts/build-pam.sh"
copy_runtime_dep() {
local dep=$1
local dest
[[ -e "$dep" ]] || return 0
case "$dep" in
"$PAM_STAGING_DIR"/*)
dest="$SYSTEMD_STAGING_DIR/${dep#"$PAM_STAGING_DIR"/}"
;;
*)
dest="$SYSTEMD_STAGING_DIR$dep"
;;
esac
mkdir -p "$(dirname "$dest")"
install -Dm755 "$dep" "$dest"
}
copy_elf_deps() {
local elf=$1
local line dep
LD_LIBRARY_PATH="$PAM_STAGING_DIR/usr/lib:${LD_LIBRARY_PATH:-}" ldd "$elf" 2>/dev/null | while IFS= read -r line; do
dep=
case "$line" in
*"=>"*"/"*)
dep=${line#*=> }
dep=${dep%% *}
;;
[[:space:]]/*)
dep=${line#"${line%%[![:space:]]*}"}
dep=${dep%% *}
;;
esac
[[ -n "${dep:-}" && "$dep" = /* ]] || continue
copy_runtime_dep "$dep"
done
}
copy_named_library() {
local soname=$1
local ldconfig_output path
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"
}
msg "configuring systemd ${SYSTEMD_VERSION}"
rm -rf "$SYSTEMD_BUILD_DIR" "$SYSTEMD_STAGING_DIR"
mkdir -p "$SYSTEMD_BUILD_DIR" "$SYSTEMD_STAGING_DIR"
PKG_CONFIG_PATH="$PAM_BUILD_DIR/pkgconfig:${PKG_CONFIG_PATH:-}" \
LD_LIBRARY_PATH="$PAM_STAGING_DIR/usr/lib:${LD_LIBRARY_PATH:-}" \
meson setup "$SYSTEMD_BUILD_DIR" "$SYSTEMD_SRC_DIR" \
--prefix=/usr \
--libdir=lib \
--sysconfdir=/etc \
--localstatedir=/var \
-Dmode=release \
-Dsplit-bin=true \
-Dinitrd=true \
-Dcompat-sysv-interfaces=false \
-Dquotaon-path=/bin/false \
-Dquotacheck-path=/bin/false \
-Dkmod-path=/sbin/modprobe \
-Dkexec-path=/bin/false \
-Dsulogin-path=/sbin/sulogin \
-Dswapon-path=/sbin/swapon \
-Dswapoff-path=/sbin/swapoff \
-Dagetty-path=/sbin/getty \
-Dmount-path=/bin/mount \
-Dumount-path=/bin/umount \
-Dloadkeys-path=/sbin/loadkmap \
-Dsetfont-path=/usr/sbin/setfont \
-Dnologin-path=/usr/sbin/nologin \
-Dsystemd-network-uid=192 \
-Dsystemd-resolve-uid=193 \
-Dadm-group=false \
-Dwheel-group=false \
-Dtests=false \
-Dslow-tests=false \
-Dfuzz-tests=false \
-Dinstall-tests=false \
-Dman=disabled \
-Dhtml=disabled \
-Dtranslations=false \
-Dfirstboot=false \
-Dbinfmt=false \
-Dhibernate=false \
-Dldconfig=false \
-Dresolve=true \
-Defi=false \
-Dtpm=false \
-Drepart=disabled \
-Dsysupdate=disabled \
-Dsysupdated=disabled \
-Dcoredump=false \
-Dpstore=false \
-Doomd=false \
-Dlogind=true \
-Dhostnamed=false \
-Dlocaled=false \
-Dmachined=false \
-Dportabled=false \
-Dsysext=false \
-Dmountfsd=false \
-Duserdb=false \
-Dhomed=disabled \
-Dpamlibdir=/usr/lib/security \
-Dpamconfdir=/etc/pam.d \
-Dnetworkd=true \
-Ddefault-network=false \
-Dtimedated=false \
-Dtimesyncd=false \
-Dremote=disabled \
-Dnsresourced=false \
-Dnss-myhostname=false \
-Dnss-mymachines=disabled \
-Dnss-resolve=disabled \
-Dnss-systemd=false \
-Dsysusers=false \
-Dbacklight=false \
-Dvconsole=false \
-Dquotacheck=false \
-Dhwdb=false \
-Drfkill=false \
-Dxdg-autostart=false \
-Dnspawn=disabled \
-Dvmspawn=disabled \
-Dimportd=disabled \
-Dseccomp=disabled \
-Dselinux=disabled \
-Dapparmor=disabled \
-Dsmack=false \
-Dpolkit=disabled \
-Dima=false \
-Dipe=false \
-Dacl=disabled \
-Daudit=disabled \
-Dfdisk=disabled \
-Dkmod=disabled \
-Dpam=enabled \
-Dpasswdqc=disabled \
-Dpwquality=disabled \
-Dmicrohttpd=disabled \
-Dlibcrypt=disabled \
-Dlibcryptsetup=disabled \
-Dlibcryptsetup-plugins=disabled \
-Dlibcurl=disabled \
-Didn=false \
-Dlibidn2=disabled \
-Dqrencode=disabled \
-Dgcrypt=disabled \
-Dgnutls=disabled \
-Dopenssl=disabled \
-Dp11kit=disabled \
-Dlibfido2=disabled \
-Dtpm2=disabled \
-Delfutils=disabled \
-Dbzip2=disabled \
-Dxz=disabled \
-Dlz4=disabled \
-Dzstd=disabled \
-Dxkbcommon=disabled \
-Dpcre2=disabled \
-Dglib=disabled \
-Ddbus=disabled \
-Dlibarchive=disabled \
-Dbootloader=disabled \
-Dkernel-install=false \
-Dukify=disabled \
-Danalyze=false \
-Dbashcompletiondir=no \
-Dzshcompletiondir=no \
-Ddefault-user-shell=/bin/sh
msg "building systemd ${SYSTEMD_VERSION}"
LD_LIBRARY_PATH="$PAM_STAGING_DIR/usr/lib:${LD_LIBRARY_PATH:-}" \
meson compile -C "$SYSTEMD_BUILD_DIR" -j "$JOBS"
msg "installing systemd ${SYSTEMD_VERSION}"
LD_LIBRARY_PATH="$PAM_STAGING_DIR/usr/lib:${LD_LIBRARY_PATH:-}" \
DESTDIR="$SYSTEMD_STAGING_DIR" meson install -C "$SYSTEMD_BUILD_DIR" --no-rebuild
msg "copying systemd runtime library dependencies"
while IFS= read -r -d '' elf; do
file_type=$(file -b "$elf" 2>/dev/null || true)
case "$file_type" in
*ELF*) copy_elf_deps "$elf" ;;
esac
done < <(find "$SYSTEMD_STAGING_DIR" -type f \( -perm /111 -o -name '*.so' -o -name '*.so.*' \) -print0)
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/lib/security/pam_systemd.so" ]] || die "pam_systemd module was not installed"
[[ -x "$SYSTEMD_STAGING_DIR/usr/lib/systemd/systemd-user-runtime-dir" ]] || die "systemd-user-runtime-dir 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"
+32 -32
View File
@@ -10,18 +10,22 @@ STAGING_DIR=${STAGING_DIR:-"$ROOT_DIR/staging"}
OUT_DIR=${OUT_DIR:-"$ROOT_DIR/out"}
OVERLAY_DIR=${OVERLAY_DIR:-"$ROOT_DIR/overlay/rootfs"}
ARCH=${ARCH:-x86_64}
ARCH=${ARCH:-arm64}
KERNEL_VERSION=${KERNEL_VERSION:-7.1}
BUSYBOX_VERSION=${BUSYBOX_VERSION:-1.38.0}
SYSTEMD_VERSION=${SYSTEMD_VERSION:-260}
DBUS_VERSION=${DBUS_VERSION:-1.16.2}
PAM_VERSION=${PAM_VERSION:-1.7.2}
NIX_VERSION=${NIX_VERSION:-2.34.0}
NIX_SYSTEM=${NIX_SYSTEM:-x86_64-linux}
NIX_SYSTEM=${NIX_SYSTEM:-aarch64-linux}
DESKTOP=${DESKTOP:-console}
ENABLE_DESKTOP=${ENABLE_DESKTOP:-0}
ROOT_LABEL=${ROOT_LABEL:-FORGE_ROOT}
EFI_LABEL=${EFI_LABEL:-FORGE_EFI}
case "$ARCH" in
arm64|aarch64)
ARCH=arm64
;;
*)
printf 'error: ForgeOS ARM64 supports ARCH=arm64 only, got ARCH=%s\n' "$ARCH" >&2
exit 1
;;
esac
case "$DESKTOP" in
console|gnome) ;;
*)
@@ -32,8 +36,6 @@ esac
if [[ -z "${IMAGE_SIZE_MIB:-}" ]]; then
if [[ "$DESKTOP" == "gnome" ]]; then
IMAGE_SIZE_MIB=12288
elif [[ "$ENABLE_DESKTOP" =~ ^(1|true|TRUE|yes|YES|on|ON)$ ]]; then
IMAGE_SIZE_MIB=6144
else
IMAGE_SIZE_MIB=4096
fi
@@ -47,44 +49,42 @@ SECURE_BOOT_KEY_DIR=${SECURE_BOOT_KEY_DIR:-"$OUT_DIR/secure-boot"}
SECURE_BOOT_COMMON_NAME=${SECURE_BOOT_COMMON_NAME:-ForgeOS Secure Boot}
JOBS=${JOBS:-$(getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)}
CROSS_COMPILE=${CROSS_COMPILE:-}
if [[ -z "$CROSS_COMPILE" && "$(uname -m)" != "aarch64" ]]; then
CROSS_COMPILE=aarch64-linux-gnu-
fi
CC=${CC:-${CROSS_COMPILE}gcc}
DEBIAN_ARCH=${DEBIAN_ARCH:-arm64}
KERNEL_MAKE_ARCH=arm64
KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:-defconfig}
KERNEL_IMAGE_TARGET=${KERNEL_IMAGE_TARGET:-Image}
KERNEL_IMAGE_RELATIVE=${KERNEL_IMAGE_RELATIVE:-arch/arm64/boot/Image}
KERNEL_IMAGE_NAME=${KERNEL_IMAGE_NAME:-Image}
KERNEL_IMAGE="$OUT_DIR/$KERNEL_IMAGE_NAME"
IMAGE_NAME=${IMAGE_NAME:-"forgeos-arm64-${KERNEL_VERSION}.img"}
IMAGE_PATH="$OUT_DIR/$IMAGE_NAME"
EFI_BOOT_NAME=${EFI_BOOT_NAME:-BOOTAA64.EFI}
EFI_LOADER="$OUT_DIR/$EFI_BOOT_NAME"
EFI_KERNEL="$OUT_DIR/FORGEOS.EFI"
GRUB_PLATFORM=${GRUB_PLATFORM:-arm64-efi}
SERIAL_CONSOLE=${SERIAL_CONSOLE:-ttyAMA0,115200}
QEMU_SYSTEM=${QEMU_SYSTEM:-qemu-system-aarch64}
QEMU_MACHINE=${QEMU_MACHINE:-virt}
QEMU_CPU=${QEMU_CPU:-max}
KERNEL_MAJOR=${KERNEL_VERSION%%.*}
KERNEL_TARBALL="linux-${KERNEL_VERSION}.tar.xz"
KERNEL_URL="https://cdn.kernel.org/pub/linux/kernel/v${KERNEL_MAJOR}.x/${KERNEL_TARBALL}"
BUSYBOX_TARBALL="busybox-${BUSYBOX_VERSION}.tar.bz2"
BUSYBOX_URL="https://busybox.net/downloads/${BUSYBOX_TARBALL}"
SYSTEMD_TARBALL="systemd-v${SYSTEMD_VERSION}.tar.gz"
SYSTEMD_URL="https://github.com/systemd/systemd/archive/refs/tags/v${SYSTEMD_VERSION}.tar.gz"
DBUS_TARBALL="dbus-${DBUS_VERSION}.tar.xz"
DBUS_URL="https://dbus.freedesktop.org/releases/dbus/${DBUS_TARBALL}"
PAM_TARBALL="linux-pam-${PAM_VERSION}.tar.gz"
PAM_URL="https://github.com/linux-pam/linux-pam/archive/refs/tags/v${PAM_VERSION}.tar.gz"
NIX_TARBALL="nix-${NIX_VERSION}-${NIX_SYSTEM}.tar.xz"
NIX_URL="https://releases.nixos.org/nix/nix-${NIX_VERSION}/${NIX_TARBALL}"
GNOME_SUITE=${GNOME_SUITE:-trixie}
GNOME_MIRROR=${GNOME_MIRROR:-http://deb.debian.org/debian}
OPENBOX_DESKTOP_PACKAGES=${OPENBOX_DESKTOP_PACKAGES:-openbox tint2 pcmanfm xinit xserver-xorg-core xserver-xorg-input-libinput xserver-xorg-video-fbdev xserver-xorg-video-vesa xserver-xorg-video-vmware lxterminal fonts-dejavu adwaita-icon-theme hicolor-icon-theme shared-mime-info}
OPENBOX_DESKTOP_SKIP_PACKAGES=${OPENBOX_DESKTOP_SKIP_PACKAGES:-base-files dbus dbus-bin dbus-daemon dbus-session-bus-common dbus-system-bus-common dbus-user-session debconf dpkg init-system-helpers keyboard-configuration libpam-systemd mount procps systemd systemd-sysv sysvinit-utils tar tzdata udev}
KERNEL_SRC_DIR="$SOURCE_DIR/linux-${KERNEL_VERSION}"
BUSYBOX_SRC_DIR="$SOURCE_DIR/busybox-${BUSYBOX_VERSION}"
SYSTEMD_SRC_DIR="$SOURCE_DIR/systemd-${SYSTEMD_VERSION}"
DBUS_SRC_DIR="$SOURCE_DIR/dbus-${DBUS_VERSION}"
PAM_SRC_DIR="$SOURCE_DIR/linux-pam-${PAM_VERSION}"
NIX_SRC_DIR="$SOURCE_DIR/nix-${NIX_VERSION}-${NIX_SYSTEM}"
KERNEL_BUILD_DIR="$BUILD_DIR/linux-${KERNEL_VERSION}"
BUSYBOX_BUILD_DIR="$BUILD_DIR/busybox-${BUSYBOX_VERSION}"
SYSTEMD_BUILD_DIR="$BUILD_DIR/systemd-${SYSTEMD_VERSION}"
DBUS_BUILD_DIR="$BUILD_DIR/dbus-${DBUS_VERSION}"
PAM_BUILD_DIR="$BUILD_DIR/linux-pam-${PAM_VERSION}"
MODULES_STAGING_DIR="$STAGING_DIR/modules"
SYSTEMD_STAGING_DIR="$STAGING_DIR/systemd"
DBUS_STAGING_DIR="$STAGING_DIR/dbus"
PAM_STAGING_DIR="$STAGING_DIR/pam"
ROOTFS_STAGING_DIR="$STAGING_DIR/rootfs"
OPENBOX_DESKTOP_DEB_DIR=${OPENBOX_DESKTOP_DEB_DIR:-"$DOWNLOAD_DIR/openbox-desktop-debs"}
OPENBOX_DESKTOP_APT_STATE_DIR=${OPENBOX_DESKTOP_APT_STATE_DIR:-"$BUILD_DIR/openbox-desktop-apt-state"}
msg() {
printf '==> %s\n' "$*"
-8
View File
@@ -8,17 +8,9 @@ require_cmd curl tar
ensure_dirs
download "$KERNEL_URL" "$DOWNLOAD_DIR/$KERNEL_TARBALL"
download "$BUSYBOX_URL" "$DOWNLOAD_DIR/$BUSYBOX_TARBALL"
download "$SYSTEMD_URL" "$DOWNLOAD_DIR/$SYSTEMD_TARBALL"
download "$DBUS_URL" "$DOWNLOAD_DIR/$DBUS_TARBALL"
download "$PAM_URL" "$DOWNLOAD_DIR/$PAM_TARBALL"
download "$NIX_URL" "$DOWNLOAD_DIR/$NIX_TARBALL"
extract_tarball "$DOWNLOAD_DIR/$KERNEL_TARBALL" "$KERNEL_SRC_DIR"
extract_tarball "$DOWNLOAD_DIR/$BUSYBOX_TARBALL" "$BUSYBOX_SRC_DIR"
extract_tarball_into "$DOWNLOAD_DIR/$SYSTEMD_TARBALL" "$SYSTEMD_SRC_DIR"
extract_tarball "$DOWNLOAD_DIR/$DBUS_TARBALL" "$DBUS_SRC_DIR"
extract_tarball_into "$DOWNLOAD_DIR/$PAM_TARBALL" "$PAM_SRC_DIR"
extract_tarball_into "$DOWNLOAD_DIR/$NIX_TARBALL" "$NIX_SRC_DIR"
msg "sources are ready"
+13 -19
View File
@@ -10,6 +10,7 @@ CHECK_ONLY=0
packages=(
build-essential
gcc-aarch64-linux-gnu
bc
bison
flex
@@ -31,22 +32,18 @@ packages=(
perl
kmod
openssl
libcrypt-dev
libcap-dev
libmount-dev
libblkid-dev
libexpat1-dev
zlib1g-dev
libzstd-dev
libssl-dev
libelf-dev
qemu-system-x86
mmdebstrap
debootstrap
qemu-user-static
binfmt-support
qemu-system-arm
)
required_commands=(
bash
make
gcc
aarch64-linux-gnu-gcc
curl
git
tar
@@ -64,11 +61,8 @@ required_commands=(
perl
depmod
openssl
ldd
ldconfig
install
dpkg-deb
qemu-system-x86_64
qemu-system-aarch64
)
usage() {
@@ -85,9 +79,9 @@ Options:
--no-update Skip apt-get update before installing.
--help Show this help.
This does not install desktop, GNOME, disk-image, installer, or Secure Boot
extras. It includes the host tools needed to enable optional rootfs layers, but
it does not install those target packages on the host.
This does not install disk-image, installer, or Secure Boot signing extras.
It installs the AArch64 cross compiler, ARM64 bootstrap helpers, and
qemu-system-aarch64 for the default ARM64 console build.
EOF
}
@@ -122,8 +116,8 @@ while [[ $# -gt 0 ]]; do
shift
done
if [[ "$(uname -m)" != "x86_64" ]]; then
printf 'warning: ForgeOS currently expects a native x86_64 build host; this host is %s\n' "$(uname -m)" >&2
if [[ "$(uname -m)" != "x86_64" && "$(uname -m)" != "aarch64" ]]; then
printf 'warning: ForgeOS ARM64 is tested from x86_64 or aarch64 hosts; this host is %s\n' "$(uname -m)" >&2
fi
if ! command -v apt-get >/dev/null 2>&1; then
+7 -7
View File
@@ -15,8 +15,8 @@ image_packages=(
e2fsprogs
mtools
grub-common
grub-efi-amd64-bin
ovmf
grub-efi-arm64-bin
qemu-efi-aarch64
)
required_commands=(
@@ -30,13 +30,13 @@ required_commands=(
dd
awk
truncate
qemu-system-x86_64
qemu-system-aarch64
)
required_paths=(
/usr/lib/grub/x86_64-efi
/usr/share/OVMF/OVMF_CODE_4M.fd
/usr/share/OVMF/OVMF_VARS_4M.fd
/usr/lib/grub/arm64-efi
/usr/share/AAVMF/AAVMF_CODE.fd
/usr/share/AAVMF/AAVMF_VARS.fd
)
usage() {
@@ -55,7 +55,7 @@ Options:
This script first checks the console rootfs/run dependencies through
scripts/install-deps.sh, then installs the extra disk image and UEFI QEMU
dependencies. It does not install desktop, GNOME, host installer, or Secure Boot
dependencies. It does not install GNOME, host installer, or Secure Boot
signing extras.
EOF
}
+1 -2
View File
@@ -4,7 +4,6 @@ set -euo pipefail
source "$(dirname "$0")/common.sh"
IMAGE_PATH="$OUT_DIR/forgeos-${KERNEL_VERSION}.img"
DEVICE=""
AUTO_CONFIRM=0
EXPAND_ROOT=1
@@ -345,4 +344,4 @@ repair_and_rescan_partitions
print_summary
msg "installation complete"
msg "UEFI boots from EFI/BOOT/BOOTX64.EFI on the target disk"
msg "UEFI boots from EFI/BOOT/$EFI_BOOT_NAME on the target disk"
+27 -24
View File
@@ -4,7 +4,7 @@ set -euo pipefail
source "$(dirname "$0")/common.sh"
require_cmd qemu-system-x86_64
require_cmd "$QEMU_SYSTEM"
ensure_dirs
MODE=${1:-direct}
@@ -18,13 +18,13 @@ find_uefi_mode() {
return
fi
if [[ -f "/usr/share/OVMF/OVMF_CODE_4M.fd" && -f "/usr/share/OVMF/OVMF_VARS_4M.fd" ]]; then
printf 'pflash:/usr/share/OVMF/OVMF_CODE_4M.fd:/usr/share/OVMF/OVMF_VARS_4M.fd\n'
if [[ -f "/usr/share/AAVMF/AAVMF_CODE.fd" && -f "/usr/share/AAVMF/AAVMF_VARS.fd" ]]; then
printf 'pflash:/usr/share/AAVMF/AAVMF_CODE.fd:/usr/share/AAVMF/AAVMF_VARS.fd\n'
return
fi
if [[ -f "/home/joe/QEMU_EFI.fd" ]]; then
printf 'bios:/home/joe/QEMU_EFI.fd\n'
if [[ -f "/usr/share/qemu-efi-aarch64/QEMU_EFI.fd" ]]; then
printf 'bios:/usr/share/qemu-efi-aarch64/QEMU_EFI.fd\n'
return
fi
@@ -33,31 +33,32 @@ find_uefi_mode() {
case "$MODE" in
direct)
[[ -f "$OUT_DIR/bzImage" ]] || die "missing $OUT_DIR/bzImage"
[[ -f "$KERNEL_IMAGE" ]] || die "missing $KERNEL_IMAGE"
[[ -f "$OUT_DIR/rootfs.cpio.gz" ]] || die "missing $OUT_DIR/rootfs.cpio.gz"
exec qemu-system-x86_64 \
exec "$QEMU_SYSTEM" \
-machine "$QEMU_MACHINE" \
-m "$MEMORY_MB" \
-smp "$SMP_CPUS" \
-cpu max \
-cpu "$QEMU_CPU" \
-display none \
-serial mon:stdio \
-kernel "$OUT_DIR/bzImage" \
-kernel "$KERNEL_IMAGE" \
-initrd "$OUT_DIR/rootfs.cpio.gz" \
-append "console=ttyS0 rdinit=/sbin/init loglevel=4" \
-append "console=$SERIAL_CONSOLE rdinit=/sbin/init loglevel=4" \
-device virtio-rng-pci
;;
image)
UEFI_MODE=$(find_uefi_mode) || die "no usable UEFI firmware found"
IMAGE_PATH="$OUT_DIR/forgeos-${KERNEL_VERSION}.img"
[[ -f "$IMAGE_PATH" ]] || die "missing $IMAGE_PATH"
case "$UEFI_MODE" in
bios:*)
FIRMWARE=${UEFI_MODE#bios:}
exec qemu-system-x86_64 \
exec "$QEMU_SYSTEM" \
-machine "$QEMU_MACHINE" \
-m "$MEMORY_MB" \
-smp "$SMP_CPUS" \
-cpu max \
-cpu "$QEMU_CPU" \
-serial mon:stdio \
-display none \
-boot order=c \
@@ -71,12 +72,13 @@ case "$MODE" in
CODE_FD=${UEFI_MODE#pflash:}
CODE_FD=${CODE_FD%%:*}
VARS_FD=${UEFI_MODE##*:}
VARS_COPY=$(mktemp /tmp/forgeos-ovmf-vars.XXXXXX.fd)
VARS_COPY=$(mktemp /tmp/forgeos-aavmf-vars.XXXXXX.fd)
cp "$VARS_FD" "$VARS_COPY"
qemu-system-x86_64 \
"$QEMU_SYSTEM" \
-machine "$QEMU_MACHINE" \
-m "$MEMORY_MB" \
-smp "$SMP_CPUS" \
-cpu max \
-cpu "$QEMU_CPU" \
-serial mon:stdio \
-display none \
-boot order=c \
@@ -95,22 +97,22 @@ case "$MODE" in
;;
image-gui)
UEFI_MODE=$(find_uefi_mode) || die "no usable UEFI firmware found"
IMAGE_PATH="$OUT_DIR/forgeos-${KERNEL_VERSION}.img"
[[ -f "$IMAGE_PATH" ]] || "$ROOT_DIR/scripts/build-image.sh"
case "$UEFI_MODE" in
bios:*)
FIRMWARE=${UEFI_MODE#bios:}
exec qemu-system-x86_64 \
exec "$QEMU_SYSTEM" \
-machine "$QEMU_MACHINE" \
-m "$MEMORY_MB" \
-smp "$SMP_CPUS" \
-cpu max \
-cpu "$QEMU_CPU" \
-serial mon:stdio \
-display "$QEMU_DISPLAY" \
-boot order=c \
-bios "$FIRMWARE" \
-drive file="$IMAGE_PATH",format=raw,if=virtio \
-device virtio-vga \
-device virtio-gpu-pci \
-device qemu-xhci \
-device usb-tablet \
-device usb-kbd \
@@ -122,19 +124,20 @@ case "$MODE" in
CODE_FD=${UEFI_MODE#pflash:}
CODE_FD=${CODE_FD%%:*}
VARS_FD=${UEFI_MODE##*:}
VARS_COPY=$(mktemp /tmp/forgeos-ovmf-vars.XXXXXX.fd)
VARS_COPY=$(mktemp /tmp/forgeos-aavmf-vars.XXXXXX.fd)
cp "$VARS_FD" "$VARS_COPY"
qemu-system-x86_64 \
"$QEMU_SYSTEM" \
-machine "$QEMU_MACHINE" \
-m "$MEMORY_MB" \
-smp "$SMP_CPUS" \
-cpu max \
-cpu "$QEMU_CPU" \
-serial mon:stdio \
-display "$QEMU_DISPLAY" \
-boot order=c \
-drive if=pflash,format=raw,readonly=on,file="$CODE_FD" \
-drive if=pflash,format=raw,file="$VARS_COPY" \
-drive file="$IMAGE_PATH",format=raw,if=virtio \
-device virtio-vga \
-device virtio-gpu-pci \
-device qemu-xhci \
-device usb-tablet \
-device usb-kbd \
+3 -3
View File
@@ -7,7 +7,7 @@ source "$(dirname "$0")/common.sh"
usage() {
cat <<'EOF'
Usage:
sign-efi-loader.sh [input-bzImage] [output-efi]
sign-efi-loader.sh [input-Image] [output-efi]
Environment:
SECURE_BOOT=1 Sign the loader instead of copying it unsigned.
@@ -24,8 +24,8 @@ if [[ "${1:-}" == "--help" || "${1:-}" == "-h" ]]; then
exit 0
fi
INPUT=${1:-"$OUT_DIR/bzImage"}
OUTPUT=${2:-"$OUT_DIR/BOOTX64.EFI"}
INPUT=${1:-"$KERNEL_IMAGE"}
OUTPUT=${2:-"$EFI_LOADER"}
[[ -f "$INPUT" ]] || die "missing EFI stub kernel: $INPUT"
mkdir -p "$(dirname "$OUTPUT")"
+2 -2
View File
@@ -7,8 +7,8 @@ source "$(dirname "$0")/common.sh"
require_cmd chmod find head install ln mkdir rsync sort tar
ensure_dirs
[[ "$ARCH" == "x86_64" ]] || die "Nix rootfs staging currently supports ARCH=x86_64 only"
[[ "$NIX_SYSTEM" == "x86_64-linux" ]] || die "Nix rootfs staging currently supports NIX_SYSTEM=x86_64-linux only"
[[ "$ARCH" == "arm64" ]] || die "Nix rootfs staging currently supports ARCH=arm64 only"
[[ "$NIX_SYSTEM" == "aarch64-linux" ]] || die "Nix rootfs staging currently supports NIX_SYSTEM=aarch64-linux only"
[[ -d "$ROOTFS_STAGING_DIR" ]] || die "missing rootfs staging tree: $ROOTFS_STAGING_DIR"
if [[ ! -d "$NIX_SRC_DIR/store" || ! -f "$NIX_SRC_DIR/.reginfo" ]]; then
-239
View File
@@ -1,239 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
source "$(dirname "$0")/common.sh"
require_cmd apt-get cat chmod dpkg-deb mkdir rm
ensure_dirs
[[ "$DESKTOP" == "console" ]] || die "Openbox desktop layer is only supported on the normal ForgeOS rootfs"
[[ -d "$ROOTFS_STAGING_DIR" ]] || die "missing rootfs staging tree: $ROOTFS_STAGING_DIR"
desktop_package_array() {
local package
for package in $OPENBOX_DESKTOP_PACKAGES; do
printf '%s\n' "$package"
done
}
is_skipped_package() {
local package=$1
case " $OPENBOX_DESKTOP_SKIP_PACKAGES " in
*" $package "*) return 0 ;;
*) return 1 ;;
esac
}
download_desktop_packages() {
local -a packages=()
local package
local status_file="$OPENBOX_DESKTOP_APT_STATE_DIR/status"
local extended_states_file="$OPENBOX_DESKTOP_APT_STATE_DIR/extended_states"
while IFS= read -r package; do
[[ -n "$package" ]] && packages+=("$package")
done < <(desktop_package_array)
[[ "${#packages[@]}" -gt 0 ]] || die "OPENBOX_DESKTOP_PACKAGES is empty"
mkdir -p \
"$OPENBOX_DESKTOP_DEB_DIR/partial" \
"$OPENBOX_DESKTOP_APT_STATE_DIR"
: > "$status_file"
: > "$extended_states_file"
msg "downloading Openbox desktop package closure"
apt-get \
-o "Dir::State::status=$status_file" \
-o "Dir::State::extended_states=$extended_states_file" \
-o "Dir::Cache::archives=$OPENBOX_DESKTOP_DEB_DIR" \
-o Debug::NoLocking=1 \
--yes \
--download-only \
--no-install-recommends \
install "${packages[@]}"
}
extract_desktop_packages() {
local deb
local package
local extracted_count=0
local skipped_count=0
shopt -s nullglob
for deb in "$OPENBOX_DESKTOP_DEB_DIR"/*.deb; do
package=$(dpkg-deb -f "$deb" Package)
if is_skipped_package "$package"; then
skipped_count=$((skipped_count + 1))
continue
fi
dpkg-deb -x "$deb" "$ROOTFS_STAGING_DIR"
extracted_count=$((extracted_count + 1))
done
shopt -u nullglob
[[ "$extracted_count" -gt 0 ]] || die "no desktop packages were extracted from $OPENBOX_DESKTOP_DEB_DIR"
msg "extracted $extracted_count desktop packages; skipped $skipped_count base packages"
}
write_desktop_config() {
mkdir -p \
"$ROOTFS_STAGING_DIR/etc/X11/xorg.conf.d" \
"$ROOTFS_STAGING_DIR/etc/systemd/system/multi-user.target.wants" \
"$ROOTFS_STAGING_DIR/root/.config/openbox" \
"$ROOTFS_STAGING_DIR/root/.config/pcmanfm/default" \
"$ROOTFS_STAGING_DIR/root/.config/tint2" \
"$ROOTFS_STAGING_DIR/usr/local/bin" \
"$ROOTFS_STAGING_DIR/var/lib/dbus"
cat > "$ROOTFS_STAGING_DIR/etc/X11/Xwrapper.config" <<'EOF'
allowed_users=anybody
needs_root_rights=yes
EOF
cat > "$ROOTFS_STAGING_DIR/etc/X11/xorg.conf.d/10-forgeos-input.conf" <<'EOF'
Section "InputClass"
Identifier "ForgeOS libinput pointers"
MatchIsPointer "on"
Driver "libinput"
EndSection
Section "InputClass"
Identifier "ForgeOS libinput keyboards"
MatchIsKeyboard "on"
Driver "libinput"
EndSection
EOF
cat > "$ROOTFS_STAGING_DIR/root/.config/openbox/autostart" <<'EOF'
pcmanfm --desktop --profile default &
tint2 &
lxterminal &
EOF
cat > "$ROOTFS_STAGING_DIR/root/.config/pcmanfm/default/desktop-items-0.conf" <<'EOF'
[*]
wallpaper_mode=color
desktop_bg=#1f2933
desktop_fg=#f3f4f6
desktop_shadow=#000000
show_wm_menu=1
sort=mtime;ascending;
show_documents=0
show_trash=0
show_mounts=0
EOF
cat > "$ROOTFS_STAGING_DIR/root/.config/tint2/tint2rc" <<'EOF'
rounded = 0
border_width = 0
background_color = #111827 95
panel_monitor = all
panel_position = bottom center horizontal
panel_size = 100% 32
panel_margin = 0 0
panel_padding = 4 2 4
panel_items = TSC
task_text = 1
task_icon = 1
task_centered = 1
task_padding = 4 2
task_background_id = 0
clock = 1
time1_format = %H:%M
time1_font = DejaVu Sans 10
clock_font_color = #f9fafb 100
systray = 1
systray_padding = 4 0 4
EOF
cat > "$ROOTFS_STAGING_DIR/usr/local/bin/forgeos-openbox-session" <<'EOF'
#!/bin/sh
set -eu
export HOME=/root
export USER=root
export LOGNAME=root
export XDG_RUNTIME_DIR=/run/user/0
export XDG_CONFIG_HOME=/root/.config
export XDG_CACHE_HOME=/root/.cache
mkdir -p "$XDG_RUNTIME_DIR" "$XDG_CACHE_HOME"
chmod 0700 "$XDG_RUNTIME_DIR"
if command -v dbus-uuidgen >/dev/null 2>&1 && [ ! -s /var/lib/dbus/machine-id ]; then
dbus-uuidgen --ensure=/var/lib/dbus/machine-id || true
fi
if command -v openbox-session >/dev/null 2>&1; then
exec openbox-session
fi
pcmanfm --desktop --profile default &
tint2 &
lxterminal &
exec openbox
EOF
chmod 0755 "$ROOTFS_STAGING_DIR/usr/local/bin/forgeos-openbox-session"
cat > "$ROOTFS_STAGING_DIR/etc/systemd/system/forgeos-desktop.service" <<'EOF'
[Unit]
Description=ForgeOS Openbox desktop
Wants=dbus.service systemd-logind.service systemd-udevd.service
After=dbus.service systemd-logind.service systemd-udevd.service systemd-user-sessions.service
Conflicts=forgeos-login@tty1.service forgeos-shell@tty1.service getty@tty1.service
[Service]
Type=simple
Environment=HOME=/root
Environment=USER=root
Environment=LOGNAME=root
Environment=XDG_RUNTIME_DIR=/run/user/0
ExecStartPre=/bin/mkdir -p /run/user/0
ExecStartPre=/bin/chmod 0700 /run/user/0
ExecStart=/usr/bin/xinit /usr/local/bin/forgeos-openbox-session -- /usr/lib/xorg/Xorg :0 vt1 -keeptty -nolisten tcp
Restart=on-failure
RestartSec=2
StandardInput=tty
StandardOutput=journal
StandardError=journal
TTYPath=/dev/tty1
TTYReset=yes
TTYVHangup=yes
TTYVTDisallocate=yes
[Install]
WantedBy=multi-user.target
EOF
ln -sfn /etc/systemd/system/forgeos-desktop.service \
"$ROOTFS_STAGING_DIR/etc/systemd/system/multi-user.target.wants/forgeos-desktop.service"
rm -f "$ROOTFS_STAGING_DIR/etc/systemd/system/getty.target.wants/forgeos-login@tty1.service"
rm -f "$ROOTFS_STAGING_DIR/etc/systemd/system/getty.target.wants/forgeos-shell@tty1.service"
if [[ -e "$ROOTFS_STAGING_DIR/usr/lib/systemd/system/dbus.socket" ]]; then
mkdir -p "$ROOTFS_STAGING_DIR/etc/systemd/system/sockets.target.wants"
ln -sfn /usr/lib/systemd/system/dbus.socket \
"$ROOTFS_STAGING_DIR/etc/systemd/system/sockets.target.wants/dbus.socket"
fi
if [[ -e "$ROOTFS_STAGING_DIR/usr/lib/systemd/system/dbus.service" ]]; then
ln -sfn /usr/lib/systemd/system/dbus.service \
"$ROOTFS_STAGING_DIR/etc/systemd/system/multi-user.target.wants/dbus.service"
fi
cat > "$ROOTFS_STAGING_DIR/etc/forgeos-desktop" <<'EOF'
NAME=Openbox
COMPONENTS=openbox,tint2,pcmanfm,xorg,lxterminal
EOF
}
download_desktop_packages
extract_desktop_packages
write_desktop_config
msg "Openbox desktop layer staged into $ROOTFS_STAGING_DIR"