Initial commit: DarkForge Linux — Phases 0-12
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>
This commit is contained in:
111
toolchain/scripts/000-env-setup.sh
Executable file
111
toolchain/scripts/000-env-setup.sh
Executable file
@@ -0,0 +1,111 @@
|
||||
#!/bin/bash
|
||||
# ============================================================================
|
||||
# DarkForge Linux — Phase 0: Environment Setup
|
||||
# ============================================================================
|
||||
# Purpose: Set up the build environment, directory structure, and variables
|
||||
# needed for the cross-toolchain bootstrap.
|
||||
# Inputs: LFS - path to target partition (e.g., /mnt/darkforge)
|
||||
# Outputs: Environment variables, directory tree, lfs user
|
||||
# Assumes: Target partition is mounted at $LFS, running as root
|
||||
# Ref: LFS 13.0 Chapters 2-4
|
||||
# ============================================================================
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# --- Configuration -----------------------------------------------------------
|
||||
# These must be set before running this script.
|
||||
# Override via environment or edit here.
|
||||
LFS="${LFS:-/mnt/darkforge}"
|
||||
LFS_TGT="x86_64-darkforge-linux-gnu"
|
||||
|
||||
# DarkForge hardware-specific flags (applied in native builds, NOT cross-compile)
|
||||
DF_CFLAGS="-march=znver5 -O2 -pipe -fomit-frame-pointer"
|
||||
DF_CXXFLAGS="${DF_CFLAGS}"
|
||||
DF_MAKEFLAGS="-j32"
|
||||
DF_LDFLAGS="-Wl,-O1,--as-needed"
|
||||
|
||||
# --- Verify mount point ------------------------------------------------------
|
||||
if ! mountpoint -q "${LFS}" 2>/dev/null; then
|
||||
echo "ERROR: ${LFS} is not a mount point."
|
||||
echo "Mount the target partition first: mount /dev/<partition> ${LFS}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "=== DarkForge Phase 0: Environment Setup ==="
|
||||
echo "LFS=${LFS}"
|
||||
echo "LFS_TGT=${LFS_TGT}"
|
||||
|
||||
# --- Create directory structure -----------------------------------------------
|
||||
echo ">>> Creating directory structure..."
|
||||
mkdir -pv "${LFS}/sources"
|
||||
mkdir -pv "${LFS}/tools"
|
||||
mkdir -pv "${LFS}"/{etc,var,usr/{bin,lib,sbin}}
|
||||
|
||||
# Create /lib64 symlink for x86_64
|
||||
case $(uname -m) in
|
||||
x86_64) mkdir -pv "${LFS}/lib64" ;;
|
||||
esac
|
||||
|
||||
# Symlinks for unified /usr layout (LFS 13.0 style)
|
||||
for dir in bin lib sbin; do
|
||||
ln -sfv "usr/${dir}" "${LFS}/${dir}" 2>/dev/null || true
|
||||
done
|
||||
|
||||
# Set sticky bit on sources directory
|
||||
chmod -v a+wt "${LFS}/sources"
|
||||
|
||||
# --- Create lfs user (if not exists) ------------------------------------------
|
||||
echo ">>> Setting up 'lfs' build user..."
|
||||
if ! id lfs &>/dev/null; then
|
||||
groupadd lfs
|
||||
useradd -s /bin/bash -g lfs -m -k /dev/null lfs
|
||||
echo "Created 'lfs' user."
|
||||
else
|
||||
echo "'lfs' user already exists."
|
||||
fi
|
||||
|
||||
# Grant lfs ownership of build directories
|
||||
chown -v lfs "${LFS}"/{usr{,/*},lib,var,etc,bin,lib64,sbin,tools,sources} 2>/dev/null || true
|
||||
|
||||
# --- Write lfs user's shell profile -------------------------------------------
|
||||
echo ">>> Writing lfs shell profile..."
|
||||
cat > /home/lfs/.bash_profile << 'PROFILE_EOF'
|
||||
exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash
|
||||
PROFILE_EOF
|
||||
|
||||
cat > /home/lfs/.bashrc << BASHRC_EOF
|
||||
set +h
|
||||
umask 022
|
||||
LFS=${LFS}
|
||||
LC_ALL=POSIX
|
||||
LFS_TGT=${LFS_TGT}
|
||||
PATH=${LFS}/tools/bin:/usr/bin
|
||||
if [ ! -L /bin ]; then PATH=/bin:\$PATH; fi
|
||||
export LFS LC_ALL LFS_TGT PATH
|
||||
export MAKEFLAGS="${DF_MAKEFLAGS}"
|
||||
BASHRC_EOF
|
||||
|
||||
chown lfs:lfs /home/lfs/.bash_profile /home/lfs/.bashrc
|
||||
|
||||
# --- Write persistent environment config for other scripts --------------------
|
||||
cat > "${LFS}/sources/darkforge-env.sh" << ENV_EOF
|
||||
# DarkForge build environment — sourced by all toolchain scripts
|
||||
export LFS="${LFS}"
|
||||
export LFS_TGT="${LFS_TGT}"
|
||||
export LC_ALL=POSIX
|
||||
export PATH="${LFS}/tools/bin:/usr/bin"
|
||||
if [ ! -L /bin ]; then export PATH="/bin:\${PATH}"; fi
|
||||
export MAKEFLAGS="${DF_MAKEFLAGS}"
|
||||
|
||||
# Hardware-specific flags (only for native compilation, NOT cross-compile)
|
||||
export DF_CFLAGS="${DF_CFLAGS}"
|
||||
export DF_CXXFLAGS="${DF_CXXFLAGS}"
|
||||
export DF_LDFLAGS="${DF_LDFLAGS}"
|
||||
ENV_EOF
|
||||
|
||||
echo "=== Environment setup complete ==="
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo " 1. Download source tarballs to ${LFS}/sources/"
|
||||
echo " 2. Switch to lfs user: su - lfs"
|
||||
echo " 3. Run toolchain build scripts in order (001, 002, ...)"
|
||||
Reference in New Issue
Block a user