mirror of
https://github.com/blazblue547-afk/ForgeOS-ARM64.git
synced 2026-12-02 14:44:17 -05:00
feat: add systemd Nix rootfs
This commit is contained in:
1 parent
9e86817361
commit
1c3099dbac
38 files changed
+718
-1173
No files matched your search
@@ -2,37 +2,34 @@ SHELL := /usr/bin/env bash
|
||||
|
||||
export ARCH ?= arm64
|
||||
export KERNEL_VERSION ?= 7.1
|
||||
export BUSYBOX_VERSION ?= 1.36.1
|
||||
export SYSTEMD_VERSION ?= 256
|
||||
export NIX_VERSION ?= 2.34.0
|
||||
export NIX_SYSTEM ?= aarch64-linux
|
||||
export DESKTOP ?= console
|
||||
export ROOT_LABEL ?= FORGE_ROOT
|
||||
export EFI_LABEL ?= FORGE_EFI
|
||||
export IMAGE_SIZE_MIB ?= $(if $(filter gnome,$(DESKTOP)),12288,4096)
|
||||
export IMAGE_SIZE_MIB ?= 4096
|
||||
export ESP_SIZE_MIB ?= 256
|
||||
export JOBS ?= $(shell getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)
|
||||
export SECURE_BOOT ?= 0
|
||||
export SECURE_BOOT_KEY ?=
|
||||
export SECURE_BOOT_CERT ?=
|
||||
export GNOME_SUITE ?= trixie
|
||||
export GNOME_MIRROR ?= http://deb.debian.org/debian
|
||||
|
||||
.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
|
||||
.PHONY: help deps image-deps fetch kernel rootfs image secure-boot-keys run run-image list-disks install clean distclean
|
||||
|
||||
help:
|
||||
@printf '%s\n' \
|
||||
'ForgeOS ARM64 targets:' \
|
||||
' make deps - install Debian/Ubuntu host deps for ARM64 builds' \
|
||||
' make deps - install host deps for ARM64 systemd/Nix builds' \
|
||||
' make image-deps - install ARM64 image + QEMU deps' \
|
||||
' make fetch - download Linux and ARM64 Nix payloads' \
|
||||
' make fetch - download Linux, BusyBox, systemd, and 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 rootfs - build systemd rootfs, stage Nix, and make initramfs' \
|
||||
' 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-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 ARM64 to a real disk' \
|
||||
' make clean - remove build, staging, and output artifacts' \
|
||||
@@ -53,19 +50,9 @@ kernel: fetch
|
||||
rootfs:
|
||||
@./scripts/build-rootfs.sh
|
||||
|
||||
gnome-rootfs: DESKTOP = gnome
|
||||
gnome-rootfs: IMAGE_SIZE_MIB = 12288
|
||||
gnome-rootfs:
|
||||
@./scripts/build-gnome-rootfs.sh
|
||||
|
||||
image:
|
||||
@./scripts/build-image.sh
|
||||
|
||||
gnome-image: DESKTOP = gnome
|
||||
gnome-image: IMAGE_SIZE_MIB = 12288
|
||||
gnome-image:
|
||||
@./scripts/build-image.sh
|
||||
|
||||
secure-boot-keys:
|
||||
@./scripts/generate-secure-boot-keys.sh
|
||||
|
||||
@@ -75,12 +62,6 @@ run:
|
||||
run-image:
|
||||
@./scripts/run-qemu.sh image
|
||||
|
||||
run-gnome: DESKTOP = gnome
|
||||
run-gnome: IMAGE_SIZE_MIB = 12288
|
||||
run-gnome: MEMORY_MB = 4096
|
||||
run-gnome: gnome-image
|
||||
@./scripts/run-qemu.sh image-gui
|
||||
|
||||
list-disks:
|
||||
@./scripts/install-to-disk.sh --list
|
||||
|
||||
|
||||
@@ -1,29 +1,34 @@
|
||||
# ForgeOS ARM64
|
||||
|
||||
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.
|
||||
ForgeOS ARM64 is a 64-bit ARM/AArch64 OS image assembled by this repository.
|
||||
The target now boots systemd as PID 1 and uses Nix as the core package manager.
|
||||
BusyBox is retained as a static early-boot and rescue utility layer, not as the
|
||||
init system.
|
||||
|
||||
As of `2026-06-17`, this flavor defaults to:
|
||||
|
||||
- Linux kernel `7.1`
|
||||
- systemd `256`
|
||||
- Nix `2.34.0` using the official `aarch64-linux` binary tarball
|
||||
- BusyBox `1.36.1` as static rescue utilities
|
||||
- ARM64 / AArch64 only
|
||||
- 64-bit only
|
||||
- UEFI boot through `EFI/BOOT/BOOTAA64.EFI`
|
||||
- Debian `arm64` console rootfs using `trixie`
|
||||
- Nix `2.34.0` using the official `aarch64-linux` binary tarball
|
||||
- GPT disk image with an EFI system partition and ext4 root partition
|
||||
- serial console on `ttyAMA0`
|
||||
- optional Debian GNOME desktop rootfs
|
||||
|
||||
## What This Repository Produces
|
||||
|
||||
- a ForgeOS ARM64 build pipeline
|
||||
- a systemd-managed root filesystem with:
|
||||
- login prompts on `tty1` and `ttyAMA0`
|
||||
- systemd-networkd DHCP networking
|
||||
- systemd-resolved and systemd-timesyncd
|
||||
- nix-daemon and a boot-time Nix store registration service
|
||||
- a bootable GPT disk image with:
|
||||
- an EFI system partition
|
||||
- an ext4 root partition
|
||||
- a direct QEMU smoke-test path using `qemu-system-aarch64`
|
||||
- an optional GNOME ARM64 image flavor
|
||||
|
||||
## Quick Start
|
||||
|
||||
@@ -35,9 +40,7 @@ make run
|
||||
```
|
||||
|
||||
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.
|
||||
`forge`.
|
||||
|
||||
To build a bootable ARM64 UEFI disk image:
|
||||
|
||||
@@ -50,38 +53,44 @@ make run-image
|
||||
|
||||
The disk image is written to `out/forgeos-arm64-7.1.img`.
|
||||
|
||||
To build the optional ARM64 GNOME image:
|
||||
|
||||
```bash
|
||||
cd ForgeOS-ARM64
|
||||
make gnome-image
|
||||
make run-gnome
|
||||
```
|
||||
|
||||
## Build Notes
|
||||
|
||||
- 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.
|
||||
initramfs, framebuffer console, and common QEMU `virt` devices.
|
||||
- On non-AArch64 hosts, the build defaults to
|
||||
`CROSS_COMPILE=aarch64-linux-gnu-`.
|
||||
- systemd is built with Meson/Ninja and installed into the target rootfs through
|
||||
`DESTDIR`.
|
||||
- Nix is staged from the official ARM64 binary tarball, then registered at first
|
||||
boot by `forgeos-nix-bootstrap.service`.
|
||||
- BusyBox is still built statically to provide `/bin/sh`, `switch_root`,
|
||||
`getty`, diagnostics helpers, and rescue tools needed before Nix is available.
|
||||
- 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.
|
||||
|
||||
## Systemd Build Requirements
|
||||
|
||||
The rootfs script can build systemd from upstream source, but systemd is not a
|
||||
single static binary. The build needs ARM64 development libraries visible through
|
||||
pkg-config and runtime libraries available for staging. Override these when
|
||||
using a custom sysroot:
|
||||
|
||||
```bash
|
||||
SYSTEMD_PKG_CONFIG_LIBDIR=/path/to/sysroot/usr/lib/pkgconfig \
|
||||
SYSTEMD_RUNTIME_LIB_DIRS=/path/to/sysroot/lib:/path/to/sysroot/usr/lib \
|
||||
make rootfs
|
||||
```
|
||||
|
||||
## Current Limits
|
||||
|
||||
- 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.
|
||||
- No desktop environment or graphical login is built by this repository.
|
||||
- Hardware support beyond the QEMU `virt` platform depends on kernel config work
|
||||
for the target board or machine.
|
||||
- Secure Boot still requires enrolling your generated local signing certificate.
|
||||
|
||||
More detail is in [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md).
|
||||
Installer usage is documented in [docs/INSTALLER.md](docs/INSTALLER.md).
|
||||
@@ -0,0 +1,40 @@
|
||||
CONFIG_STATIC=y
|
||||
CONFIG_INSTALL_APPLET_SYMLINKS=y
|
||||
CONFIG_INIT=y
|
||||
CONFIG_FEATURE_USE_INITTAB=y
|
||||
CONFIG_ASH=y
|
||||
CONFIG_SH_IS_ASH=y
|
||||
CONFIG_CTTYHACK=y
|
||||
CONFIG_GETTY=y
|
||||
CONFIG_LOGIN=y
|
||||
CONFIG_PASSWD=y
|
||||
CONFIG_SU=y
|
||||
CONFIG_FEATURE_SHADOWPASSWDS=y
|
||||
CONFIG_USE_BB_PWD_GRP=y
|
||||
CONFIG_USE_BB_SHADOW=y
|
||||
CONFIG_MDEV=y
|
||||
CONFIG_FEATURE_MDEV_CONF=y
|
||||
CONFIG_FEATURE_MDEV_EXEC=y
|
||||
CONFIG_FEATURE_MDEV_LOAD_FIRMWARE=y
|
||||
CONFIG_SWITCH_ROOT=y
|
||||
CONFIG_MODPROBE=y
|
||||
CONFIG_LSMOD=y
|
||||
CONFIG_INSMOD=y
|
||||
CONFIG_RMMOD=y
|
||||
CONFIG_DEPMOD=y
|
||||
CONFIG_BLKID=y
|
||||
CONFIG_FEATURE_BLKID_TYPE=y
|
||||
CONFIG_MOUNT=y
|
||||
CONFIG_UMOUNT=y
|
||||
CONFIG_FEATURE_MOUNT_LABEL=y
|
||||
CONFIG_FEATURE_MOUNT_FLAGS=y
|
||||
CONFIG_FEATURE_MOUNT_FSTAB=y
|
||||
CONFIG_DMESG=y
|
||||
CONFIG_KILLALL5=y
|
||||
CONFIG_IFCONFIG=y
|
||||
CONFIG_ROUTE=y
|
||||
CONFIG_IP=y
|
||||
CONFIG_UDHCPC=y
|
||||
CONFIG_FEATURE_UDHCPC_ARPING=y
|
||||
CONFIG_FEATURE_UDHCP_PORT=y
|
||||
CONFIG_FEATURE_UDHCP_RFC3397=y
|
||||
+43
-28
@@ -2,15 +2,17 @@
|
||||
|
||||
## Goal
|
||||
|
||||
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.
|
||||
ForgeOS ARM64 targets 64-bit ARM systems with UEFI firmware. The target image
|
||||
boots systemd as PID 1 and uses Nix as the core package manager.
|
||||
|
||||
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.
|
||||
The current stack is:
|
||||
|
||||
- Linux kernel source from kernel.org
|
||||
- systemd source from the upstream systemd project
|
||||
- BusyBox source from busybox.net for static rescue and early-boot tools
|
||||
- official Nix `aarch64-linux` binary tarball for the Nix store bootstrap
|
||||
- ForgeOS shell scripts, identity files, unit files, boot configuration, and
|
||||
image layout from this repository
|
||||
|
||||
## Boot Model
|
||||
|
||||
@@ -22,22 +24,33 @@ work.
|
||||
`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`.
|
||||
7. The kernel mounts the ext4 root partition and executes `/sbin/init`.
|
||||
8. `/sbin/init` points to `/usr/lib/systemd/systemd`.
|
||||
9. systemd reaches `multi-user.target`, starts console login units, networkd,
|
||||
resolved, timesyncd, the Nix bootstrap service, and nix-daemon.
|
||||
|
||||
The image also includes `rootfs.cpio.gz` on the EFI partition. The GRUB
|
||||
initramfs entries can use `/init` and `/sbin/forgeos-switch-root` to locate and
|
||||
switch to the real ext4 root partition before executing systemd.
|
||||
|
||||
## Root Filesystem Model
|
||||
|
||||
The default rootfs is assembled in `staging/rootfs` from:
|
||||
|
||||
- Debian `trixie` ARM64 packages
|
||||
- ForgeOS identity, user, network, and systemd defaults
|
||||
- a systemd `DESTDIR` install tree
|
||||
- a statically linked ARM64 BusyBox utility tree
|
||||
- generated `/etc/passwd`, `/etc/shadow`, `/etc/group`, `/etc/fstab`,
|
||||
`/etc/systemd/*`, network, hostname, profile, and OS identity files
|
||||
- ForgeOS helper scripts from `overlay/rootfs`
|
||||
- the official Nix ARM64 store closure plus registration metadata
|
||||
- kernel modules from the ARM64 kernel build
|
||||
- the official Nix `aarch64-linux` binary tarball staged into `/nix/store`
|
||||
- the ARM64 kernel image copied to `/boot`
|
||||
|
||||
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.
|
||||
systemd units are enabled by creating `.wants` symlinks in
|
||||
`/etc/systemd/system`, matching systemd's normal enablement model. Nix follows a
|
||||
multi-user daemon layout: `nixbld` users are generated in `/etc/passwd`,
|
||||
`/etc/nix/nix.conf` declares `build-users-group = nixbld`, and
|
||||
`nix-daemon.socket`/`nix-daemon.service` are enabled under systemd.
|
||||
|
||||
## QEMU Model
|
||||
|
||||
@@ -47,21 +60,23 @@ The run scripts use `qemu-system-aarch64` with:
|
||||
- `-cpu max`
|
||||
- PL011 serial console through `ttyAMA0`
|
||||
- AAVMF firmware for UEFI image boots
|
||||
- virtio block, network, rng, and GPU devices where appropriate
|
||||
- virtio block, network, and rng devices
|
||||
|
||||
## Known Gaps
|
||||
|
||||
- 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.
|
||||
- The Nix payload is currently the official binary tarball rather than a
|
||||
source-built Nix closure.
|
||||
- The systemd build depends on an ARM64 sysroot for target development and
|
||||
runtime libraries.
|
||||
- No desktop environment or graphical login.
|
||||
- No board-specific kernel profiles beyond QEMU `virt`.
|
||||
- No Microsoft/shim-signed Secure Boot chain.
|
||||
- No in-OS guided installer or update system.
|
||||
|
||||
## Suggested Next Steps
|
||||
|
||||
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
|
||||
1. Add a first-class ARM64 sysroot recipe for systemd dependencies.
|
||||
2. Add a source-built Nix recipe or a reproducible closure generator.
|
||||
3. Add hardware profiles for common ARM64 laptops, SBCs, and servers.
|
||||
4. 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.
|
||||
@@ -1,15 +0,0 @@
|
||||
root:x:0:
|
||||
tty:x:5:
|
||||
disk:x:6:
|
||||
audio:x:29:forge
|
||||
utmp:x:43:
|
||||
video:x:44:forge
|
||||
messagebus:x:81:
|
||||
users:x:100:forge
|
||||
input:x:104:forge
|
||||
systemd-journal:x:190:
|
||||
systemd-network:x:192:
|
||||
systemd-resolve:x:193:
|
||||
nixbld:x:30000:nixbld1,nixbld2,nixbld3,nixbld4,nixbld5,nixbld6,nixbld7,nixbld8,nixbld9,nixbld10,nixbld11,nixbld12,nixbld13,nixbld14,nixbld15,nixbld16,nixbld17,nixbld18,nixbld19,nixbld20,nixbld21,nixbld22,nixbld23,nixbld24,nixbld25,nixbld26,nixbld27,nixbld28,nixbld29,nixbld30,nixbld31,nixbld32
|
||||
forge:x:1000:
|
||||
nobody:x:65534:
|
||||
@@ -1,15 +0,0 @@
|
||||
root:*::
|
||||
tty:*::
|
||||
disk:*::
|
||||
audio:*::forge
|
||||
utmp:*::
|
||||
video:*::forge
|
||||
messagebus:*::
|
||||
users:*::forge
|
||||
input:*::forge
|
||||
systemd-journal:*::
|
||||
systemd-network:*::
|
||||
systemd-resolve:*::
|
||||
nixbld:*::nixbld1,nixbld2,nixbld3,nixbld4,nixbld5,nixbld6,nixbld7,nixbld8,nixbld9,nixbld10,nixbld11,nixbld12,nixbld13,nixbld14,nixbld15,nixbld16,nixbld17,nixbld18,nixbld19,nixbld20,nixbld21,nixbld22,nixbld23,nixbld24,nixbld25,nixbld26,nixbld27,nixbld28,nixbld29,nixbld30,nixbld31,nixbld32
|
||||
forge:!::
|
||||
nobody:*::
|
||||
@@ -1 +0,0 @@
|
||||
forgeos
|
||||
@@ -1 +0,0 @@
|
||||
ForgeOS \r (\m)
|
||||
@@ -1,3 +0,0 @@
|
||||
# ForgeOS ships a small BusyBox-compatible neofetch implementation.
|
||||
# Keep this distro name available for tools that read neofetch-style config.
|
||||
ascii_distro="forgeos"
|
||||
@@ -1,11 +0,0 @@
|
||||
passwd: files
|
||||
group: files
|
||||
shadow: files
|
||||
|
||||
hosts: files dns
|
||||
networks: files
|
||||
|
||||
protocols: files
|
||||
services: files
|
||||
ethers: files
|
||||
rpc: files
|
||||
@@ -1,3 +0,0 @@
|
||||
NAME=ForgeOS
|
||||
ID=forgeos
|
||||
PRETTY_NAME="ForgeOS"
|
||||
@@ -1,7 +0,0 @@
|
||||
#%PAM-1.0
|
||||
|
||||
auth required pam_unix.so nullok
|
||||
account required pam_unix.so
|
||||
password required pam_unix.so sha512 shadow
|
||||
session required pam_unix.so
|
||||
session optional pam_systemd.so
|
||||
@@ -1,6 +0,0 @@
|
||||
#%PAM-1.0
|
||||
|
||||
auth required pam_deny.so
|
||||
account required pam_deny.so
|
||||
password required pam_deny.so
|
||||
session required pam_deny.so
|
||||
@@ -1,4 +0,0 @@
|
||||
#%PAM-1.0
|
||||
|
||||
account required pam_unix.so no_pass_expiry
|
||||
session optional pam_systemd.so
|
||||
@@ -1,38 +0,0 @@
|
||||
root:x:0:0:root:/root:/bin/sh
|
||||
forge:x:1000:1000:ForgeOS User:/home/forge:/bin/sh
|
||||
systemd-network:x:192:192:systemd Network Management:/:/bin/sh
|
||||
systemd-resolve:x:193:193:systemd Resolver:/:/bin/sh
|
||||
messagebus:x:81:81:System Message Bus:/:/bin/sh
|
||||
nixbld1:x:30001:30000:Nix build user 1:/var/empty:/sbin/nologin
|
||||
nixbld2:x:30002:30000:Nix build user 2:/var/empty:/sbin/nologin
|
||||
nixbld3:x:30003:30000:Nix build user 3:/var/empty:/sbin/nologin
|
||||
nixbld4:x:30004:30000:Nix build user 4:/var/empty:/sbin/nologin
|
||||
nixbld5:x:30005:30000:Nix build user 5:/var/empty:/sbin/nologin
|
||||
nixbld6:x:30006:30000:Nix build user 6:/var/empty:/sbin/nologin
|
||||
nixbld7:x:30007:30000:Nix build user 7:/var/empty:/sbin/nologin
|
||||
nixbld8:x:30008:30000:Nix build user 8:/var/empty:/sbin/nologin
|
||||
nixbld9:x:30009:30000:Nix build user 9:/var/empty:/sbin/nologin
|
||||
nixbld10:x:30010:30000:Nix build user 10:/var/empty:/sbin/nologin
|
||||
nixbld11:x:30011:30000:Nix build user 11:/var/empty:/sbin/nologin
|
||||
nixbld12:x:30012:30000:Nix build user 12:/var/empty:/sbin/nologin
|
||||
nixbld13:x:30013:30000:Nix build user 13:/var/empty:/sbin/nologin
|
||||
nixbld14:x:30014:30000:Nix build user 14:/var/empty:/sbin/nologin
|
||||
nixbld15:x:30015:30000:Nix build user 15:/var/empty:/sbin/nologin
|
||||
nixbld16:x:30016:30000:Nix build user 16:/var/empty:/sbin/nologin
|
||||
nixbld17:x:30017:30000:Nix build user 17:/var/empty:/sbin/nologin
|
||||
nixbld18:x:30018:30000:Nix build user 18:/var/empty:/sbin/nologin
|
||||
nixbld19:x:30019:30000:Nix build user 19:/var/empty:/sbin/nologin
|
||||
nixbld20:x:30020:30000:Nix build user 20:/var/empty:/sbin/nologin
|
||||
nixbld21:x:30021:30000:Nix build user 21:/var/empty:/sbin/nologin
|
||||
nixbld22:x:30022:30000:Nix build user 22:/var/empty:/sbin/nologin
|
||||
nixbld23:x:30023:30000:Nix build user 23:/var/empty:/sbin/nologin
|
||||
nixbld24:x:30024:30000:Nix build user 24:/var/empty:/sbin/nologin
|
||||
nixbld25:x:30025:30000:Nix build user 25:/var/empty:/sbin/nologin
|
||||
nixbld26:x:30026:30000:Nix build user 26:/var/empty:/sbin/nologin
|
||||
nixbld27:x:30027:30000:Nix build user 27:/var/empty:/sbin/nologin
|
||||
nixbld28:x:30028:30000:Nix build user 28:/var/empty:/sbin/nologin
|
||||
nixbld29:x:30029:30000:Nix build user 29:/var/empty:/sbin/nologin
|
||||
nixbld30:x:30030:30000:Nix build user 30:/var/empty:/sbin/nologin
|
||||
nixbld31:x:30031:30000:Nix build user 31:/var/empty:/sbin/nologin
|
||||
nixbld32:x:30032:30000:Nix build user 32:/var/empty:/sbin/nologin
|
||||
nobody:x:65534:65534:nobody:/:/bin/sh
|
||||
@@ -1,16 +0,0 @@
|
||||
PATH=/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin
|
||||
export PATH
|
||||
|
||||
PS1='[forgeos \w]# '
|
||||
export PS1
|
||||
|
||||
alias ll='ls -alF'
|
||||
alias la='ls -A'
|
||||
alias l='ls -CF'
|
||||
|
||||
if [ -d /etc/profile.d ]; then
|
||||
for profile_script in /etc/profile.d/*.sh; do
|
||||
[ -r "$profile_script" ] && . "$profile_script"
|
||||
done
|
||||
unset profile_script
|
||||
fi
|
||||
@@ -1,38 +0,0 @@
|
||||
root:$6$forgeos$gPbch8oHqLnms/ljQGrpqE5btu4FY8J9ryX.9/CfzBY6CyakPaoEkHapeKRjkZbg3BdAdZz6eDzPD0YOV3CYK0:20620:0:99999:7:::
|
||||
forge:$6$forgeos$gPbch8oHqLnms/ljQGrpqE5btu4FY8J9ryX.9/CfzBY6CyakPaoEkHapeKRjkZbg3BdAdZz6eDzPD0YOV3CYK0:20620:0:99999:7:::
|
||||
systemd-network:*:20620:0:99999:7:::
|
||||
systemd-resolve:*:20620:0:99999:7:::
|
||||
messagebus:*:20620:0:99999:7:::
|
||||
nixbld1:!:20620:0:99999:7:::
|
||||
nixbld2:!:20620:0:99999:7:::
|
||||
nixbld3:!:20620:0:99999:7:::
|
||||
nixbld4:!:20620:0:99999:7:::
|
||||
nixbld5:!:20620:0:99999:7:::
|
||||
nixbld6:!:20620:0:99999:7:::
|
||||
nixbld7:!:20620:0:99999:7:::
|
||||
nixbld8:!:20620:0:99999:7:::
|
||||
nixbld9:!:20620:0:99999:7:::
|
||||
nixbld10:!:20620:0:99999:7:::
|
||||
nixbld11:!:20620:0:99999:7:::
|
||||
nixbld12:!:20620:0:99999:7:::
|
||||
nixbld13:!:20620:0:99999:7:::
|
||||
nixbld14:!:20620:0:99999:7:::
|
||||
nixbld15:!:20620:0:99999:7:::
|
||||
nixbld16:!:20620:0:99999:7:::
|
||||
nixbld17:!:20620:0:99999:7:::
|
||||
nixbld18:!:20620:0:99999:7:::
|
||||
nixbld19:!:20620:0:99999:7:::
|
||||
nixbld20:!:20620:0:99999:7:::
|
||||
nixbld21:!:20620:0:99999:7:::
|
||||
nixbld22:!:20620:0:99999:7:::
|
||||
nixbld23:!:20620:0:99999:7:::
|
||||
nixbld24:!:20620:0:99999:7:::
|
||||
nixbld25:!:20620:0:99999:7:::
|
||||
nixbld26:!:20620:0:99999:7:::
|
||||
nixbld27:!:20620:0:99999:7:::
|
||||
nixbld28:!:20620:0:99999:7:::
|
||||
nixbld29:!:20620:0:99999:7:::
|
||||
nixbld30:!:20620:0:99999:7:::
|
||||
nixbld31:!:20620:0:99999:7:::
|
||||
nixbld32:!:20620:0:99999:7:::
|
||||
nobody:*:20620:0:99999:7:::
|
||||
@@ -1 +0,0 @@
|
||||
/bin/sh
|
||||
@@ -1,6 +0,0 @@
|
||||
[Match]
|
||||
Name=en* eth*
|
||||
|
||||
[Network]
|
||||
DHCP=yes
|
||||
IPv6AcceptRA=yes
|
||||
@@ -1,20 +0,0 @@
|
||||
disable *
|
||||
enable forgeos-login@tty1.service
|
||||
enable serial-getty@ttyAMA0.service
|
||||
enable forgeos-bootdiag.service
|
||||
enable forgeos-console-banner.service
|
||||
enable dbus.service
|
||||
enable dbus.socket
|
||||
enable systemd-logind.service
|
||||
enable systemd-logind-varlink.socket
|
||||
enable systemd-networkd.service
|
||||
enable systemd-networkd.socket
|
||||
enable systemd-resolved.service
|
||||
enable systemd-resolved-monitor.socket
|
||||
enable systemd-resolved-varlink.socket
|
||||
enable systemd-udevd.service
|
||||
enable systemd-udevd-control.socket
|
||||
enable systemd-udevd-kernel.socket
|
||||
enable forgeos-nix-bootstrap.service
|
||||
enable nix-daemon.service
|
||||
enable nix-daemon.socket
|
||||
@@ -1,12 +0,0 @@
|
||||
[Unit]
|
||||
Description=Record ForgeOS boot diagnostics
|
||||
Documentation=man:systemd.service(5)
|
||||
After=local-fs.target systemd-udevd.service
|
||||
ConditionPathExists=/sbin/forgeos-bootdiag
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/sbin/forgeos-bootdiag systemd
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -1,12 +0,0 @@
|
||||
[Unit]
|
||||
Description=Print ForgeOS console banner
|
||||
Documentation=man:systemd.service(5)
|
||||
After=systemd-logind.service systemd-user-sessions.service
|
||||
ConditionPathExists=/sbin/forgeos-console-banner
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/sbin/forgeos-console-banner
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -1,12 +0,0 @@
|
||||
[Unit]
|
||||
Description=Repair ForgeOS user home ownership
|
||||
Documentation=man:systemd.service(5)
|
||||
After=local-fs.target
|
||||
Before=systemd-user-sessions.service getty.target getty@tty1.service serial-getty@ttyAMA0.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/bin/sh -c 'if [ -d /home/forge ]; then chown -R 1000:1000 /home/forge && chmod 700 /home/forge; fi'
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -1,26 +0,0 @@
|
||||
[Unit]
|
||||
Description=ForgeOS login prompt on %I
|
||||
Documentation=man:systemd.service(5)
|
||||
Wants=systemd-logind.service
|
||||
After=systemd-logind.service systemd-user-sessions.service getty-pre.target
|
||||
Before=getty.target
|
||||
ConditionPathExists=/dev/%I
|
||||
IgnoreOnIsolate=yes
|
||||
|
||||
[Service]
|
||||
ExecStart=-/sbin/getty -L 0 %I linux
|
||||
Type=idle
|
||||
Restart=always
|
||||
RestartSec=0
|
||||
UtmpIdentifier=%I
|
||||
StandardInput=tty
|
||||
StandardOutput=tty
|
||||
TTYPath=/dev/%I
|
||||
TTYReset=yes
|
||||
TTYVHangup=yes
|
||||
TTYVTDisallocate=yes
|
||||
IgnoreSIGPIPE=no
|
||||
SendSIGHUP=yes
|
||||
|
||||
[Install]
|
||||
WantedBy=getty.target
|
||||
@@ -1,24 +0,0 @@
|
||||
[Unit]
|
||||
Description=ForgeOS root shell on %I
|
||||
Documentation=man:systemd.service(5)
|
||||
After=systemd-logind.service systemd-user-sessions.service
|
||||
Before=getty.target
|
||||
IgnoreOnIsolate=yes
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=-/bin/sh -l
|
||||
Restart=always
|
||||
RestartSec=0
|
||||
StandardInput=tty
|
||||
StandardOutput=tty
|
||||
StandardError=tty
|
||||
TTYPath=/dev/%I
|
||||
TTYReset=yes
|
||||
TTYVHangup=yes
|
||||
KillMode=process
|
||||
IgnoreSIGPIPE=no
|
||||
SendSIGHUP=yes
|
||||
|
||||
[Install]
|
||||
WantedBy=getty.target
|
||||
@@ -1,2 +0,0 @@
|
||||
cd /root
|
||||
exec /bin/sh
|
||||
@@ -1,124 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -u
|
||||
|
||||
show_help() {
|
||||
cat <<'EOF'
|
||||
Usage: neofetch [--help] [--version]
|
||||
|
||||
Print ForgeOS system information with the ForgeOS ASCII logo.
|
||||
EOF
|
||||
}
|
||||
|
||||
case "${1:-}" in
|
||||
--help|-h)
|
||||
show_help
|
||||
exit 0
|
||||
;;
|
||||
--version|-V)
|
||||
echo "ForgeOS neofetch 1.0"
|
||||
exit 0
|
||||
;;
|
||||
--*)
|
||||
echo "neofetch: unsupported option: $1" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -t 1 ] && [ -z "${NO_COLOR:-}" ]; then
|
||||
reset="$(printf '\033[0m')"
|
||||
bold="$(printf '\033[1m')"
|
||||
logo_color="$(printf '\033[36m')"
|
||||
key_color="$(printf '\033[1;37m')"
|
||||
else
|
||||
reset=''
|
||||
bold=''
|
||||
logo_color=''
|
||||
key_color=''
|
||||
fi
|
||||
|
||||
os_release="${NEOFETCH_OS_RELEASE:-/etc/os-release}"
|
||||
host_file="${NEOFETCH_HOSTNAME:-/etc/hostname}"
|
||||
desktop_file="${NEOFETCH_DESKTOP_FILE:-/etc/forgeos-desktop}"
|
||||
|
||||
os_name="ForgeOS"
|
||||
if [ -r "$os_release" ]; then
|
||||
os_name="$(sed -n 's/^PRETTY_NAME=//p' "$os_release" | head -n 1 | sed 's/^"//;s/"$//')"
|
||||
[ -n "$os_name" ] || os_name="$(sed -n 's/^NAME=//p' "$os_release" | head -n 1 | sed 's/^"//;s/"$//')"
|
||||
[ -n "$os_name" ] || os_name="ForgeOS"
|
||||
fi
|
||||
|
||||
host="$(cat "$host_file" 2>/dev/null || hostname 2>/dev/null || echo forgeos)"
|
||||
kernel="$(uname -sr 2>/dev/null || echo unknown)"
|
||||
arch="$(uname -m 2>/dev/null || echo unknown)"
|
||||
shell_name="${SHELL:-/bin/sh}"
|
||||
terminal="${TERM:-linux}"
|
||||
init_name="systemd"
|
||||
|
||||
desktop="console"
|
||||
if [ -r "$desktop_file" ]; then
|
||||
desktop="$(sed -n 's/^NAME=//p' "$desktop_file" | head -n 1 | sed 's/^"//;s/"$//')"
|
||||
[ -n "$desktop" ] || desktop="Openbox"
|
||||
fi
|
||||
|
||||
uptime_text="unknown"
|
||||
if [ -r /proc/uptime ]; then
|
||||
uptime_seconds="$(cut -d. -f1 /proc/uptime 2>/dev/null | awk '{print $1}')"
|
||||
case "$uptime_seconds" in
|
||||
''|*[!0-9]*)
|
||||
;;
|
||||
*)
|
||||
days=$((uptime_seconds / 86400))
|
||||
hours=$(((uptime_seconds % 86400) / 3600))
|
||||
mins=$(((uptime_seconds % 3600) / 60))
|
||||
if [ "$days" -gt 0 ]; then
|
||||
uptime_text="${days}d ${hours}h ${mins}m"
|
||||
elif [ "$hours" -gt 0 ]; then
|
||||
uptime_text="${hours}h ${mins}m"
|
||||
else
|
||||
uptime_text="${mins}m"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
cpu="$arch"
|
||||
if [ -r /proc/cpuinfo ]; then
|
||||
cpu="$(sed -n 's/^model name[[:space:]]*:[[:space:]]*//p' /proc/cpuinfo | head -n 1)"
|
||||
[ -n "$cpu" ] || cpu="$arch"
|
||||
fi
|
||||
|
||||
memory="unknown"
|
||||
if [ -r /proc/meminfo ]; then
|
||||
mem_total="$(awk '/^MemTotal:/ {print int($2 / 1024)}' /proc/meminfo)"
|
||||
mem_available="$(awk '/^MemAvailable:/ {print int($2 / 1024)}' /proc/meminfo)"
|
||||
if [ -n "$mem_total" ] && [ -n "$mem_available" ]; then
|
||||
mem_used=$((mem_total - mem_available))
|
||||
memory="${mem_used}MiB / ${mem_total}MiB"
|
||||
fi
|
||||
fi
|
||||
|
||||
line() {
|
||||
logo_line="$1"
|
||||
label="$2"
|
||||
value="$3"
|
||||
|
||||
if [ -n "$label" ]; then
|
||||
printf '%b%-37s%b %b%s%b %s\n' "$logo_color" "$logo_line" "$reset" "$key_color" "$label" "$reset" "$value"
|
||||
else
|
||||
printf '%b%s%b\n' "$logo_color" "$logo_line" "$reset"
|
||||
fi
|
||||
}
|
||||
|
||||
printf '%b%s@%s%b\n' "$bold" "${USER:-root}" "$host" "$reset"
|
||||
line ' ______ ____ _____' 'OS:' "$os_name"
|
||||
line ' / ____/___ _________ ____ / __ \/ ___/' 'Host:' "$host"
|
||||
line ' / /_ / __ \/ ___/ __ `/ _ \/ / / /\__ \' 'Kernel:' "$kernel"
|
||||
line ' / __/ / /_/ / / / /_/ / __/ /_/ /__/ /' 'Uptime:' "$uptime_text"
|
||||
line '/_/ \____/_/ \__, /\___/\____/____/' 'Shell:' "$shell_name"
|
||||
line ' /____/' 'Terminal:' "$terminal"
|
||||
line ' forged from source' 'Desktop:' "$desktop"
|
||||
line '' 'Init:' "$init_name"
|
||||
line '' 'CPU:' "$cpu"
|
||||
line '' 'Memory:' "$memory"
|
||||
line '' 'Packages:' 'overlay + source-built core'
|
||||
@@ -1,5 +0,0 @@
|
||||
d /home/forge 0700 forge forge -
|
||||
z /home/forge 0700 forge forge -
|
||||
z /root 0700 root root -
|
||||
z /etc/shadow 0600 root root -
|
||||
z /etc/gshadow 0600 root root -
|
||||
@@ -1,7 +0,0 @@
|
||||
______ ____ _____
|
||||
/ ____/___ _________ ____ / __ \/ ___/
|
||||
/ /_ / __ \/ ___/ __ `/ _ \/ / / /\__ \
|
||||
/ __/ / /_/ / / / /_/ / __/ /_/ /__/ /
|
||||
/_/ \____/_/ \__, /\___/\____/____/
|
||||
/____/
|
||||
forged from source
|
||||
+516
-279
@@ -4,301 +4,398 @@ set -euo pipefail
|
||||
|
||||
source "$(dirname "$0")/common.sh"
|
||||
|
||||
require_cmd find openssl rsync cpio gzip grep sed date seq
|
||||
require_cmd find install make "$CC" rsync cpio gzip openssl date yes grep sed meson ninja gperf awk seq readlink ln mkdir
|
||||
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}
|
||||
ROOTFS_USER=${ROOTFS_USER:-forge}
|
||||
ROOTFS_USER_UID=${ROOTFS_USER_UID:-1000}
|
||||
ROOTFS_ROOT_PASSWORD=${ROOTFS_ROOT_PASSWORD:-forge}
|
||||
ROOTFS_USER_PASSWORD=${ROOTFS_USER_PASSWORD:-forge}
|
||||
ROOTFS_HOSTNAME=${ROOTFS_HOSTNAME:-forgeos-arm64}
|
||||
NIX_BUILD_USERS=${NIX_BUILD_USERS:-32}
|
||||
|
||||
normalize_packages_csv() {
|
||||
local package_csv
|
||||
SYSTEMD_CROSS_FILE=${SYSTEMD_CROSS_FILE:-"$BUILD_DIR/systemd-arm64.cross"}
|
||||
SYSTEMD_PKG_CONFIG_LIBDIR=${SYSTEMD_PKG_CONFIG_LIBDIR:-/usr/lib/aarch64-linux-gnu/pkgconfig:/usr/share/pkgconfig:/usr/aarch64-linux-gnu/lib/pkgconfig}
|
||||
SYSTEMD_PKG_CONFIG_SYSROOT_DIR=${SYSTEMD_PKG_CONFIG_SYSROOT_DIR:-}
|
||||
SYSTEMD_RUNTIME_LIB_DIRS=${SYSTEMD_RUNTIME_LIB_DIRS:-/usr/aarch64-linux-gnu/lib:/lib/aarch64-linux-gnu:/usr/lib/aarch64-linux-gnu}
|
||||
SYSTEMD_MESON_ARGS=${SYSTEMD_MESON_ARGS:-}
|
||||
|
||||
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"
|
||||
}
|
||||
build_busybox() {
|
||||
[[ -d "$BUSYBOX_SRC_DIR" ]] || "$ROOT_DIR/scripts/fetch-sources.sh"
|
||||
|
||||
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"
|
||||
msg "configuring BusyBox ${BUSYBOX_VERSION} rescue utilities"
|
||||
rm -rf "$BUSYBOX_BUILD_DIR" "$BUSYBOX_INSTALL_DIR"
|
||||
mkdir -p "$BUSYBOX_BUILD_DIR" "$BUSYBOX_INSTALL_DIR"
|
||||
|
||||
make -C "$BUSYBOX_SRC_DIR" O="$BUSYBOX_BUILD_DIR" \
|
||||
ARCH="$KERNEL_MAKE_ARCH" CROSS_COMPILE="$CROSS_COMPILE" defconfig
|
||||
apply_kconfig_fragment "$BUSYBOX_BUILD_DIR/.config" "$ROOT_DIR/config/busybox.fragment"
|
||||
if ! make -C "$BUSYBOX_SRC_DIR" O="$BUSYBOX_BUILD_DIR" \
|
||||
ARCH="$KERNEL_MAKE_ARCH" CROSS_COMPILE="$CROSS_COMPILE" olddefconfig; then
|
||||
yes "" | make -C "$BUSYBOX_SRC_DIR" O="$BUSYBOX_BUILD_DIR" \
|
||||
ARCH="$KERNEL_MAKE_ARCH" CROSS_COMPILE="$CROSS_COMPILE" oldconfig
|
||||
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
|
||||
|
||||
msg "building static BusyBox ${BUSYBOX_VERSION}"
|
||||
make -C "$BUSYBOX_SRC_DIR" O="$BUSYBOX_BUILD_DIR" \
|
||||
ARCH="$KERNEL_MAKE_ARCH" CROSS_COMPILE="$CROSS_COMPILE" -j"$JOBS"
|
||||
make -C "$BUSYBOX_SRC_DIR" O="$BUSYBOX_BUILD_DIR" \
|
||||
ARCH="$KERNEL_MAKE_ARCH" CROSS_COMPILE="$CROSS_COMPILE" \
|
||||
CONFIG_PREFIX="$BUSYBOX_INSTALL_DIR" install
|
||||
}
|
||||
|
||||
cleanup_chroot_mounts() {
|
||||
local mountpoint
|
||||
write_systemd_cross_file() {
|
||||
local ar_tool="${CROSS_COMPILE}ar"
|
||||
local strip_tool="${CROSS_COMPILE}strip"
|
||||
local pkg_config_tool="${PKG_CONFIG:-pkg-config}"
|
||||
|
||||
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
|
||||
}
|
||||
command -v "$ar_tool" >/dev/null 2>&1 || ar_tool=ar
|
||||
command -v "$strip_tool" >/dev/null 2>&1 || strip_tool=strip
|
||||
|
||||
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//,/ }
|
||||
cat > "$SYSTEMD_CROSS_FILE" <<EOF
|
||||
[binaries]
|
||||
c = '$CC'
|
||||
ar = '$ar_tool'
|
||||
strip = '$strip_tool'
|
||||
pkgconfig = '$pkg_config_tool'
|
||||
|
||||
[host_machine]
|
||||
system = 'linux'
|
||||
cpu_family = 'aarch64'
|
||||
cpu = 'aarch64'
|
||||
endian = 'little'
|
||||
|
||||
[properties]
|
||||
needs_exe_wrapper = true
|
||||
EOF
|
||||
}
|
||||
|
||||
bootstrap_with_mmdebstrap() {
|
||||
local package_csv
|
||||
meson_has_option() {
|
||||
local option=$1
|
||||
|
||||
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
|
||||
grep -Eq "option\\(['\"]${option}['\"]" "$SYSTEMD_SRC_DIR/meson_options.txt" 2>/dev/null
|
||||
}
|
||||
|
||||
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"
|
||||
add_meson_option() {
|
||||
local option=$1
|
||||
local value=$2
|
||||
|
||||
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"
|
||||
if meson_has_option "$option"; then
|
||||
systemd_meson_args+=("-D${option}=${value}")
|
||||
fi
|
||||
}
|
||||
|
||||
enable_unit() {
|
||||
local unit=$1
|
||||
local target=$2
|
||||
local source
|
||||
build_systemd() {
|
||||
local extra_args=()
|
||||
local systemd_binary="$SYSTEMD_INSTALL_DIR/usr/lib/systemd/systemd"
|
||||
|
||||
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"
|
||||
if [[ -x "$systemd_binary" ]]; then
|
||||
msg "using cached systemd install tree"
|
||||
return
|
||||
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"
|
||||
[[ -d "$SYSTEMD_SRC_DIR" ]] || "$ROOT_DIR/scripts/fetch-sources.sh"
|
||||
|
||||
msg "configuring systemd ${SYSTEMD_VERSION}"
|
||||
rm -rf "$SYSTEMD_BUILD_DIR" "$SYSTEMD_INSTALL_DIR"
|
||||
mkdir -p "$SYSTEMD_BUILD_DIR" "$SYSTEMD_INSTALL_DIR"
|
||||
write_systemd_cross_file
|
||||
|
||||
systemd_meson_args=(
|
||||
setup "$SYSTEMD_BUILD_DIR" "$SYSTEMD_SRC_DIR"
|
||||
--cross-file "$SYSTEMD_CROSS_FILE"
|
||||
--prefix=/usr
|
||||
--sysconfdir=/etc
|
||||
--localstatedir=/var
|
||||
--libdir=lib
|
||||
)
|
||||
|
||||
add_meson_option mode release
|
||||
add_meson_option man false
|
||||
add_meson_option html false
|
||||
add_meson_option tests false
|
||||
add_meson_option install-tests false
|
||||
add_meson_option translations false
|
||||
add_meson_option firstboot false
|
||||
add_meson_option homed false
|
||||
add_meson_option logind false
|
||||
add_meson_option machined false
|
||||
add_meson_option portabled false
|
||||
add_meson_option oomd false
|
||||
add_meson_option repart false
|
||||
add_meson_option sysupdate false
|
||||
add_meson_option userdb false
|
||||
add_meson_option networkd true
|
||||
add_meson_option resolved true
|
||||
add_meson_option timesyncd true
|
||||
add_meson_option tmpfiles true
|
||||
add_meson_option sysusers true
|
||||
add_meson_option randomseed true
|
||||
|
||||
if [[ -n "$SYSTEMD_MESON_ARGS" ]]; then
|
||||
# shellcheck disable=SC2206
|
||||
extra_args=($SYSTEMD_MESON_ARGS)
|
||||
systemd_meson_args+=("${extra_args[@]}")
|
||||
fi
|
||||
|
||||
for group in sudo adm cdrom dip plugdev users video audio netdev; do
|
||||
add_group_member "$group" "$ARM64_USER"
|
||||
PKG_CONFIG_LIBDIR="$SYSTEMD_PKG_CONFIG_LIBDIR" \
|
||||
PKG_CONFIG_SYSROOT_DIR="$SYSTEMD_PKG_CONFIG_SYSROOT_DIR" \
|
||||
meson "${systemd_meson_args[@]}"
|
||||
|
||||
msg "building systemd ${SYSTEMD_VERSION}"
|
||||
ninja -C "$SYSTEMD_BUILD_DIR" -j"$JOBS"
|
||||
DESTDIR="$SYSTEMD_INSTALL_DIR" ninja -C "$SYSTEMD_BUILD_DIR" install
|
||||
|
||||
[[ -x "$systemd_binary" ]] || die "systemd install did not produce $systemd_binary"
|
||||
}
|
||||
|
||||
runtime_library_paths() {
|
||||
local path
|
||||
|
||||
printf '%s\n' "$ROOTFS_STAGING_DIR/usr/lib"
|
||||
printf '%s\n' "$ROOTFS_STAGING_DIR/usr/lib/systemd"
|
||||
printf '%s\n' "$ROOTFS_STAGING_DIR/usr/lib/aarch64-linux-gnu"
|
||||
printf '%s\n' "$ROOTFS_STAGING_DIR/lib"
|
||||
printf '%s\n' "$ROOTFS_STAGING_DIR/lib/aarch64-linux-gnu"
|
||||
IFS=: read -ra paths <<< "$SYSTEMD_RUNTIME_LIB_DIRS"
|
||||
for path in "${paths[@]}"; do
|
||||
[[ -n "$path" ]] && printf '%s\n' "$path"
|
||||
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"
|
||||
find_runtime_library() {
|
||||
local name=$1
|
||||
local dir
|
||||
|
||||
while IFS= read -r dir; do
|
||||
[[ -f "$dir/$name" ]] || continue
|
||||
printf '%s\n' "$dir/$name"
|
||||
return 0
|
||||
done < <(runtime_library_paths)
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
copy_runtime_library() {
|
||||
local source=$1
|
||||
local name=${source##*/}
|
||||
|
||||
mkdir -p "$ROOTFS_STAGING_DIR/usr/lib/aarch64-linux-gnu" "$ROOTFS_STAGING_DIR/lib/aarch64-linux-gnu"
|
||||
install -m 0644 "$source" "$ROOTFS_STAGING_DIR/usr/lib/aarch64-linux-gnu/$name"
|
||||
ln -sfn "../../usr/lib/aarch64-linux-gnu/$name" "$ROOTFS_STAGING_DIR/lib/aarch64-linux-gnu/$name"
|
||||
}
|
||||
|
||||
copy_dynamic_interpreter() {
|
||||
local readelf_tool=$1
|
||||
local binary=$2
|
||||
local interpreter
|
||||
local name
|
||||
local found
|
||||
|
||||
interpreter=$("$readelf_tool" -l "$binary" 2>/dev/null | awk -F': ' '/Requesting program interpreter/ { gsub(/]/, "", $2); print $2; exit }')
|
||||
[[ -n "$interpreter" ]] || return 0
|
||||
|
||||
name=${interpreter##*/}
|
||||
if [[ -f "$ROOTFS_STAGING_DIR$interpreter" ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
found=$(find_runtime_library "$name" || true)
|
||||
[[ -n "$found" ]] || die "could not locate dynamic interpreter $name; set SYSTEMD_RUNTIME_LIB_DIRS"
|
||||
|
||||
install -Dm755 "$found" "$ROOTFS_STAGING_DIR$interpreter"
|
||||
}
|
||||
|
||||
copy_systemd_runtime_libraries() {
|
||||
local readelf_tool="${READELF:-${CROSS_COMPILE}readelf}"
|
||||
local item
|
||||
local needed
|
||||
local lib
|
||||
local queue=()
|
||||
local next=()
|
||||
local seen_key
|
||||
declare -A seen=()
|
||||
|
||||
command -v "$readelf_tool" >/dev/null 2>&1 || die "missing required command: $readelf_tool"
|
||||
|
||||
while IFS= read -r item; do
|
||||
queue+=("$item")
|
||||
done < <(
|
||||
find "$ROOTFS_STAGING_DIR/usr/lib/systemd" "$ROOTFS_STAGING_DIR/usr/bin" \
|
||||
-type f -perm /111 -print 2>/dev/null
|
||||
)
|
||||
|
||||
while [[ "${#queue[@]}" -gt 0 ]]; do
|
||||
next=()
|
||||
for item in "${queue[@]}"; do
|
||||
[[ -f "$item" ]] || continue
|
||||
seen_key=$(readlink -f "$item")
|
||||
[[ -n "${seen[$seen_key]:-}" ]] && continue
|
||||
seen[$seen_key]=1
|
||||
|
||||
copy_dynamic_interpreter "$readelf_tool" "$item"
|
||||
|
||||
while IFS= read -r needed; do
|
||||
[[ -n "$needed" ]] || continue
|
||||
lib=$(find_runtime_library "$needed" || true)
|
||||
[[ -n "$lib" ]] || die "could not locate runtime library $needed; set SYSTEMD_RUNTIME_LIB_DIRS"
|
||||
copy_runtime_library "$lib"
|
||||
next+=("$lib")
|
||||
done < <("$readelf_tool" -d "$item" 2>/dev/null | awk -F'[][]' '/NEEDED/ { print $2 }')
|
||||
done
|
||||
queue=("${next[@]}")
|
||||
done
|
||||
}
|
||||
|
||||
write_identity_files() {
|
||||
local today
|
||||
local root_hash
|
||||
local user_hash
|
||||
local user
|
||||
local uid
|
||||
local members=
|
||||
local index
|
||||
|
||||
ensure_group nixbld 30000
|
||||
today=$(($(date +%s) / 86400))
|
||||
root_hash=$(openssl passwd -6 -salt root "$ROOTFS_ROOT_PASSWORD")
|
||||
user_hash=$(openssl passwd -6 -salt "$ROOTFS_USER" "$ROOTFS_USER_PASSWORD")
|
||||
|
||||
for index in $(seq 1 32); do
|
||||
cat > "$ROOTFS_STAGING_DIR/etc/passwd" <<EOF
|
||||
root:x:0:0:root:/root:/bin/sh
|
||||
systemd-journal:x:190:190:systemd Journal:/var/log/journal:/bin/false
|
||||
systemd-network:x:192:192:systemd Network Management:/:/bin/false
|
||||
systemd-resolve:x:193:193:systemd Resolver:/:/bin/false
|
||||
systemd-timesync:x:194:194:systemd Time Synchronization:/:/bin/false
|
||||
$ROOTFS_USER:x:$ROOTFS_USER_UID:$ROOTFS_USER_UID:ForgeOS User:/home/$ROOTFS_USER:/bin/sh
|
||||
nobody:x:65534:65534:nobody:/var/empty:/bin/false
|
||||
EOF
|
||||
|
||||
cat > "$ROOTFS_STAGING_DIR/etc/group" <<EOF
|
||||
root:x:0:
|
||||
tty:x:5:
|
||||
disk:x:6:
|
||||
kmem:x:9:
|
||||
audio:x:29:$ROOTFS_USER
|
||||
video:x:44:$ROOTFS_USER
|
||||
utmp:x:43:
|
||||
users:x:100:$ROOTFS_USER
|
||||
input:x:104:$ROOTFS_USER
|
||||
netdev:x:108:$ROOTFS_USER
|
||||
systemd-journal:x:190:
|
||||
systemd-network:x:192:
|
||||
systemd-resolve:x:193:
|
||||
systemd-timesync:x:194:
|
||||
$ROOTFS_USER:x:$ROOTFS_USER_UID:
|
||||
nobody:x:65534:
|
||||
EOF
|
||||
|
||||
cat > "$ROOTFS_STAGING_DIR/etc/shadow" <<EOF
|
||||
root:$root_hash:$today:0:99999:7:::
|
||||
systemd-journal:!:$today:0:99999:7:::
|
||||
systemd-network:!:$today:0:99999:7:::
|
||||
systemd-resolve:!:$today:0:99999:7:::
|
||||
systemd-timesync:!:$today:0:99999:7:::
|
||||
$ROOTFS_USER:$user_hash:$today:0:99999:7:::
|
||||
nobody:!:$today:0:99999:7:::
|
||||
EOF
|
||||
|
||||
cat > "$ROOTFS_STAGING_DIR/etc/gshadow" <<EOF
|
||||
root:*::
|
||||
tty:*::
|
||||
disk:*::
|
||||
kmem:*::
|
||||
audio:*::$ROOTFS_USER
|
||||
video:*::$ROOTFS_USER
|
||||
utmp:*::
|
||||
users:*::$ROOTFS_USER
|
||||
input:*::$ROOTFS_USER
|
||||
netdev:*::$ROOTFS_USER
|
||||
systemd-journal:*::
|
||||
systemd-network:*::
|
||||
systemd-resolve:*::
|
||||
systemd-timesync:*::
|
||||
$ROOTFS_USER:*::
|
||||
nobody:*::
|
||||
EOF
|
||||
|
||||
for index in $(seq 1 "$NIX_BUILD_USERS"); 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"
|
||||
printf '%s:x:%s:30000:Nix build user %s:/var/empty:/bin/false\n' "$user" "$uid" "$index" >> "$ROOTFS_STAGING_DIR/etc/passwd"
|
||||
printf '%s:!:%s:0:99999:7:::\n' "$user" "$today" >> "$ROOTFS_STAGING_DIR/etc/shadow"
|
||||
done
|
||||
printf 'nixbld:x:30000:%s\n' "$members" >> "$ROOTFS_STAGING_DIR/etc/group"
|
||||
printf 'nixbld:*::%s\n' "$members" >> "$ROOTFS_STAGING_DIR/etc/gshadow"
|
||||
|
||||
sed -i "s|^nixbld:.*|nixbld:x:30000:${members}|" "$group_file"
|
||||
ensure_gshadow_group nixbld "$members"
|
||||
}
|
||||
chmod 0644 "$ROOTFS_STAGING_DIR/etc/passwd" "$ROOTFS_STAGING_DIR/etc/group"
|
||||
chmod 0600 "$ROOTFS_STAGING_DIR/etc/shadow" "$ROOTFS_STAGING_DIR/etc/gshadow"
|
||||
|
||||
configure_identity() {
|
||||
mkdir -p "$ROOTFS_STAGING_DIR/etc/default"
|
||||
printf 'forgeos-arm64\n' > "$ROOTFS_STAGING_DIR/etc/hostname"
|
||||
printf '%s\n' "$ROOTFS_HOSTNAME" > "$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
|
||||
PRETTY_NAME="ForgeOS ARM64 systemd + Nix"
|
||||
VERSION="${KERNEL_VERSION}"
|
||||
BUILD_ID="systemd-${SYSTEMD_VERSION}-nix-${NIX_VERSION}"
|
||||
EOF
|
||||
printf 'LANG=en_US.UTF-8\n' > "$ROOTFS_STAGING_DIR/etc/default/locale"
|
||||
rm -f "$ROOTFS_STAGING_DIR/etc/machine-id"
|
||||
cat > "$ROOTFS_STAGING_DIR/etc/issue" <<'EOF'
|
||||
ForgeOS ARM64 systemd + Nix \r on \m
|
||||
|
||||
EOF
|
||||
cat > "$ROOTFS_STAGING_DIR/etc/profile" <<'EOF'
|
||||
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
|
||||
for profile in /etc/profile.d/*.sh; do
|
||||
[ -r "$profile" ] && . "$profile"
|
||||
done
|
||||
unset profile
|
||||
export PS1='\u@\h:\w\$ '
|
||||
umask 022
|
||||
EOF
|
||||
cat > "$ROOTFS_STAGING_DIR/etc/shells" <<'EOF'
|
||||
/bin/sh
|
||||
/bin/ash
|
||||
EOF
|
||||
cat > "$ROOTFS_STAGING_DIR/etc/securetty" <<'EOF'
|
||||
console
|
||||
tty1
|
||||
ttyAMA0
|
||||
EOF
|
||||
cat > "$ROOTFS_STAGING_DIR/etc/nsswitch.conf" <<'EOF'
|
||||
passwd: files
|
||||
group: files
|
||||
shadow: files
|
||||
hosts: files dns
|
||||
networks: files
|
||||
protocols: files
|
||||
services: files
|
||||
EOF
|
||||
cat > "$ROOTFS_STAGING_DIR/etc/hosts" <<EOF
|
||||
127.0.0.1 localhost
|
||||
127.0.1.1 $ROOTFS_HOSTNAME
|
||||
::1 localhost ip6-localhost ip6-loopback
|
||||
EOF
|
||||
printf 'LANG=C.UTF-8\n' > "$ROOTFS_STAGING_DIR/etc/locale.conf"
|
||||
: > "$ROOTFS_STAGING_DIR/etc/machine-id"
|
||||
printf 'ForgeOS rootfs: Linux %s + systemd %s + Nix %s\n' \
|
||||
"$KERNEL_VERSION" "$SYSTEMD_VERSION" "$NIX_VERSION" > "$ROOTFS_STAGING_DIR/etc/forgeos-systemd-nix"
|
||||
}
|
||||
|
||||
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)
|
||||
write_fstab() {
|
||||
cat > "$ROOTFS_STAGING_DIR/etc/fstab" <<'EOF'
|
||||
proc /proc proc defaults 0 0
|
||||
sysfs /sys sysfs defaults 0 0
|
||||
devtmpfs /dev devtmpfs mode=0755,nosuid 0 0
|
||||
tmpfs /run tmpfs mode=0755,nosuid,nodev 0 0
|
||||
tmpfs /tmp tmpfs mode=1777,nosuid,nodev 0 0
|
||||
EOF
|
||||
}
|
||||
|
||||
write_systemd_units() {
|
||||
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
|
||||
"$ROOTFS_STAGING_DIR/usr/lib/tmpfiles.d"
|
||||
|
||||
cat > "$ROOTFS_STAGING_DIR/etc/systemd/network/20-dhcp.network" <<'EOF'
|
||||
[Match]
|
||||
@@ -312,26 +409,164 @@ 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"
|
||||
cat > "$ROOTFS_STAGING_DIR/etc/systemd/system/forgeos-getty@.service" <<'EOF'
|
||||
[Unit]
|
||||
Description=ForgeOS console login on %I
|
||||
After=systemd-user-sessions.service
|
||||
Before=getty.target
|
||||
IgnoreOnIsolate=yes
|
||||
ConditionPathExists=/dev/%I
|
||||
|
||||
[Service]
|
||||
ExecStart=-/sbin/getty 38400 %I linux
|
||||
Restart=always
|
||||
RestartSec=0
|
||||
Type=idle
|
||||
TTYPath=/dev/%I
|
||||
TTYReset=yes
|
||||
TTYVHangup=yes
|
||||
KillMode=process
|
||||
|
||||
[Install]
|
||||
WantedBy=getty.target
|
||||
EOF
|
||||
|
||||
cat > "$ROOTFS_STAGING_DIR/etc/systemd/system/forgeos-serial-getty@.service" <<'EOF'
|
||||
[Unit]
|
||||
Description=ForgeOS serial login on %I
|
||||
After=systemd-user-sessions.service
|
||||
Before=getty.target
|
||||
IgnoreOnIsolate=yes
|
||||
ConditionPathExists=/dev/%I
|
||||
|
||||
[Service]
|
||||
ExecStart=-/sbin/getty -L 115200 %I vt100
|
||||
Restart=always
|
||||
RestartSec=0
|
||||
Type=idle
|
||||
TTYPath=/dev/%I
|
||||
TTYReset=yes
|
||||
TTYVHangup=yes
|
||||
KillMode=process
|
||||
|
||||
[Install]
|
||||
WantedBy=getty.target
|
||||
EOF
|
||||
|
||||
cat > "$ROOTFS_STAGING_DIR/etc/systemd/system/forgeos-console-banner.service" <<'EOF'
|
||||
[Unit]
|
||||
Description=Print ForgeOS console banner
|
||||
After=multi-user.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/sbin/forgeos-console-banner
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
cat > "$ROOTFS_STAGING_DIR/etc/systemd/system/forgeos-bootdiag.service" <<'EOF'
|
||||
[Unit]
|
||||
Description=Record ForgeOS boot diagnostics
|
||||
DefaultDependencies=no
|
||||
After=local-fs.target systemd-udev-settle.service
|
||||
Before=multi-user.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/sbin/forgeos-bootdiag userspace-start
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
cat > "$ROOTFS_STAGING_DIR/usr/lib/tmpfiles.d/forgeos.conf" <<'EOF'
|
||||
d /run/lock 0755 root root - -
|
||||
d /var/log/journal 2755 root systemd-journal - -
|
||||
d /var/lib/systemd 0755 root root - -
|
||||
d /var/lib/systemd/timesync 0755 systemd-timesync systemd-timesync - -
|
||||
d /var/empty 0755 root root - -
|
||||
EOF
|
||||
}
|
||||
|
||||
unit_path() {
|
||||
local unit=$1
|
||||
local template=
|
||||
|
||||
if [[ "$unit" == *@*.service && "$unit" != *@.service ]]; then
|
||||
template="${unit%@*}@.service"
|
||||
fi
|
||||
|
||||
if [[ -e "$ROOTFS_STAGING_DIR/usr/lib/systemd/system/$unit" ]]; then
|
||||
printf '/usr/lib/systemd/system/%s\n' "$unit"
|
||||
elif [[ -e "$ROOTFS_STAGING_DIR/lib/systemd/system/$unit" ]]; then
|
||||
printf '/lib/systemd/system/%s\n' "$unit"
|
||||
elif [[ -e "$ROOTFS_STAGING_DIR/etc/systemd/system/$unit" ]]; then
|
||||
printf '/etc/systemd/system/%s\n' "$unit"
|
||||
elif [[ -n "$template" && -e "$ROOTFS_STAGING_DIR/usr/lib/systemd/system/$template" ]]; then
|
||||
printf '/usr/lib/systemd/system/%s\n' "$template"
|
||||
elif [[ -n "$template" && -e "$ROOTFS_STAGING_DIR/lib/systemd/system/$template" ]]; then
|
||||
printf '/lib/systemd/system/%s\n' "$template"
|
||||
elif [[ -n "$template" && -e "$ROOTFS_STAGING_DIR/etc/systemd/system/$template" ]]; then
|
||||
printf '/etc/systemd/system/%s\n' "$template"
|
||||
else
|
||||
return 1
|
||||
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"
|
||||
enable_unit() {
|
||||
local unit=$1
|
||||
local target=$2
|
||||
local source
|
||||
|
||||
source=$(unit_path "$unit") || return 0
|
||||
mkdir -p "$ROOTFS_STAGING_DIR/etc/systemd/system/$target.wants"
|
||||
ln -sfn "$source" "$ROOTFS_STAGING_DIR/etc/systemd/system/$target.wants/$unit"
|
||||
}
|
||||
|
||||
msg "assembling ARM64 root filesystem"
|
||||
BOOTSTRAP_TOOL=$(choose_bootstrap_tool)
|
||||
configure_systemd_boot() {
|
||||
local multi_user_target
|
||||
local systemd_binary=/usr/lib/systemd/systemd
|
||||
|
||||
[[ -x "$ROOTFS_STAGING_DIR$systemd_binary" ]] || die "missing systemd binary at $systemd_binary"
|
||||
ln -sfn ../usr/lib/systemd/systemd "$ROOTFS_STAGING_DIR/sbin/init"
|
||||
|
||||
multi_user_target=$(unit_path multi-user.target) || die "systemd did not install multi-user.target"
|
||||
ln -sfn "$multi_user_target" "$ROOTFS_STAGING_DIR/etc/systemd/system/default.target"
|
||||
|
||||
enable_unit forgeos-getty@tty1.service getty.target
|
||||
enable_unit forgeos-serial-getty@ttyAMA0.service getty.target
|
||||
enable_unit forgeos-console-banner.service multi-user.target
|
||||
enable_unit forgeos-bootdiag.service multi-user.target
|
||||
|
||||
enable_unit systemd-journald.socket sockets.target
|
||||
enable_unit systemd-journald-dev-log.socket sockets.target
|
||||
enable_unit systemd-udevd-control.socket sockets.target
|
||||
enable_unit systemd-udevd-kernel.socket sockets.target
|
||||
enable_unit systemd-udevd.service sysinit.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
|
||||
|
||||
enable_unit forgeos-nix-bootstrap.service sysinit.target
|
||||
enable_unit nix-daemon.service multi-user.target
|
||||
enable_unit nix-daemon.socket sockets.target
|
||||
}
|
||||
|
||||
install_forgeos_helpers() {
|
||||
install -Dm755 "$OVERLAY_DIR/init" "$ROOTFS_STAGING_DIR/init"
|
||||
install -Dm755 "$OVERLAY_DIR/sbin/forgeos-switch-root" "$ROOTFS_STAGING_DIR/sbin/forgeos-switch-root"
|
||||
install -Dm755 "$OVERLAY_DIR/sbin/forgeos-bootdiag" "$ROOTFS_STAGING_DIR/sbin/forgeos-bootdiag"
|
||||
install -Dm755 "$OVERLAY_DIR/sbin/forgeos-console-banner" "$ROOTFS_STAGING_DIR/sbin/forgeos-console-banner"
|
||||
install -Dm755 "$OVERLAY_DIR/usr/share/udhcpc/default.script" \
|
||||
"$ROOTFS_STAGING_DIR/usr/share/udhcpc/default.script"
|
||||
}
|
||||
|
||||
assemble_rootfs() {
|
||||
msg "assembling systemd + Nix ARM64 root filesystem"
|
||||
|
||||
[[ "$ARCH" == "arm64" ]] || die "ARM64 rootfs requires ARCH=arm64"
|
||||
[[ -f "$KERNEL_IMAGE" ]] || "$ROOT_DIR/scripts/build-kernel.sh"
|
||||
@@ -341,32 +576,34 @@ 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"
|
||||
rsync -a "$BUSYBOX_INSTALL_DIR/" "$ROOTFS_STAGING_DIR/"
|
||||
rsync -a "$SYSTEMD_INSTALL_DIR/" "$ROOTFS_STAGING_DIR/"
|
||||
|
||||
case "$BOOTSTRAP_TOOL" in
|
||||
mmdebstrap)
|
||||
bootstrap_with_mmdebstrap
|
||||
;;
|
||||
debootstrap)
|
||||
bootstrap_with_debootstrap
|
||||
;;
|
||||
esac
|
||||
mkdir -p \
|
||||
"$ROOTFS_STAGING_DIR"/{boot,dev,etc/profile.d,home,lib,mnt,media,proc,root,run,sbin,sys,tmp,usr/bin,usr/sbin,var} \
|
||||
"$ROOTFS_STAGING_DIR/home/$ROOTFS_USER" \
|
||||
"$ROOTFS_STAGING_DIR/var"/{empty,lib/systemd,log/journal,run,tmp}
|
||||
|
||||
msg "configuring ForgeOS ARM64 defaults"
|
||||
configure_identity
|
||||
configure_user
|
||||
configure_nix_build_users
|
||||
configure_console_services
|
||||
copy_systemd_runtime_libraries
|
||||
write_identity_files
|
||||
write_fstab
|
||||
write_systemd_units
|
||||
install_forgeos_helpers
|
||||
"$ROOT_DIR/scripts/stage-nix.sh"
|
||||
enable_nix_services
|
||||
configure_systemd_boot
|
||||
|
||||
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"
|
||||
chmod 0700 "$ROOTFS_STAGING_DIR/root" "$ROOTFS_STAGING_DIR/home/$ROOTFS_USER"
|
||||
chmod 1777 "$ROOTFS_STAGING_DIR/tmp" "$ROOTFS_STAGING_DIR/var/tmp"
|
||||
}
|
||||
|
||||
build_busybox
|
||||
build_systemd
|
||||
assemble_rootfs
|
||||
|
||||
find "$ROOTFS_STAGING_DIR" -printf '%P\n' | LC_ALL=C sort > "$OUT_DIR/rootfs.manifest"
|
||||
(
|
||||
@@ -374,5 +611,5 @@ find "$ROOTFS_STAGING_DIR" -printf '%P\n' | LC_ALL=C sort > "$OUT_DIR/rootfs.man
|
||||
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 "systemd + Nix ARM64 rootfs tree: $ROOTFS_STAGING_DIR"
|
||||
msg "initramfs: $OUT_DIR/rootfs.cpio.gz"
|
||||
@@ -1,285 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
source "$(dirname "$0")/common.sh"
|
||||
|
||||
require_cmd find openssl rsync
|
||||
ensure_dirs
|
||||
|
||||
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}
|
||||
GNOME_USER_UID=${GNOME_USER_UID:-1000}
|
||||
GNOME_USER_PASSWORD=${GNOME_USER_PASSWORD:-forge}
|
||||
GNOME_AUTOLOGIN=${GNOME_AUTOLOGIN:-1}
|
||||
GNOME_PACKAGES=${GNOME_PACKAGES:-systemd-sysv dbus dbus-user-session gnome-core gdm3 network-manager sudo locales xserver-xorg xserver-xorg-video-all xserver-xorg-input-libinput mesa-utils fonts-dejavu firmware-linux-free}
|
||||
|
||||
normalize_packages_csv() {
|
||||
local package_csv
|
||||
|
||||
package_csv=${GNOME_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 "$GNOME_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 "$GNOME_BOOTSTRAP_TOOL" >/dev/null 2>&1 || die "missing required command: $GNOME_BOOTSTRAP_TOOL"
|
||||
printf '%s\n' "$GNOME_BOOTSTRAP_TOOL"
|
||||
;;
|
||||
*)
|
||||
die "unsupported GNOME_BOOTSTRAP_TOOL=$GNOME_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 ${GNOME_COMPONENTS//,/ }
|
||||
deb http://security.debian.org/debian-security ${GNOME_SUITE}-security ${GNOME_COMPONENTS//,/ }
|
||||
deb $GNOME_MIRROR ${GNOME_SUITE}-updates ${GNOME_COMPONENTS//,/ }
|
||||
EOF
|
||||
}
|
||||
|
||||
bootstrap_with_mmdebstrap() {
|
||||
local package_csv
|
||||
|
||||
require_cmd mmdebstrap
|
||||
package_csv=$(normalize_packages_csv)
|
||||
|
||||
msg "bootstrapping Debian $GNOME_SUITE GNOME rootfs with mmdebstrap"
|
||||
DEBIAN_FRONTEND=noninteractive mmdebstrap \
|
||||
--mode=auto \
|
||||
--variant=apt \
|
||||
--architectures="$GNOME_DEBIAN_ARCH" \
|
||||
--components="$GNOME_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 base rootfs with debootstrap"
|
||||
debootstrap \
|
||||
--arch="$GNOME_DEBIAN_ARCH" \
|
||||
--components="$GNOME_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 GNOME 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 $GNOME_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
|
||||
}
|
||||
|
||||
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"
|
||||
}
|
||||
|
||||
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/$GNOME_USER"
|
||||
|
||||
ensure_group "$GNOME_USER" "$GNOME_USER_UID"
|
||||
|
||||
if ! grep -q "^${GNOME_USER}:" "$passwd_file"; then
|
||||
printf '%s:x:%s:%s:ForgeOS GNOME User:/home/%s:/bin/bash\n' \
|
||||
"$GNOME_USER" "$GNOME_USER_UID" "$GNOME_USER_UID" "$GNOME_USER" >> "$passwd_file"
|
||||
fi
|
||||
|
||||
password_hash=$(openssl passwd -6 -salt "$GNOME_USER" "$GNOME_USER_PASSWORD")
|
||||
today=$(($(date +%s) / 86400))
|
||||
if grep -q "^${GNOME_USER}:" "$shadow_file"; then
|
||||
sed -i "s|^${GNOME_USER}:.*|${GNOME_USER}:${password_hash}:${today}:0:99999:7:::|" "$shadow_file"
|
||||
else
|
||||
printf '%s:%s:%s:0:99999:7:::\n' "$GNOME_USER" "$password_hash" "$today" >> "$shadow_file"
|
||||
fi
|
||||
|
||||
for group in sudo adm cdrom dip plugdev users video audio netdev; do
|
||||
add_group_member "$group" "$GNOME_USER"
|
||||
done
|
||||
|
||||
mkdir -p "$home_dir"
|
||||
chmod 0750 "$home_dir"
|
||||
if [[ "$EUID" -eq 0 ]]; then
|
||||
chown -R "$GNOME_USER_UID:$GNOME_USER_UID" "$home_dir"
|
||||
fi
|
||||
|
||||
mkdir -p "$ROOTFS_STAGING_DIR/etc/sudoers.d"
|
||||
printf '%s ALL=(ALL:ALL) ALL\n' "$GNOME_USER" > "$ROOTFS_STAGING_DIR/etc/sudoers.d/forgeos"
|
||||
chmod 0440 "$ROOTFS_STAGING_DIR/etc/sudoers.d/forgeos"
|
||||
}
|
||||
|
||||
configure_desktop_services() {
|
||||
local graphical_target
|
||||
local gdm_service
|
||||
local network_manager_service
|
||||
|
||||
graphical_target=$(unit_path graphical.target)
|
||||
gdm_service=$(unit_path gdm3.service)
|
||||
network_manager_service=$(unit_path NetworkManager.service)
|
||||
|
||||
mkdir -p \
|
||||
"$ROOTFS_STAGING_DIR/etc/systemd/system" \
|
||||
"$ROOTFS_STAGING_DIR/etc/systemd/system/multi-user.target.wants"
|
||||
|
||||
ln -sfn "$graphical_target" "$ROOTFS_STAGING_DIR/etc/systemd/system/default.target"
|
||||
|
||||
if [[ -e "$ROOTFS_STAGING_DIR${gdm_service}" ]]; then
|
||||
ln -sfn "$gdm_service" "$ROOTFS_STAGING_DIR/etc/systemd/system/display-manager.service"
|
||||
fi
|
||||
|
||||
if [[ -e "$ROOTFS_STAGING_DIR${network_manager_service}" ]]; then
|
||||
ln -sfn "$network_manager_service" \
|
||||
"$ROOTFS_STAGING_DIR/etc/systemd/system/multi-user.target.wants/NetworkManager.service"
|
||||
fi
|
||||
|
||||
mkdir -p "$ROOTFS_STAGING_DIR/etc/gdm3"
|
||||
{
|
||||
printf '[daemon]\n'
|
||||
printf 'WaylandEnable=false\n'
|
||||
if truthy "$GNOME_AUTOLOGIN"; then
|
||||
printf 'AutomaticLoginEnable=true\n'
|
||||
printf 'AutomaticLogin=%s\n' "$GNOME_USER"
|
||||
fi
|
||||
} > "$ROOTFS_STAGING_DIR/etc/gdm3/daemon.conf"
|
||||
}
|
||||
|
||||
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 ARM64
|
||||
ID=forgeos-arm64
|
||||
ID_LIKE=debian
|
||||
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"
|
||||
rm -f "$ROOTFS_STAGING_DIR/etc/machine-id"
|
||||
: > "$ROOTFS_STAGING_DIR/etc/machine-id"
|
||||
}
|
||||
|
||||
msg "assembling GNOME root filesystem"
|
||||
BOOTSTRAP_TOOL=$(choose_bootstrap_tool)
|
||||
|
||||
[[ "$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
|
||||
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 GNOME defaults"
|
||||
configure_identity
|
||||
configure_user
|
||||
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 "$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"
|
||||
|
||||
msg "GNOME rootfs tree: $ROOTFS_STAGING_DIR"
|
||||
msg "default desktop user: $GNOME_USER"
|
||||
+34
-29
@@ -4,24 +4,20 @@ set -euo pipefail
|
||||
|
||||
source "$(dirname "$0")/common.sh"
|
||||
|
||||
require_cmd qemu-img parted mkfs.vfat mkfs.ext4 mcopy mmd dd awk truncate
|
||||
require_cmd qemu-img parted mkfs.vfat mkfs.ext4 debugfs mcopy mmd dd awk truncate
|
||||
ensure_dirs
|
||||
|
||||
ROOTFS_USER=${ROOTFS_USER:-forge}
|
||||
ROOTFS_USER_UID=${ROOTFS_USER_UID:-1000}
|
||||
|
||||
normal_rootfs_matches() {
|
||||
[[ -d "$ROOTFS_STAGING_DIR" ]] || return 1
|
||||
[[ -f "$ROOTFS_STAGING_DIR/etc/forgeos-nix" ]] || return 1
|
||||
[[ ! -f "$ROOTFS_STAGING_DIR/etc/forgeos-desktop" ]] || return 1
|
||||
[[ ! -f "$ROOTFS_STAGING_DIR/etc/forgeos-doom-emacs" ]] || return 1
|
||||
[[ -f "$ROOTFS_STAGING_DIR/etc/forgeos-systemd-nix" ]] || return 1
|
||||
}
|
||||
|
||||
[[ -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"
|
||||
|
||||
[[ -f "$OUT_DIR/rootfs.cpio.gz" ]] || "$ROOT_DIR/scripts/build-rootfs.sh"
|
||||
fi
|
||||
|
||||
EFI_INITRD="$OUT_DIR/rootfs.cpio.gz"
|
||||
GRUB_CFG="$OUT_DIR/grub.cfg"
|
||||
@@ -53,7 +49,7 @@ insmod all_video
|
||||
insmod gfxterm
|
||||
terminal_output gfxterm console
|
||||
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 initrd_common="rdinit=/init"
|
||||
set handoff_common="rdinit=/init forgeos.switch_root=1"
|
||||
|
||||
menuentry "ForgeOS ARM64 - default" {
|
||||
@@ -67,7 +63,6 @@ menuentry "ForgeOS ARM64 - firmware framebuffer safe mode" {
|
||||
}
|
||||
EOF
|
||||
|
||||
if [[ "$DESKTOP" != "gnome" ]]; then
|
||||
cat >> "$GRUB_CFG" <<'EOF'
|
||||
|
||||
menuentry "ForgeOS ARM64 - initramfs-assisted root" {
|
||||
@@ -84,7 +79,7 @@ menuentry "ForgeOS ARM64 - initramfs framebuffer safe mode" {
|
||||
|
||||
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
|
||||
linux ($esp)/EFI/BOOT/FORGEOS.EFI $linux_common $initrd_common
|
||||
initrd ($esp)/EFI/BOOT/rootfs.cpio.gz
|
||||
}
|
||||
|
||||
@@ -93,20 +88,6 @@ menuentry "ForgeOS ARM64 - EFI stub chainload" {
|
||||
chainloader ($esp)/EFI/BOOT/FORGEOS.EFI
|
||||
}
|
||||
EOF
|
||||
elif [[ "$DESKTOP" == "gnome" ]]; then
|
||||
cat >> "$GRUB_CFG" <<'EOF'
|
||||
|
||||
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 ARM64 - EFI stub chainload" {
|
||||
search --no-floppy --file --set=esp /EFI/BOOT/FORGEOS.EFI
|
||||
chainloader ($esp)/EFI/BOOT/FORGEOS.EFI
|
||||
}
|
||||
EOF
|
||||
fi
|
||||
}
|
||||
|
||||
prepare_efi_loader() {
|
||||
@@ -135,6 +116,31 @@ prepare_efi_loader() {
|
||||
esac
|
||||
}
|
||||
|
||||
normalize_root_image_ownership() {
|
||||
local command_file="$OUT_DIR/rootfs-ownership.debugfs"
|
||||
local path
|
||||
|
||||
: > "$command_file"
|
||||
while IFS= read -r path; do
|
||||
[[ -n "$path" ]] || continue
|
||||
printf 'set_inode_field /%s uid 0\n' "$path" >> "$command_file"
|
||||
printf 'set_inode_field /%s gid 0\n' "$path" >> "$command_file"
|
||||
done < "$OUT_DIR/rootfs.manifest"
|
||||
|
||||
if [[ -d "$ROOTFS_STAGING_DIR/home/$ROOTFS_USER" ]]; then
|
||||
while IFS= read -r path; do
|
||||
case "$path" in
|
||||
"home/$ROOTFS_USER"|"home/$ROOTFS_USER"/*)
|
||||
printf 'set_inode_field /%s uid %s\n' "$path" "$ROOTFS_USER_UID" >> "$command_file"
|
||||
printf 'set_inode_field /%s gid %s\n' "$path" "$ROOTFS_USER_UID" >> "$command_file"
|
||||
;;
|
||||
esac
|
||||
done < "$OUT_DIR/rootfs.manifest"
|
||||
fi
|
||||
|
||||
debugfs -w -f "$command_file" "$ROOT_IMAGE" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
msg "preparing EFI loader"
|
||||
prepare_efi_loader
|
||||
|
||||
@@ -160,13 +166,12 @@ mmd -i "$ESP_IMAGE" ::/EFI
|
||||
mmd -i "$ESP_IMAGE" ::/EFI/BOOT
|
||||
mcopy -i "$ESP_IMAGE" "$EFI_LOADER" "::/EFI/BOOT/$EFI_BOOT_NAME"
|
||||
mcopy -i "$ESP_IMAGE" "$EFI_KERNEL" ::/EFI/BOOT/FORGEOS.EFI
|
||||
if [[ "$DESKTOP" != "gnome" ]]; then
|
||||
mcopy -i "$ESP_IMAGE" "$EFI_INITRD" ::/EFI/BOOT/rootfs.cpio.gz
|
||||
fi
|
||||
|
||||
msg "building ext4 root partition image"
|
||||
truncate -s "$ROOT_SIZE" "$ROOT_IMAGE"
|
||||
mkfs.ext4 -F -L "$ROOT_LABEL" -d "$ROOTFS_STAGING_DIR" "$ROOT_IMAGE" >/dev/null
|
||||
mkfs.ext4 -F -L "$ROOT_LABEL" -E root_owner=0:0 -d "$ROOTFS_STAGING_DIR" "$ROOT_IMAGE" >/dev/null
|
||||
normalize_root_image_ownership
|
||||
|
||||
msg "embedding partitions into raw disk image"
|
||||
dd if="$ESP_IMAGE" of="$IMAGE_PATH" bs=4M seek="$ESP_OFFSET" oflag=seek_bytes conv=notrunc status=none
|
||||
|
||||
+14
-9
@@ -12,6 +12,8 @@ OVERLAY_DIR=${OVERLAY_DIR:-"$ROOT_DIR/overlay/rootfs"}
|
||||
|
||||
ARCH=${ARCH:-arm64}
|
||||
KERNEL_VERSION=${KERNEL_VERSION:-7.1}
|
||||
BUSYBOX_VERSION=${BUSYBOX_VERSION:-1.36.1}
|
||||
SYSTEMD_VERSION=${SYSTEMD_VERSION:-256}
|
||||
NIX_VERSION=${NIX_VERSION:-2.34.0}
|
||||
NIX_SYSTEM=${NIX_SYSTEM:-aarch64-linux}
|
||||
DESKTOP=${DESKTOP:-console}
|
||||
@@ -27,19 +29,15 @@ case "$ARCH" in
|
||||
;;
|
||||
esac
|
||||
case "$DESKTOP" in
|
||||
console|gnome) ;;
|
||||
console) ;;
|
||||
*)
|
||||
printf 'error: unsupported DESKTOP=%s\n' "$DESKTOP" >&2
|
||||
printf 'error: unsupported DESKTOP=%s; ForgeOS ARM64 is source-built console only\n' "$DESKTOP" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
if [[ -z "${IMAGE_SIZE_MIB:-}" ]]; then
|
||||
if [[ "$DESKTOP" == "gnome" ]]; then
|
||||
IMAGE_SIZE_MIB=12288
|
||||
else
|
||||
IMAGE_SIZE_MIB=4096
|
||||
fi
|
||||
fi
|
||||
ESP_SIZE_MIB=${ESP_SIZE_MIB:-256}
|
||||
BOOTLOADER=${BOOTLOADER:-grub}
|
||||
SECURE_BOOT=${SECURE_BOOT:-0}
|
||||
@@ -54,7 +52,6 @@ if [[ -z "$CROSS_COMPILE" && "$(uname -m)" != "aarch64" ]]; then
|
||||
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}
|
||||
@@ -75,14 +72,22 @@ 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-${SYSTEMD_VERSION}.tar.gz"
|
||||
SYSTEMD_URL="https://github.com/systemd/systemd/archive/refs/tags/v${SYSTEMD_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}
|
||||
|
||||
KERNEL_SRC_DIR="$SOURCE_DIR/linux-${KERNEL_VERSION}"
|
||||
BUSYBOX_SRC_DIR="$SOURCE_DIR/busybox-${BUSYBOX_VERSION}"
|
||||
SYSTEMD_SRC_DIR="$SOURCE_DIR/systemd-${SYSTEMD_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}"
|
||||
BUSYBOX_INSTALL_DIR="$BUILD_DIR/busybox-rootfs"
|
||||
SYSTEMD_BUILD_DIR="$BUILD_DIR/systemd-${SYSTEMD_VERSION}"
|
||||
SYSTEMD_INSTALL_DIR="$BUILD_DIR/systemd-rootfs"
|
||||
MODULES_STAGING_DIR="$STAGING_DIR/modules"
|
||||
ROOTFS_STAGING_DIR="$STAGING_DIR/rootfs"
|
||||
|
||||
|
||||
@@ -4,13 +4,17 @@ set -euo pipefail
|
||||
|
||||
source "$(dirname "$0")/common.sh"
|
||||
|
||||
require_cmd curl tar
|
||||
require_cmd curl tar bzip2 gzip xz
|
||||
ensure_dirs
|
||||
|
||||
download "$KERNEL_URL" "$DOWNLOAD_DIR/$KERNEL_TARBALL"
|
||||
download "$BUSYBOX_URL" "$DOWNLOAD_DIR/$BUSYBOX_TARBALL"
|
||||
download "$SYSTEMD_URL" "$DOWNLOAD_DIR/$SYSTEMD_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_into "$DOWNLOAD_DIR/$NIX_TARBALL" "$NIX_SRC_DIR"
|
||||
|
||||
msg "sources are ready"
|
||||
+12
-9
@@ -11,6 +11,7 @@ CHECK_ONLY=0
|
||||
packages=(
|
||||
build-essential
|
||||
gcc-aarch64-linux-gnu
|
||||
binutils-aarch64-linux-gnu
|
||||
bc
|
||||
bison
|
||||
flex
|
||||
@@ -33,10 +34,6 @@ packages=(
|
||||
kmod
|
||||
openssl
|
||||
libelf-dev
|
||||
mmdebstrap
|
||||
debootstrap
|
||||
qemu-user-static
|
||||
binfmt-support
|
||||
qemu-system-arm
|
||||
)
|
||||
|
||||
@@ -44,6 +41,7 @@ required_commands=(
|
||||
bash
|
||||
make
|
||||
aarch64-linux-gnu-gcc
|
||||
aarch64-linux-gnu-readelf
|
||||
curl
|
||||
git
|
||||
tar
|
||||
@@ -69,7 +67,7 @@ usage() {
|
||||
cat <<EOF
|
||||
Usage: scripts/install-deps.sh [options]
|
||||
|
||||
Install Debian/Ubuntu host packages needed for:
|
||||
Install host packages needed for:
|
||||
make rootfs
|
||||
make run
|
||||
|
||||
@@ -80,8 +78,13 @@ Options:
|
||||
--help Show this help.
|
||||
|
||||
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.
|
||||
It installs the AArch64 cross compiler, kernel/BusyBox/systemd build tools,
|
||||
and qemu-system-aarch64 for the ARM64 systemd + Nix console build.
|
||||
|
||||
The systemd source build also needs target ARM64 development libraries visible
|
||||
through pkg-config. On Debian-style hosts this usually means enabling arm64
|
||||
multiarch and installing the required :arm64 -dev packages, or setting
|
||||
SYSTEMD_PKG_CONFIG_LIBDIR/SYSTEMD_RUNTIME_LIB_DIRS to a prepared ARM64 sysroot.
|
||||
EOF
|
||||
}
|
||||
|
||||
@@ -175,7 +178,7 @@ else
|
||||
"${sudo_cmd[@]}" apt-get update
|
||||
fi
|
||||
|
||||
msg "installing ForgeOS rootfs/run dependencies"
|
||||
msg "installing ForgeOS systemd/Nix build/run dependencies"
|
||||
"${sudo_cmd[@]}" apt-get install -y --no-install-recommends "${missing_packages[@]}"
|
||||
fi
|
||||
fi
|
||||
@@ -193,5 +196,5 @@ if [[ "${#missing_commands[@]}" -gt 0 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
msg "host dependencies are ready for make rootfs and make run"
|
||||
msg "host dependencies are ready for systemd/Nix make rootfs and make run"
|
||||
msg "project: $ROOT_DIR"
|
||||
@@ -24,6 +24,7 @@ required_commands=(
|
||||
parted
|
||||
mkfs.vfat
|
||||
mkfs.ext4
|
||||
debugfs
|
||||
mcopy
|
||||
mmd
|
||||
grub-mkstandalone
|
||||
@@ -43,7 +44,7 @@ usage() {
|
||||
cat <<EOF
|
||||
Usage: scripts/install-image-deps.sh [options]
|
||||
|
||||
Install Debian/Ubuntu host packages needed for:
|
||||
Install host packages needed for:
|
||||
make image
|
||||
make run-image
|
||||
|
||||
@@ -53,10 +54,9 @@ Options:
|
||||
--no-update Skip apt-get update before installing.
|
||||
--help Show this help.
|
||||
|
||||
This script first checks the console rootfs/run dependencies through
|
||||
This script first checks the systemd/Nix rootfs/run dependencies through
|
||||
scripts/install-deps.sh, then installs the extra disk image and UEFI QEMU
|
||||
dependencies. It does not install GNOME, host installer, or Secure Boot
|
||||
signing extras.
|
||||
dependencies. It does not install host installer or Secure Boot signing extras.
|
||||
EOF
|
||||
}
|
||||
|
||||
|
||||
+2
-58
@@ -44,7 +44,7 @@ case "$MODE" in
|
||||
-serial mon:stdio \
|
||||
-kernel "$KERNEL_IMAGE" \
|
||||
-initrd "$OUT_DIR/rootfs.cpio.gz" \
|
||||
-append "console=$SERIAL_CONSOLE rdinit=/sbin/init loglevel=4" \
|
||||
-append "console=$SERIAL_CONSOLE rdinit=/init loglevel=4" \
|
||||
-device virtio-rng-pci
|
||||
;;
|
||||
image)
|
||||
@@ -95,63 +95,7 @@ case "$MODE" in
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
image-gui)
|
||||
UEFI_MODE=$(find_uefi_mode) || die "no usable UEFI firmware found"
|
||||
[[ -f "$IMAGE_PATH" ]] || "$ROOT_DIR/scripts/build-image.sh"
|
||||
|
||||
case "$UEFI_MODE" in
|
||||
bios:*)
|
||||
FIRMWARE=${UEFI_MODE#bios:}
|
||||
exec "$QEMU_SYSTEM" \
|
||||
-machine "$QEMU_MACHINE" \
|
||||
-m "$MEMORY_MB" \
|
||||
-smp "$SMP_CPUS" \
|
||||
-cpu "$QEMU_CPU" \
|
||||
-serial mon:stdio \
|
||||
-display "$QEMU_DISPLAY" \
|
||||
-boot order=c \
|
||||
-bios "$FIRMWARE" \
|
||||
-drive file="$IMAGE_PATH",format=raw,if=virtio \
|
||||
-device virtio-gpu-pci \
|
||||
-device qemu-xhci \
|
||||
-device usb-tablet \
|
||||
-device usb-kbd \
|
||||
-device virtio-rng-pci \
|
||||
-netdev user,id=net0 \
|
||||
-device virtio-net-pci,netdev=net0
|
||||
;;
|
||||
pflash:*)
|
||||
CODE_FD=${UEFI_MODE#pflash:}
|
||||
CODE_FD=${CODE_FD%%:*}
|
||||
VARS_FD=${UEFI_MODE##*:}
|
||||
VARS_COPY=$(mktemp /tmp/forgeos-aavmf-vars.XXXXXX.fd)
|
||||
cp "$VARS_FD" "$VARS_COPY"
|
||||
"$QEMU_SYSTEM" \
|
||||
-machine "$QEMU_MACHINE" \
|
||||
-m "$MEMORY_MB" \
|
||||
-smp "$SMP_CPUS" \
|
||||
-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-gpu-pci \
|
||||
-device qemu-xhci \
|
||||
-device usb-tablet \
|
||||
-device usb-kbd \
|
||||
-device virtio-rng-pci \
|
||||
-netdev user,id=net0 \
|
||||
-device virtio-net-pci,netdev=net0
|
||||
rm -f "$VARS_COPY"
|
||||
;;
|
||||
*)
|
||||
die "unsupported UEFI mode: $UEFI_MODE"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
die "usage: $0 {direct|image|image-gui}"
|
||||
die "usage: $0 {direct|image}"
|
||||
;;
|
||||
esac
|
||||
@@ -4,11 +4,11 @@ set -euo pipefail
|
||||
|
||||
source "$(dirname "$0")/common.sh"
|
||||
|
||||
require_cmd chmod find head install ln mkdir rsync sort tar
|
||||
require_cmd chmod find head install ln mkdir rsync sort
|
||||
ensure_dirs
|
||||
|
||||
[[ "$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"
|
||||
[[ "$ARCH" == "arm64" ]] || die "Nix staging currently supports ARCH=arm64 only"
|
||||
[[ "$NIX_SYSTEM" == "aarch64-linux" ]] || die "Nix 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
|
||||
@@ -67,10 +67,6 @@ for tool in nix nix-build nix-channel nix-collect-garbage nix-copy-closure nix-d
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -e "$ROOTFS_STAGING_DIR/usr/sbin/nologin" ]]; then
|
||||
ln -sfn ../usr/sbin/nologin "$ROOTFS_STAGING_DIR/sbin/nologin"
|
||||
fi
|
||||
|
||||
cat > "$ROOTFS_STAGING_DIR/etc/nix/nix.conf" <<'EOF'
|
||||
build-users-group = nixbld
|
||||
allowed-users = *
|
||||
|
||||
Reference in new issue
Block a user