Complete from-scratch Linux distribution targeting AMD Ryzen 9 9950X3D + NVIDIA RTX 5090 on ASUS ROG CROSSHAIR X870E HERO. Deliverables: - dpack: custom package manager in Rust (3,800 lines) - TOML package parser, dependency resolver, build sandbox - CRUX Pkgfile and Gentoo ebuild converters - Shared library conflict detection - 124 package definitions across 4 repos (core/extra/desktop/gaming) - 34 toolchain bootstrap scripts (LFS 13.0 adapted for Zen 5) - Linux 6.19.8 kernel config (hardware-specific, fully commented) - SysVinit init system with rc.d service scripts - Live ISO builder (UEFI-only, squashfs+xorriso) - Interactive installer (GPT partitioning, EFISTUB boot) - Integration test checklist (docs/TESTING.md) No systemd. No bootloader. No display manager. Kernel boots via EFISTUB → auto-login → dwl Wayland compositor. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
92 lines
3.2 KiB
Bash
Executable File
92 lines
3.2 KiB
Bash
Executable File
#!/bin/bash
|
|
# ============================================================================
|
|
# DarkForge Linux — Phase 0, Chapter 7: Chroot Environment Setup
|
|
# ============================================================================
|
|
# Purpose: Prepare the virtual filesystems and enter the chroot environment.
|
|
# This script must be run as ROOT on the host system. It mounts
|
|
# /dev, /proc, /sys, /run into the LFS tree and enters the chroot.
|
|
# Inputs: LFS environment variable
|
|
# Outputs: Running chroot environment with virtual filesystems mounted
|
|
# Assumes: All Chapter 5+6 scripts (001-022) complete successfully
|
|
# Ref: LFS 13.0 §7.2-7.4
|
|
# ============================================================================
|
|
|
|
set -euo pipefail
|
|
|
|
LFS="${LFS:-/mnt/darkforge}"
|
|
|
|
echo "=== DarkForge: Setting up chroot environment ==="
|
|
|
|
# Verify we're running as root
|
|
if [ "$(id -u)" -ne 0 ]; then
|
|
echo "ERROR: This script must be run as root."
|
|
exit 1
|
|
fi
|
|
|
|
# Change ownership from lfs user to root
|
|
# (the chroot tools now belong to the system)
|
|
chown -R root:root "${LFS}"/{usr,lib,var,etc,bin,sbin,tools} 2>/dev/null || true
|
|
case $(uname -m) in
|
|
x86_64) chown -R root:root "${LFS}/lib64" ;;
|
|
esac
|
|
|
|
# --- Create essential directory structure ------------------------------------
|
|
mkdir -pv "${LFS}"/{dev,proc,sys,run}
|
|
mkdir -pv "${LFS}"/{boot,home,mnt,opt,srv}
|
|
mkdir -pv "${LFS}/etc"/{opt,sysconfig}
|
|
mkdir -pv "${LFS}/lib/firmware"
|
|
mkdir -pv "${LFS}/media"/{floppy,cdrom}
|
|
mkdir -pv "${LFS}/usr"/{,local/}{include,src}
|
|
mkdir -pv "${LFS}/usr/local"/{bin,lib,sbin}
|
|
mkdir -pv "${LFS}/usr"/{,local/}share/{color,dict,doc,info,locale,man}
|
|
mkdir -pv "${LFS}/usr"/{,local/}share/{misc,terminfo,zoneinfo}
|
|
mkdir -pv "${LFS}/usr"/{,local/}share/man/man{1..8}
|
|
mkdir -pv "${LFS}/var"/{cache,local,log,mail,opt,spool}
|
|
mkdir -pv "${LFS}/var/lib"/{color,misc,locate}
|
|
|
|
ln -sfv /run "${LFS}/var/run"
|
|
ln -sfv /run/lock "${LFS}/var/lock"
|
|
|
|
install -dv -m 0750 "${LFS}/root"
|
|
install -dv -m 1777 "${LFS}/tmp" "${LFS}/var/tmp"
|
|
|
|
# --- Mount virtual kernel filesystems ----------------------------------------
|
|
# These expose the host kernel's interfaces inside the chroot
|
|
|
|
# Bind-mount /dev from host (gives us device nodes)
|
|
mount -v --bind /dev "${LFS}/dev"
|
|
|
|
# Mount devpts for pseudo-terminals
|
|
mount -vt devpts devpts -o gid=5,mode=0620 "${LFS}/dev/pts"
|
|
|
|
# Mount /proc (process info filesystem)
|
|
mount -vt proc proc "${LFS}/proc"
|
|
|
|
# Mount /sys (sysfs — kernel objects)
|
|
mount -vt sysfs sysfs "${LFS}/sys"
|
|
|
|
# Mount /run (tmpfs for runtime data)
|
|
mount -vt tmpfs tmpfs "${LFS}/run"
|
|
|
|
# Handle /dev/shm — some systems make it a symlink
|
|
if [ -h "${LFS}/dev/shm" ]; then
|
|
install -v -d -m 1777 "${LFS}/$(readlink "${LFS}/dev/shm")"
|
|
else
|
|
mount -vt tmpfs -o nosuid,nodev tmpfs "${LFS}/dev/shm"
|
|
fi
|
|
|
|
echo ""
|
|
echo "=== Virtual filesystems mounted ==="
|
|
echo ""
|
|
echo "To enter the chroot, run:"
|
|
echo ""
|
|
echo " chroot \"${LFS}\" /usr/bin/env -i \\"
|
|
echo " HOME=/root \\"
|
|
echo " TERM=\"\${TERM}\" \\"
|
|
echo " PS1='(darkforge chroot) \\u:\\w\\\$ ' \\"
|
|
echo " PATH=/usr/bin:/usr/sbin \\"
|
|
echo " MAKEFLAGS=\"-j32\" \\"
|
|
echo " /bin/bash --login"
|
|
echo ""
|
|
echo "Then run the chroot build scripts (024-xxx) from inside the chroot."
|