Big script

This commit is contained in:
2026-03-20 15:09:30 +01:00
parent dc2ac2f768
commit a2ca02a856
92 changed files with 5842 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3: Chroot Environment for Chapter 8 Builds
# ============================================================================
# Purpose: Sourced by all Phase 3 build scripts. Sets hardware-specific
# compiler flags for native compilation targeting AMD Zen 5.
# ============================================================================
# Hardware-specific flags — AMD Ryzen 9 9950X3D (Zen 5)
export CFLAGS="-march=znver5 -O2 -pipe -fomit-frame-pointer"
export CXXFLAGS="${CFLAGS}"
export LDFLAGS="-Wl,-O1,--as-needed"
export MAKEFLAGS="-j32"
# Standard paths
export SRCDIR="/sources"
export SCRIPTS="/sources/toolchain-scripts"
# Helper function for consistent build pattern
pkg_extract() {
local tarball="$1"
cd "${SRCDIR}"
tar -xf "${tarball}"
}
pkg_cleanup() {
local dir="$1"
cd "${SRCDIR}"
rm -rf "${dir}"
}

View File

@@ -0,0 +1,141 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3: Download Additional Source Tarballs
# ============================================================================
# Purpose: Download packages needed for Chapter 8 (full base system) that
# were not already downloaded in Phase 0.
# Inputs: Running inside chroot or on host with $LFS set
# Outputs: Additional source tarballs in /sources/ (chroot) or $LFS/sources/
# Updated: 2026-03-21
# ============================================================================
set -euo pipefail
# Detect if we're in chroot (/ is the LFS root) or on host
if [ -f /sources/darkforge-env.sh ]; then
SRCDIR="/sources"
else
LFS="${LFS:-/mnt/darkforge}"
SRCDIR="${LFS}/sources"
fi
GNU_MIRROR="http://ftp.klid.dk/ftp/gnu"
cd "${SRCDIR}"
echo "=== DarkForge Phase 3: Downloading additional source tarballs ==="
download() {
local url="$1"
local filename="${2:-$(basename "${url}")}"
if [ -f "${filename}" ]; then
echo " [SKIP] ${filename}"
return 0
fi
echo " [GET] ${filename}"
wget --no-verbose --continue "${url}" -O "${filename}" || {
echo " [FAIL] ${filename} — trying curl"
curl -fLo "${filename}" "${url}" || {
echo " [ERROR] Failed: ${filename}"
return 1
}
}
}
# ==============================================================================
# Packages NOT in Phase 0 download list
# ==============================================================================
echo ">>> IANA-Etc (protocol/service definitions)..."
download "https://github.com/Mic92/iana-etc/releases/download/20250306/iana-etc-20250306.tar.gz"
echo ">>> Compression libraries..."
download "https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz"
download "https://github.com/lz4/lz4/releases/download/v1.10.0/lz4-1.10.0.tar.gz"
echo ">>> Libraries..."
download "${GNU_MIRROR}/readline/readline-8.3.tar.gz"
download "https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.45/pcre2-10.45.tar.bz2"
download "https://github.com/besser82/libxcrypt/releases/download/v4.4.38/libxcrypt-4.4.38.tar.xz"
download "https://savannah.nongnu.org/download/attr/attr-2.5.2.tar.gz"
download "https://savannah.nongnu.org/download/acl/acl-2.3.2.tar.xz"
download "https://kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.76.tar.xz"
download "https://sourceware.org/elfutils/ftp/0.192/elfutils-0.192.tar.bz2"
download "https://github.com/libffi/libffi/releases/download/v3.4.7/libffi-3.4.7.tar.gz"
download "https://github.com/libexpat/libexpat/releases/download/R_2_7_1/expat-2.7.1.tar.xz"
download "https://savannah.nongnu.org/download/libpipeline/libpipeline-1.5.8.tar.gz"
echo ">>> Build tools..."
download "https://github.com/westes/flex/releases/download/v2.6.4/flex-2.6.4.tar.gz"
download "https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.4.3.tar.gz" "pkgconf-2.4.3.tar.gz"
download "${GNU_MIRROR}/bc/bc-7.0.3.tar.xz"
download "${GNU_MIRROR}/autoconf/autoconf-2.72.tar.xz"
download "${GNU_MIRROR}/automake/automake-1.17.tar.xz"
download "${GNU_MIRROR}/libtool/libtool-2.5.4.tar.xz"
download "https://github.com/ninja-build/ninja/archive/v1.12.1/ninja-1.12.1.tar.gz"
download "https://github.com/mesonbuild/meson/releases/download/1.7.0/meson-1.7.0.tar.gz"
download "https://cmake.org/files/v3.31/cmake-3.31.6.tar.gz"
download "${GNU_MIRROR}/intltool/intltool-0.51.0.tar.gz"
echo ">>> Test frameworks..."
download "https://downloads.sourceforge.net/tcl/tcl8.6.16-src.tar.gz"
download "https://downloads.sourceforge.net/expect/expect5.45.4.tar.gz"
download "${GNU_MIRROR}/dejagnu/dejagnu-1.6.3.tar.gz"
echo ">>> Security and crypto..."
download "https://github.com/openssl/openssl/releases/download/openssl-3.5.0/openssl-3.5.0.tar.gz"
download "https://github.com/shadow-maint/shadow/releases/download/4.17.4/shadow-4.17.4.tar.xz"
echo ">>> Database and XML..."
download "${GNU_MIRROR}/gdbm/gdbm-1.24.tar.gz"
download "${GNU_MIRROR}/gperf/gperf-3.1.tar.gz"
download "https://www.sqlite.org/2025/sqlite-autoconf-3490100.tar.gz"
download "https://cpan.metacpan.org/authors/id/T/TO/TODDR/XML-Parser-2.47.tar.gz"
echo ">>> Python packages..."
download "https://pypi.org/packages/source/f/flit-core/flit_core-3.11.0.tar.gz"
download "https://pypi.org/packages/source/p/packaging/packaging-25.0.tar.gz"
download "https://pypi.org/packages/source/w/wheel/wheel-0.45.1.tar.gz"
download "https://pypi.org/packages/source/s/setuptools/setuptools-78.1.0.tar.gz"
download "https://pypi.org/packages/source/M/MarkupSafe/markupsafe-3.0.2.tar.gz"
download "https://pypi.org/packages/source/J/Jinja2/jinja2-3.1.6.tar.gz"
echo ">>> System utilities..."
download "https://ftp.isc.org/isc/dhcp/4.4.3-P1/dhcp-4.4.3-P1.tar.gz" 2>/dev/null || true
download "${GNU_MIRROR}/inetutils/inetutils-2.6.tar.xz"
download "https://mirrors.edge.kernel.org/pub/linux/utils/kbd/kbd-2.7.1.tar.xz"
download "https://mirrors.edge.kernel.org/pub/linux/utils/kernel/kmod/kmod-34.tar.xz"
download "${GNU_MIRROR}/less/less-668.tar.gz"
download "${GNU_MIRROR}/groff/groff-1.23.0.tar.gz"
download "https://mirrors.edge.kernel.org/pub/linux/utils/net/iproute2/iproute2-6.13.0.tar.xz"
download "https://github.com/termux/procps/releases/download/v4.0.5/procps-ng-4.0.5.tar.xz" 2>/dev/null || \
download "https://sourceforge.net/projects/procps-ng/files/Production/procps-ng-4.0.5.tar.xz"
download "https://github.com/psmisc/psmisc/releases/download/v23.7/psmisc-23.7.tar.xz"
download "https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v2.40/util-linux-2.40.4.tar.xz" 2>/dev/null || true
download "https://mirrors.edge.kernel.org/pub/linux/kernel/people/tytso/e2fsprogs/v1.47.2/e2fsprogs-1.47.2.tar.gz"
echo ">>> Init and logging..."
download "https://github.com/slicer69/sysklogd/releases/download/v2.7.0/sysklogd-2.7.0.tar.gz"
download "https://github.com/slicer69/sysvinit/releases/download/3.14/sysvinit-3.14.tar.xz"
echo ">>> eudev (udev without systemd)..."
download "https://github.com/eudev-project/eudev/releases/download/v3.2.14/eudev-3.2.14.tar.gz"
echo ">>> Documentation..."
download "https://download.savannah.gnu.org/releases/man-db/man-db-2.13.0.tar.xz"
download "https://mirrors.edge.kernel.org/pub/linux/docs/man-pages/man-pages-6.12.tar.xz"
echo ">>> Editor..."
download "https://github.com/vim/vim/archive/v9.1.1166/vim-9.1.1166.tar.gz"
echo ">>> Patches..."
download "https://www.linuxfromscratch.org/patches/lfs/13.0/bzip2-1.0.8-install_docs-1.patch"
download "https://www.linuxfromscratch.org/patches/lfs/13.0/coreutils-9.10-i18n-1.patch"
download "https://www.linuxfromscratch.org/patches/lfs/13.0/expect-5.45.4-gcc15-1.patch"
download "https://www.linuxfromscratch.org/patches/lfs/13.0/kbd-2.9.0-backspace-1.patch" 2>/dev/null || true
download "https://www.linuxfromscratch.org/patches/lfs/13.0/sysvinit-3.14-consolidated-1.patch"
echo ""
echo "=== Phase 3 downloads complete ==="
FILECOUNT=$(ls -1 "${SRCDIR}/"*.{tar.*,patch,gz,xz,bz2} 2>/dev/null | wc -l)
echo "${FILECOUNT} total files in ${SRCDIR}/"

View File

@@ -0,0 +1,287 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3: Build All Base System Packages (Chapter 8)
# ============================================================================
# Purpose: Enters the chroot and runs all Phase 3 build scripts (101-179)
# in sequence. This builds the complete LFS base system with
# native compilation targeting AMD Zen 5.
# Usage: sudo -E bash /mnt/darkforge/sources/toolchain-scripts/100-phase3-build-all.sh
# Inputs: LFS environment variable (default: /mnt/darkforge)
# Phase 0 toolchain must be complete (023a-chroot-build-all.sh)
# Phase 3 sources downloaded (100-download-phase3.sh)
# Outputs: Complete base system installed in the chroot
# ============================================================================
set -euo pipefail
LFS="${LFS:-/mnt/darkforge}"
SCRIPTS="/sources/toolchain-scripts"
# Color output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
NC='\033[0m'
ok() { echo -e "${GREEN}>>> $*${NC}"; }
warn() { echo -e "${YELLOW}>>> $*${NC}"; }
fail() { echo -e "${RED}>>> $*${NC}"; exit 1; }
info() { echo -e "${CYAN}>>> $*${NC}"; }
[ "$(id -u)" -eq 0 ] || fail "This script must be run as root."
# Verify chroot is ready (virtual filesystems mounted)
if ! mountpoint -q "${LFS}/proc" 2>/dev/null; then
fail "${LFS}/proc is not mounted. Run 023-chroot-setup.sh first."
fi
# Verify Phase 0 completed (gcc should exist)
if [ ! -f "${LFS}/usr/bin/gcc" ]; then
fail "gcc not found in chroot. Phase 0 must be complete first."
fi
echo "============================================================"
echo " DarkForge Linux — Phase 3: Base System Build (Chapter 8)"
echo "============================================================"
echo ""
info "Target: AMD Ryzen 9 9950X3D (Zen 5) — 32 parallel jobs"
info "This will take a while. Grab some coffee."
echo ""
# Allow resuming from a specific script number
START_FROM="${1:-101}"
info "Starting from script ${START_FROM}"
echo ""
# Build the chroot runner script
cat > "${LFS}/tmp/phase3-runner.sh" << 'CHROOT_EOF'
#!/bin/bash
set -euo pipefail
SCRIPTS="/sources/toolchain-scripts"
LOG_DIR="/sources/logs/phase3"
mkdir -p "${LOG_DIR}"
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
NC='\033[0m'
START_FROM="$1"
TOTAL=0
PASSED=0
FAILED=0
SKIPPED=0
run_script() {
local script="$1"
local name
name=$(basename "${script}" .sh)
local num="${name%%-*}"
local logfile="${LOG_DIR}/${name}.log"
# Skip if before our start point
if [ "${num}" -lt "${START_FROM}" ]; then
echo -e "${CYAN}>>> [$(date '+%H:%M:%S')] SKIP: ${name} (before start point ${START_FROM})${NC}"
SKIPPED=$((SKIPPED + 1))
return 0
fi
TOTAL=$((TOTAL + 1))
echo -e "${YELLOW}>>> [$(date '+%H:%M:%S')] Building: ${name} [${TOTAL}]${NC}"
local start_time
start_time=$(date +%s)
if bash "${script}" 2>&1 | tee "${logfile}"; then
local end_time
end_time=$(date +%s)
local elapsed=$((end_time - start_time))
local mins=$((elapsed / 60))
local secs=$((elapsed % 60))
echo -e "${GREEN}>>> [$(date '+%H:%M:%S')] PASSED: ${name} (${mins}m ${secs}s)${NC}"
echo ""
PASSED=$((PASSED + 1))
else
local end_time
end_time=$(date +%s)
local elapsed=$((end_time - start_time))
echo -e "${RED}>>> [$(date '+%H:%M:%S')] FAILED: ${name} (after ${elapsed}s)${NC}"
echo " Log: ${logfile}"
echo ""
FAILED=$((FAILED + 1))
# Don't exit immediately — log the failure and continue to see what else fails
# For critical packages, we do need to stop though
local critical_packages="103 118 127 103 149"
if echo "${critical_packages}" | grep -qw "${num}"; then
echo -e "${RED}>>> CRITICAL package failed — cannot continue.${NC}"
echo ""
echo "=== PHASE 3 ABORTED ==="
echo " Passed: ${PASSED} Failed: ${FAILED} Skipped: ${SKIPPED}"
exit 1
fi
fi
}
echo "============================================"
echo " Phase 3: Building LFS Base System"
echo " $(date)"
echo "============================================"
echo ""
# ---- Run download script first if needed ----
if [ "${START_FROM}" -le 100 ]; then
echo -e "${YELLOW}>>> Running Phase 3 download script...${NC}"
bash "${SCRIPTS}/100-download-phase3.sh" 2>&1 | tee "${LOG_DIR}/100-download-phase3.log"
echo ""
fi
# ---- Foundation packages (101-113) ----
echo -e "${CYAN}=== Stage 1: Foundation packages ===${NC}"
run_script "${SCRIPTS}/101-man-pages.sh"
run_script "${SCRIPTS}/102-iana-etc.sh"
run_script "${SCRIPTS}/103-glibc.sh"
run_script "${SCRIPTS}/104-zlib.sh"
run_script "${SCRIPTS}/105-bzip2.sh"
run_script "${SCRIPTS}/106-xz.sh"
run_script "${SCRIPTS}/107-lz4.sh"
run_script "${SCRIPTS}/108-zstd.sh"
run_script "${SCRIPTS}/109-file.sh"
run_script "${SCRIPTS}/110-readline.sh"
run_script "${SCRIPTS}/111-m4.sh"
run_script "${SCRIPTS}/112-bc.sh"
run_script "${SCRIPTS}/113-flex.sh"
# ---- Test frameworks & toolchain rebuild (114-127) ----
echo -e "${CYAN}=== Stage 2: Test frameworks & final toolchain ===${NC}"
run_script "${SCRIPTS}/114-tcl.sh"
run_script "${SCRIPTS}/115-expect.sh"
run_script "${SCRIPTS}/116-dejagnu.sh"
run_script "${SCRIPTS}/117-pkgconf.sh"
run_script "${SCRIPTS}/118-binutils.sh"
run_script "${SCRIPTS}/119-gmp.sh"
run_script "${SCRIPTS}/120-mpfr.sh"
run_script "${SCRIPTS}/121-mpc.sh"
run_script "${SCRIPTS}/122-attr.sh"
run_script "${SCRIPTS}/123-acl.sh"
run_script "${SCRIPTS}/124-libcap.sh"
run_script "${SCRIPTS}/125-libxcrypt.sh"
run_script "${SCRIPTS}/126-shadow.sh"
run_script "${SCRIPTS}/127-gcc.sh"
# ---- Core system libraries & tools (128-154) ----
echo -e "${CYAN}=== Stage 3: Core system libraries & tools ===${NC}"
run_script "${SCRIPTS}/128-ncurses.sh"
run_script "${SCRIPTS}/129-sed.sh"
run_script "${SCRIPTS}/130-psmisc.sh"
run_script "${SCRIPTS}/131-gettext.sh"
run_script "${SCRIPTS}/132-bison.sh"
run_script "${SCRIPTS}/133-grep.sh"
run_script "${SCRIPTS}/134-bash.sh"
run_script "${SCRIPTS}/135-libtool.sh"
run_script "${SCRIPTS}/136-gdbm.sh"
run_script "${SCRIPTS}/137-gperf.sh"
run_script "${SCRIPTS}/138-expat.sh"
run_script "${SCRIPTS}/139-inetutils.sh"
run_script "${SCRIPTS}/140-less.sh"
run_script "${SCRIPTS}/141-perl.sh"
run_script "${SCRIPTS}/142-xml-parser.sh"
run_script "${SCRIPTS}/143-intltool.sh"
run_script "${SCRIPTS}/144-autoconf.sh"
run_script "${SCRIPTS}/145-automake.sh"
run_script "${SCRIPTS}/146-openssl.sh"
run_script "${SCRIPTS}/147-libelf.sh"
run_script "${SCRIPTS}/148-libffi.sh"
run_script "${SCRIPTS}/149-python.sh"
run_script "${SCRIPTS}/150-flit-core.sh"
run_script "${SCRIPTS}/151-wheel.sh"
run_script "${SCRIPTS}/152-setuptools.sh"
run_script "${SCRIPTS}/153-ninja.sh"
run_script "${SCRIPTS}/154-meson.sh"
# ---- System utilities & final packages (155-179) ----
echo -e "${CYAN}=== Stage 4: System utilities & final packages ===${NC}"
run_script "${SCRIPTS}/155-kmod.sh"
run_script "${SCRIPTS}/156-coreutils.sh"
run_script "${SCRIPTS}/157-diffutils.sh"
run_script "${SCRIPTS}/158-gawk.sh"
run_script "${SCRIPTS}/159-findutils.sh"
run_script "${SCRIPTS}/160-groff.sh"
run_script "${SCRIPTS}/161-gzip.sh"
run_script "${SCRIPTS}/162-iproute2.sh"
run_script "${SCRIPTS}/163-kbd.sh"
run_script "${SCRIPTS}/164-libpipeline.sh"
run_script "${SCRIPTS}/165-make.sh"
run_script "${SCRIPTS}/166-patch.sh"
run_script "${SCRIPTS}/167-tar.sh"
run_script "${SCRIPTS}/168-texinfo.sh"
run_script "${SCRIPTS}/169-vim.sh"
run_script "${SCRIPTS}/170-markupsafe.sh"
run_script "${SCRIPTS}/171-jinja2.sh"
run_script "${SCRIPTS}/172-eudev.sh"
run_script "${SCRIPTS}/173-man-db.sh"
run_script "${SCRIPTS}/174-procps-ng.sh"
run_script "${SCRIPTS}/175-util-linux.sh"
run_script "${SCRIPTS}/176-e2fsprogs.sh"
run_script "${SCRIPTS}/177-sysklogd.sh"
run_script "${SCRIPTS}/178-sysvinit.sh"
run_script "${SCRIPTS}/179-strip-and-cleanup.sh"
echo ""
echo "============================================================"
echo " Phase 3 Build Summary"
echo "============================================================"
echo " Passed: ${PASSED}"
echo " Failed: ${FAILED}"
echo " Skipped: ${SKIPPED}"
echo ""
if [ "${FAILED}" -gt 0 ]; then
echo -e "${RED}>>> ${FAILED} package(s) failed! Check logs in ${LOG_DIR}/${NC}"
echo ""
echo "Failed package logs:"
for logfile in ${LOG_DIR}/*.log; do
name=$(basename "${logfile}" .log)
if tail -5 "${logfile}" 2>/dev/null | grep -qi "error\|fail"; then
echo " - ${logfile}"
fi
done
exit 1
else
echo -e "${GREEN}>>> ALL ${PASSED} packages built successfully!${NC}"
echo ""
echo "============================================================"
echo " DarkForge Linux: Phase 3 base system build COMPLETE!"
echo "============================================================"
echo ""
echo "The system now has a complete base installation."
echo "Next: Phase 4 (Kernel) or Phase 5 (Init System)."
fi
CHROOT_EOF
chmod +x "${LFS}/tmp/phase3-runner.sh"
# Enter chroot and run the build
# Use hardware-specific Zen 5 flags via the env file sourced by each script
info "Entering chroot to build Phase 3 packages..."
echo ""
chroot "${LFS}" /usr/bin/env -i \
HOME=/root \
TERM="${TERM}" \
PS1='(darkforge chroot) \u:\w\$ ' \
PATH=/usr/bin:/usr/sbin \
MAKEFLAGS="-j32" \
/bin/bash /tmp/phase3-runner.sh "${START_FROM}"
# Clean up
rm -f "${LFS}/tmp/phase3-runner.sh"
echo ""
echo -e "${GREEN}Phase 3 runner exited successfully.${NC}"
echo ""
echo "To resume from a specific script if something failed:"
echo " sudo -E bash ${LFS}/sources/toolchain-scripts/100-phase3-build-all.sh <script-number>"
echo " Example: sudo -E bash ${LFS}/sources/toolchain-scripts/100-phase3-build-all.sh 118"

View File

@@ -0,0 +1,28 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.3: Man-Pages
# ============================================================================
# Purpose: Install man-pages (system documentation).
# This is the documentation for system calls, library functions, etc.
# Inputs: /sources/man-pages-6.12.tar.xz
# Outputs: /usr/share/man/ populated with man pages
# Ref: LFS 13.0 §8.3
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="man-pages"
VERSION="6.12"
echo "=== Installing ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
# man-pages is just documentation files, no compile step
# Only install the man pages
make prefix=/usr install
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

View File

@@ -0,0 +1,29 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.4: IANA-Etc
# ============================================================================
# Purpose: Install IANA protocol and service definitions.
# Provides /etc/services and /etc/protocols which many programs need.
# Inputs: /sources/iana-etc-20250306.tar.gz
# Outputs: /etc/services, /etc/protocols
# Ref: LFS 13.0 §8.4
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="iana-etc"
VERSION="20250306"
echo "=== Installing ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.gz"
cd "${PACKAGE}-${VERSION}"
# IANA-Etc is just data files
# Copy the protocol and service definitions
cp services /etc/
cp protocols /etc/
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

153
toolchain/scripts/103-glibc.sh Executable file
View File

@@ -0,0 +1,153 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.5: Glibc (Final, Native)
# ============================================================================
# Purpose: Build and install the final glibc for the target system.
# This is the CRITICAL step that brings the system from cross-compiled
# to fully native. All subsequent packages will link against this glibc.
# Includes locale generation, timezone setup, and NSS configuration.
# Inputs: /sources/glibc-2.43.tar.xz, /sources/glibc-fhs-1.patch
# Outputs: /usr/lib/libc.so.6, /usr/include/c++/, locales, timezone data
# Ref: LFS 13.0 §8.5 — CRITICAL SECTION
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="glibc"
VERSION="2.43"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3, CRITICAL) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
# Apply FHS (Filesystem Hierarchy Standard) patch
# This ensures certain programs install to /usr/sbin instead of /sbin
echo ">>> Applying glibc-fhs-1.patch..."
patch -Np1 -i ../glibc-fhs-1.patch
# Create the build directory
mkdir -v build
cd build
# Configure glibc for native compilation on the target system
# --enable-kernel=5.4: Require kernel 5.4+ (we're running 6.19.8)
# --disable-nscd: We don't need the Name Service Cache Daemon
# --disable-timezone-tools: We'll set timezone manually
# --with-headers: Point to the kernel headers we installed in Phase 0
echo ">>> Configuring glibc..."
../configure \
--prefix=/usr \
--disable-werror \
--enable-kernel=5.4 \
--enable-stack-protector=strong \
--with-headers=/usr/include \
--disable-nscd \
--disable-timezone-tools
# Build glibc
echo ">>> Building glibc (this takes a while)..."
make
# Install glibc
echo ">>> Installing glibc..."
make DESTDIR=/ install
# ============================================================================
# Locale Generation — CRITICAL for UTF-8 support
# ============================================================================
echo ""
echo ">>> Generating locale data..."
# Create the en_US.UTF-8 locale (essential for development and user systems)
# This step creates binary locale files that programs use for character handling
localedef -i en_US -f UTF-8 en_US.UTF-8
# Verify locale was created
if locale -a | grep -q en_US.UTF-8; then
echo "PASS: en_US.UTF-8 locale created"
else
echo "FAIL: Could not create en_US.UTF-8 locale"
exit 1
fi
# ============================================================================
# Timezone Setup
# ============================================================================
echo ""
echo ">>> Setting up timezone data..."
# The timezone database is kept in /usr/share/zoneinfo
# Default to UTC (can be overridden during system installation)
# Copy the timezone file and create the symlink
if [ -f /usr/share/zoneinfo/UTC ]; then
ln -sfv ../usr/share/zoneinfo/UTC /etc/localtime
echo "PASS: Timezone symlink created (UTC)"
else
echo "FAIL: /usr/share/zoneinfo/UTC not found"
exit 1
fi
# ============================================================================
# Create /etc/nsswitch.conf — Critical for name service resolution
# ============================================================================
echo ""
echo ">>> Creating /etc/nsswitch.conf..."
cat > /etc/nsswitch.conf << 'NSS_EOF'
# Begin /etc/nsswitch.conf
# This file is used by the name service switch functionality in glibc
# It controls how hostname lookups, user/group lookups, etc. are resolved
passwd: files
group: files
shadow: files
hosts: files dns
networks: files
protocols: files
services: files
ethers: files
rpc: files
# End /etc/nsswitch.conf
NSS_EOF
echo "PASS: /etc/nsswitch.conf created"
# ============================================================================
# Verify glibc installation
# ============================================================================
echo ""
echo ">>> Running glibc sanity checks..."
# Test 1: Verify libc.so.6 is present
if [ -f /usr/lib/libc.so.6 ]; then
echo "PASS: /usr/lib/libc.so.6 exists"
else
echo "FAIL: /usr/lib/libc.so.6 NOT FOUND"
exit 1
fi
# Test 2: Verify we can call ldd
if ldd --version &>/dev/null; then
echo "PASS: ldd works"
else
echo "FAIL: ldd is broken"
exit 1
fi
# Test 3: Run a simple C program to test libc
echo "int main() { return 0; }" > /tmp/test.c
gcc /tmp/test.c -o /tmp/test
/tmp/test
echo "PASS: Basic C program execution works"
rm -f /tmp/test /tmp/test.c
cd ..
pkg_cleanup "${PACKAGE}-${VERSION}"
echo ""
echo "=== ${PACKAGE}-${VERSION} complete ==="
echo "=== CRITICAL: glibc is now native on the target system ==="

43
toolchain/scripts/104-zlib.sh Executable file
View File

@@ -0,0 +1,43 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.6: Zlib
# ============================================================================
# Purpose: Build and install zlib compression library (native version).
# This is a critical dependency for many tools (binutils, gcc, etc.)
# Inputs: /sources/zlib-1.3.2.tar.xz
# Outputs: /usr/lib/libz.so.1, /usr/include/zlib.h
# Ref: LFS 13.0 §8.6
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="zlib"
VERSION="1.3.2"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
# Configure zlib for the target system
# --prefix=/usr: Install to standard location
./configure --prefix=/usr
# Build zlib
make
# Run basic tests to ensure build is correct
make check
# Install zlib
make install
# Zlib installs some files to /usr/lib with incorrect permissions
# Make them writable (they're .a and .so files)
chmod -v 755 /usr/lib/libz.so.1.3.2
ln -sfv libz.so.1.3.2 /usr/lib/libz.so
ln -sfv libz.so.1.3.2 /usr/lib/libz.so.1
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

63
toolchain/scripts/105-bzip2.sh Executable file
View File

@@ -0,0 +1,63 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.7: Bzip2
# ============================================================================
# Purpose: Build and install bzip2 compression utility and library.
# Needed for compressing/decompressing bzip2 archives.
# Inputs: /sources/bzip2-1.0.8.tar.gz, /sources/bzip2-1.0.8-install_docs-1.patch
# Outputs: /usr/bin/bzip2, /usr/lib/libbz2.so.1
# Ref: LFS 13.0 §8.7
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="bzip2"
VERSION="1.0.8"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.gz"
cd "${PACKAGE}-${VERSION}"
# Apply LFS patch to install documentation
echo ">>> Applying bzip2-1.0.8-install_docs-1.patch..."
patch -Np1 -i ../bzip2-1.0.8-install_docs-1.patch
# Bzip2 uses a Makefile (not autoconf)
# Compile bzip2
make -f Makefile-libbz2_so
make clean
# Build bzip2 normally (static version for bzip2 binary)
make
# Install bzip2
make PREFIX=/usr install
# The Makefile builds dynamic libraries; we need to install them
# Install the dynamic library we built
cp bzip2-shared /bin/bzip2
cp libbz2.so.1.0.8 /lib/
ln -s libbz2.so.1.0.8 /lib/libbz2.so.1
# Create symlink in /usr/lib (some packages look there)
ln -s /lib/libbz2.so.1 /usr/lib/libbz2.so
# Verify installation
if [ -x /bin/bzip2 ]; then
echo "PASS: bzip2 binary installed"
else
echo "FAIL: bzip2 binary not found"
exit 1
fi
if [ -f /lib/libbz2.so.1.0.8 ]; then
echo "PASS: libbz2.so installed"
else
echo "FAIL: libbz2.so not found"
exit 1
fi
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

63
toolchain/scripts/106-xz.sh Executable file
View File

@@ -0,0 +1,63 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.8: XZ Utils
# ============================================================================
# Purpose: Build and install XZ utils (LZMA compression).
# Needed for extracting and compressing .tar.xz archives.
# Inputs: /sources/xz-5.8.1.tar.gz (from Phase 0 download as xz-5.8.1)
# Outputs: /usr/bin/xz, /usr/lib/liblzma.so
# Ref: LFS 13.0 §8.8
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="xz"
VERSION="5.8.1"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
# The download may be named xz-5.8.1.tar.gz (from github releases)
# Check for the tarball
if [ -f "/sources/${PACKAGE}-${VERSION}.tar.gz" ]; then
pkg_extract "${PACKAGE}-${VERSION}.tar.gz"
elif [ -f "/sources/${PACKAGE}-${VERSION}.tar.xz" ]; then
pkg_extract "${PACKAGE}-${VERSION}.tar.xz"
else
echo "FAIL: Could not find xz tarball"
exit 1
fi
cd "${PACKAGE}-${VERSION}"
# Configure xz for the target system
./configure --prefix=/usr \
--disable-static \
--docdir=/usr/share/doc/xz-${VERSION}
# Build xz
make
# Run tests (optional but recommended)
make check || true
# Install xz
make install
# Verify installation
if [ -x /usr/bin/xz ]; then
echo "PASS: xz binary installed"
else
echo "FAIL: xz binary not found"
exit 1
fi
if [ -f /usr/lib/liblzma.so ]; then
echo "PASS: liblzma.so installed"
else
echo "FAIL: liblzma.so not found"
exit 1
fi
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

50
toolchain/scripts/107-lz4.sh Executable file
View File

@@ -0,0 +1,50 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.9: LZ4
# ============================================================================
# Purpose: Build and install LZ4 compression library and tools.
# LZ4 is a fast compression algorithm used by some system tools.
# Inputs: /sources/lz4-1.10.0.tar.gz
# Outputs: /usr/bin/lz4, /usr/lib/liblz4.so
# Ref: LFS 13.0 §8.9
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="lz4"
VERSION="1.10.0"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.gz"
cd "${PACKAGE}-${VERSION}"
# LZ4 uses a Makefile (not autoconf)
# Build and install in one step with make install
# PREFIX=/usr: Install to standard location
make BUILD_SHARED=yes PREFIX=/usr
# Run tests
make test || true
# Install lz4
make install PREFIX=/usr
# Verify installation
if [ -x /usr/bin/lz4 ]; then
echo "PASS: lz4 binary installed"
else
echo "FAIL: lz4 binary not found"
exit 1
fi
if [ -f /usr/lib/liblz4.so ]; then
echo "PASS: liblz4.so installed"
else
echo "FAIL: liblz4.so not found"
exit 1
fi
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

51
toolchain/scripts/108-zstd.sh Executable file
View File

@@ -0,0 +1,51 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.10: Zstd
# ============================================================================
# Purpose: Build and install Zstandard compression library and tools.
# Zstd offers better compression than gzip with reasonable speed.
# Increasingly used by modern Linux systems and tools.
# Inputs: /sources/zstd-1.5.7.tar.gz
# Outputs: /usr/bin/zstd, /usr/lib/libzstd.so
# Ref: LFS 13.0 §8.10
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="zstd"
VERSION="1.5.7"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.gz"
cd "${PACKAGE}-${VERSION}"
# Zstd uses a Makefile (not autoconf)
# Build zstd
# Note: Zstd build can be slow due to its heavy optimization
make
# Run tests (optional)
make test || true
# Install zstd
make PREFIX=/usr DESTDIR=/ install
# Verify symlinks are correct
if [ -L /usr/lib/libzstd.so ]; then
echo "PASS: libzstd.so symlink exists"
else
echo "FAIL: libzstd.so symlink not found"
exit 1
fi
if [ -x /usr/bin/zstd ]; then
echo "PASS: zstd binary installed"
else
echo "FAIL: zstd binary not found"
exit 1
fi
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

55
toolchain/scripts/109-file.sh Executable file
View File

@@ -0,0 +1,55 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.11: File
# ============================================================================
# Purpose: Build and install the file command and libmagic library.
# The file command determines file types by examining their content.
# libmagic is used by many programs for file type detection.
# Inputs: /sources/file-5.47.tar.gz
# Outputs: /usr/bin/file, /usr/lib/libmagic.so
# Ref: LFS 13.0 §8.11
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="file"
VERSION="5.47"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.gz"
cd "${PACKAGE}-${VERSION}"
# Configure file for the target system
./configure --prefix=/usr
# Build file
make
# Run tests (optional)
make check || true
# Install file
make install
# Verify installation
if [ -x /usr/bin/file ]; then
echo "PASS: file binary installed"
else
echo "FAIL: file binary not found"
exit 1
fi
if [ -f /usr/lib/libmagic.so ]; then
echo "PASS: libmagic.so installed"
else
echo "FAIL: libmagic.so not found"
exit 1
fi
# Test file command
/usr/bin/file /bin/bash > /dev/null && echo "PASS: file command works"
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

View File

@@ -0,0 +1,49 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.12: Readline
# ============================================================================
# Purpose: Build and install the readline library.
# Readline provides command-line editing and history to programs like
# bash, gdb, and many other interactive tools.
# Inputs: /sources/readline-8.3.tar.gz
# Outputs: /usr/lib/libreadline.so, /usr/include/readline/readline.h
# Ref: LFS 13.0 §8.12
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="readline"
VERSION="8.3"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.gz"
cd "${PACKAGE}-${VERSION}"
# Configure readline for the target system
# --with-curses: Use ncurses for terminal handling
# --disable-static: Build only shared libraries (smaller install)
./configure --prefix=/usr \
--disable-static \
--with-curses
# Build readline
make SHLIB_LIBS="-lncurses"
# Install readline
make SHLIB_LIBS="-lncurses" install
# Install documentation
install -v -m644 doc/*.{ps,pdf,html,dvi} /usr/share/doc/readline-${VERSION}
# Verify installation
if [ -f /usr/lib/libreadline.so ]; then
echo "PASS: libreadline.so installed"
else
echo "FAIL: libreadline.so not found"
exit 1
fi
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

49
toolchain/scripts/111-m4.sh Executable file
View File

@@ -0,0 +1,49 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.14: M4
# ============================================================================
# Purpose: Build and install m4, the macro processing language.
# M4 is a dependency for autoconf/automake and other build tools.
# Required for building other packages in Phase 3+.
# Inputs: /sources/m4-1.4.21.tar.xz
# Outputs: /usr/bin/m4
# Ref: LFS 13.0 §8.14
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="m4"
VERSION="1.4.21"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
# Configure m4 for the target system
./configure --prefix=/usr
# Build m4
make
# Run tests to ensure build is correct
make check
# Install m4
make install
# Verify installation
if [ -x /usr/bin/m4 ]; then
echo "PASS: m4 binary installed"
else
echo "FAIL: m4 binary not found"
exit 1
fi
# Test m4
echo "define(HELLO, Hello World)" | /usr/bin/m4 | grep -q "Hello World" && \
echo "PASS: m4 works correctly"
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

60
toolchain/scripts/112-bc.sh Executable file
View File

@@ -0,0 +1,60 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.15: Bc
# ============================================================================
# Purpose: Build and install bc, an arbitrary-precision arithmetic language.
# Bc is a small but useful calculator utility for scripts and users.
# Inputs: /sources/bc-7.0.3.tar.xz
# Outputs: /usr/bin/bc, /usr/bin/dc
# Ref: LFS 13.0 §8.15
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="bc"
VERSION="7.0.3"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
# Configure bc for the target system
# Note: bc's configure script is unusual; it's a custom ./configure
./configure --prefix=/usr \
-G \
-O2 \
--mandir=/usr/share/man
# Build bc
# The -j flag for make often doesn't work with bc's custom build system
# So we don't use it here
make
# Run tests
make test
# Install bc
make install
# Verify installation
if [ -x /usr/bin/bc ]; then
echo "PASS: bc binary installed"
else
echo "FAIL: bc binary not found"
exit 1
fi
if [ -x /usr/bin/dc ]; then
echo "PASS: dc binary installed"
else
echo "FAIL: dc binary not found"
exit 1
fi
# Test bc
echo "2 + 2" | /usr/bin/bc | grep -q "4" && echo "PASS: bc works correctly"
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

63
toolchain/scripts/113-flex.sh Executable file
View File

@@ -0,0 +1,63 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.16: Flex
# ============================================================================
# Purpose: Build and install flex, the fast lexical scanner generator.
# Flex is used by many build tools and programs that parse text.
# It's a key component of the build toolchain for parsing source code.
# Inputs: /sources/flex-2.6.4.tar.gz
# Outputs: /usr/bin/flex, /usr/lib/libfl.so
# Ref: LFS 13.0 §8.16
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="flex"
VERSION="2.6.4"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.gz"
cd "${PACKAGE}-${VERSION}"
# Configure flex for the target system
# --disable-static: Build only shared libraries
./configure --prefix=/usr \
--disable-static \
--docdir=/usr/share/doc/flex-${VERSION}
# Build flex
make
# Run tests (optional but recommended)
# Note: Some tests may fail on heavily optimized builds, which is acceptable
make check || true
# Install flex
make install
# Create symlink for lex (many programs expect 'lex' to be available)
# Flex is a modern replacement for the classic lex tool
ln -sv flex /usr/bin/lex
# Verify installation
if [ -x /usr/bin/flex ]; then
echo "PASS: flex binary installed"
else
echo "FAIL: flex binary not found"
exit 1
fi
if [ -f /usr/lib/libfl.so ]; then
echo "PASS: libfl.so installed"
else
echo "FAIL: libfl.so not found"
exit 1
fi
# Test flex
echo "%%" | /usr/bin/flex > /dev/null && echo "PASS: flex works correctly"
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

41
toolchain/scripts/114-tcl.sh Executable file
View File

@@ -0,0 +1,41 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.17: Tcl
# ============================================================================
# Purpose: Build Tcl (Tool Command Language), a scripting language needed
# by expect and dejagnu for running test suites.
# Inputs: /sources/tcl8.6.16-src.tar.gz
# Outputs: Tcl library and binary in /usr
# Ref: LFS 13.0 §8.17
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="tcl8.6.16"
VERSION="8.6.16"
echo "=== Building ${PACKAGE} (Phase 3) ==="
pkg_extract "${PACKAGE}-src.tar.gz"
cd "${PACKAGE}/unix"
# Configure Tcl with optimizations for our hardware
./configure \
--prefix=/usr \
--enable-64bit \
--enable-threads
make
make install
# Make the library accessible and create symbolic links
make install-private-headers
ln -sv tclsh8.6 /usr/bin/tclsh
# Verify installation
echo "Tcl version: $(/usr/bin/tclsh --version)"
cd "${SRCDIR}"
pkg_cleanup "${PACKAGE}"
echo "=== ${PACKAGE} complete ==="

41
toolchain/scripts/115-expect.sh Executable file
View File

@@ -0,0 +1,41 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.18: Expect
# ============================================================================
# Purpose: Build Expect, which is used to run automated tests for other
# programs. Required by dejagnu for the GCC test suite.
# Inputs: /sources/expect5.45.4.tar.gz
# /sources/expect-5.45.4-gcc15-1.patch (GCC 15 compatibility)
# Outputs: expect binary and libraries in /usr
# Ref: LFS 13.0 §8.18
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="expect"
VERSION="5.45.4"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}${VERSION}.tar.gz"
cd "${PACKAGE}${VERSION}"
# Apply GCC 15 compatibility patch
patch -Np1 < "${SRCDIR}/expect-${VERSION}-gcc15-1.patch"
# Configure with Tcl support
./configure \
--prefix=/usr \
--with-tcl=/usr/lib \
--with-tclinclude=/usr/include
make
make install
# Verify installation
echo "expect version: $(/usr/bin/expect -v | head -1)"
cd "${SRCDIR}"
pkg_cleanup "${PACKAGE}${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

View File

@@ -0,0 +1,33 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.19: DejaGNU
# ============================================================================
# Purpose: Build DejaGNU, a framework for testing other programs.
# Primarily used to run the GCC test suite.
# Inputs: /sources/dejagnu-1.6.3.tar.gz
# Outputs: DejaGNU framework in /usr/share/dejagnu
# Ref: LFS 13.0 §8.19
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="dejagnu"
VERSION="1.6.3"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.gz"
cd "${PACKAGE}-${VERSION}"
# Configure DejaGNU
./configure --prefix=/usr
make install
# Verify installation
echo "DejaGNU version: $(/usr/bin/runtest --version 2>&1 | head -1)"
cd "${SRCDIR}"
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

View File

@@ -0,0 +1,39 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.20: pkgconf
# ============================================================================
# Purpose: Build pkgconf, a lightweight pkg-config replacement for querying
# package metadata and compiler/linker flags.
# Inputs: /sources/pkgconf-2.4.3.tar.gz
# Outputs: pkgconf binary and pkg-config symlink in /usr/bin
# Ref: LFS 13.0 §8.20
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="pkgconf"
VERSION="2.4.3"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.gz"
cd "${PACKAGE}-${VERSION}"
# Configure pkgconf with standard prefix
./configure \
--prefix=/usr \
--disable-static
make
make install
# Create pkg-config symlink for compatibility with scripts expecting pkg-config
ln -sv pkgconf /usr/bin/pkg-config
# Verify installation
echo "pkgconf version: $(/usr/bin/pkgconf --version)"
cd "${SRCDIR}"
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

View File

@@ -0,0 +1,58 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.21: Binutils (FINAL NATIVE)
# ============================================================================
# Purpose: Build the FINAL native binutils (assembler, linker, etc.)
# This replaces the cross-build binutils for the target system.
# Version 2.46.0 — matches Phase 0 toolchain bootstrap.
# Inputs: /sources/binutils-2.46.0.tar.xz
# Outputs: as, ld, ar, ranlib, objdump, nm, etc. in /usr/bin
# Ref: LFS 13.0 §8.21
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="binutils"
VERSION="2.46.0"
echo "=== Building FINAL NATIVE ${PACKAGE}-${VERSION} (Phase 3 — CRITICAL) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
# Verify that we're using Zen 5 flags from the environment
echo "Build flags: CFLAGS='${CFLAGS}' CXXFLAGS='${CXXFLAGS}' LDFLAGS='${LDFLAGS}'"
mkdir -v build
cd build
# Configure native binutils with full features for the target system
# --enable-gold: include the gold linker (faster, supports LTO)
# --enable-ld=default: use GNU ld as default (more compatible than gold for now)
# --enable-plugins: support linker plugins for LTO
# --disable-werror: don't fail on compiler warnings
# --with-system-zlib: use system zlib for compression
../configure \
--prefix=/usr \
--sysconfdir=/etc \
--localstatedir=/var \
--enable-gold \
--enable-ld=default \
--enable-plugins \
--disable-werror \
--with-system-zlib
make
make install
# Install LTO support
install -Dm644 ../include/plugin-api.h /usr/include/plugin-api.h
# Verify binutils installation
echo "Binutils version: $(ld --version | head -1)"
echo "as version: $(as --version | head -1)"
cd "${SRCDIR}"
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== FINAL NATIVE ${PACKAGE}-${VERSION} complete ==="

View File

@@ -0,0 +1,40 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.22: GMP (GNU Multiple Precision)
# ============================================================================
# Purpose: Build GMP, a library for arbitrary-precision arithmetic.
# Required by GCC for floating-point operations in the compiler.
# Inputs: /sources/gmp-6.3.0.tar.xz
# Outputs: GMP library in /usr/lib, headers in /usr/include
# Ref: LFS 13.0 §8.22
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="gmp"
VERSION="6.3.0"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
# Build GMP with optimization for x86_64 (znver5 will inherit from CFLAGS)
# --enable-cxx: build C++ bindings for GCC
./configure \
--prefix=/usr \
--enable-cxx \
--disable-static
make
make html
make install
make install-html
# Verify installation
echo "GMP version: $(/usr/bin/gmp-config --version 2>/dev/null || echo 'GMP installed')"
cd "${SRCDIR}"
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

View File

@@ -0,0 +1,40 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.23: MPFR (Multiple Precision Float)
# ============================================================================
# Purpose: Build MPFR, a library for arbitrary-precision floating-point
# arithmetic. Required by GCC for advanced floating-point operations.
# Inputs: /sources/mpfr-4.2.2.tar.xz
# GMP already installed
# Outputs: MPFR library in /usr/lib, headers in /usr/include
# Ref: LFS 13.0 §8.23
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="mpfr"
VERSION="4.2.2"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
# Configure MPFR with GMP support already in place
./configure \
--prefix=/usr \
--disable-static \
--enable-thread-safe
make
make html
make install
make install-html
# Verify installation
echo "MPFR version: $(grep -o 'define MPFR_VERSION_MAJOR [0-9]*' src/mpfrversion.h | awk '{print $NF}').$(grep -o 'define MPFR_VERSION_MINOR [0-9]*' src/mpfrversion.h | awk '{print $NF}')"
cd "${SRCDIR}"
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

39
toolchain/scripts/121-mpc.sh Executable file
View File

@@ -0,0 +1,39 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.24: MPC (Multiple Precision Complex)
# ============================================================================
# Purpose: Build MPC, a library for arbitrary-precision complex number
# arithmetic. Required by GCC for floating-point math operations.
# Inputs: /sources/mpc-1.3.1.tar.gz
# GMP and MPFR already installed
# Outputs: MPC library in /usr/lib, headers in /usr/include
# Ref: LFS 13.0 §8.24
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="mpc"
VERSION="1.3.1"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.gz"
cd "${PACKAGE}-${VERSION}"
# Configure MPC with GMP and MPFR support already in place
./configure \
--prefix=/usr \
--disable-static
make
make html
make install
make install-html
# Verify installation
echo "MPC version: $(grep -o '#define MPC_VERSION "[^"]*' src/mpc.h | awk -F'"' '{print $NF}')"
cd "${SRCDIR}"
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

41
toolchain/scripts/122-attr.sh Executable file
View File

@@ -0,0 +1,41 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.25: Attr (Extended Attributes)
# ============================================================================
# Purpose: Build Attr, a library for managing extended attributes on
# filesystem files (user-space API for xattr).
# Required by ACL package.
# Inputs: /sources/attr-2.5.2.tar.gz
# Outputs: attr library in /usr/lib, tools in /usr/bin
# Ref: LFS 13.0 §8.25
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="attr"
VERSION="2.5.2"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.gz"
cd "${PACKAGE}-${VERSION}"
# Configure attr with standard options
./configure \
--prefix=/usr \
--disable-static \
--sysconfdir=/etc
make
make install
# Install library symlinks for consistency
install -Dm644 include/attr.h /usr/include/attr.h
# Verify installation
echo "attr version: $(/usr/bin/attr --version 2>&1 | head -1)"
cd "${SRCDIR}"
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

39
toolchain/scripts/123-acl.sh Executable file
View File

@@ -0,0 +1,39 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.26: ACL (Access Control Lists)
# ============================================================================
# Purpose: Build ACL, a library for managing Access Control Lists on
# filesystems. Provides fine-grained permission control beyond
# traditional Unix permissions.
# Inputs: /sources/acl-2.3.2.tar.xz
# attr already installed
# Outputs: ACL library in /usr/lib, tools in /usr/bin
# Ref: LFS 13.0 §8.26
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="acl"
VERSION="2.3.2"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
# Configure ACL with attr support
./configure \
--prefix=/usr \
--disable-static \
--sysconfdir=/etc
make
make install
# Verify installation
echo "ACL version: $(/usr/bin/getfacl --version 2>&1 | head -1)"
cd "${SRCDIR}"
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

39
toolchain/scripts/124-libcap.sh Executable file
View File

@@ -0,0 +1,39 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.27: Libcap (POSIX Capabilities)
# ============================================================================
# Purpose: Build libcap, a library for managing POSIX capabilities on
# executables. Used for privilege separation without full root.
# Required by various system tools and by polkit (for privilege escalation).
# Inputs: /sources/libcap-2.76.tar.xz
# Outputs: libcap library in /usr/lib, utilities in /usr/sbin
# Ref: LFS 13.0 §8.27
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="libcap"
VERSION="2.76"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
# Prevent static linking (we want shared libraries)
sed -i '/^LIBDIR/s/lib/lib/' Makefile
# Build and install with optimizations
make lib=lib
make lib=lib DESTDIR=/ install
# Install headers
install -Dm644 libcap/include/sys/capability.h /usr/include/sys/capability.h
# Verify installation
echo "libcap version: $(/usr/sbin/getcap -V 2>&1 || echo 'libcap installed')"
cd "${SRCDIR}"
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

View File

@@ -0,0 +1,42 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.28: Libxcrypt
# ============================================================================
# Purpose: Build libxcrypt, a modern replacement for the crypt() function
# in glibc. Provides support for various password hashing algorithms
# (MD5, SHA-256, SHA-512, bcrypt, etc.).
# Required by shadow password utilities and system authentication.
# Inputs: /sources/libxcrypt-4.4.38.tar.xz
# Outputs: libxcrypt library in /usr/lib, headers in /usr/include
# Ref: LFS 13.0 §8.28
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="libxcrypt"
VERSION="4.4.38"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
# Configure libxcrypt with all algorithms enabled
# --enable-hashes: enable all supported hash algorithms
# --enable-obsolete-api: keep old crypt() API for compatibility
./configure \
--prefix=/usr \
--enable-hashes=all \
--enable-obsolete-api \
--disable-static
make
make install
# Verify installation
echo "libxcrypt installed: libcrypt=$(ls -1 /usr/lib/libcrypt* 2>/dev/null | head -1)"
cd "${SRCDIR}"
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

54
toolchain/scripts/126-shadow.sh Executable file
View File

@@ -0,0 +1,54 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.29: Shadow
# ============================================================================
# Purpose: Build Shadow, which provides tools for user and group management:
# useradd, userdel, usermod, passwd, su, login, etc.
# CRITICAL: Disable systemd support — we use SysVinit only.
# Inputs: /sources/shadow-4.17.4.tar.xz
# libxcrypt already installed
# Outputs: User/group management tools in /usr/bin, /usr/sbin, /etc/default
# Ref: LFS 13.0 §8.29
# Notes: NO systemd-enable, NO logind, NO PAM modules for systemd
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="shadow"
VERSION="4.17.4"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) — SysVinit ONLY ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
# Disable systemd and nls (language support)
# Use traditional shadow files, not systemd-homed
sed -i 's/^\t#\(ENCRYPT_METHOD\)/\1/' etc/default/useradd.in
sed -i 's/^ENCRYPT_METHOD.*/ENCRYPT_METHOD SHA512/' etc/default/useradd.in
# Configure shadow for traditional SysVinit system
# --disable-nls: no i18n for now
# --with-libcrypt=xcrypt: use libxcrypt for password hashing
# --disable-man: we'll handle man pages separately
./configure \
--sysconfdir=/etc \
--with-libcrypt=xcrypt \
--disable-nls \
--without-libpam
make
make install
# Verify that systemd is not included
if grep -q "systemd" /etc/default/useradd; then
echo "[ERROR] Shadow was built with systemd references!"
exit 1
fi
echo "Shadow version: $(/usr/bin/useradd --version 2>&1 | head -1)"
cd "${SRCDIR}"
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete (SysVinit mode) ==="

141
toolchain/scripts/127-gcc.sh Executable file
View File

@@ -0,0 +1,141 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.30: GCC (FINAL NATIVE COMPILER)
# ============================================================================
# Purpose: Build the FINAL NATIVE GCC compiler for the target system.
# This is a CRITICAL step — it compiles for the local hardware
# (AMD Ryzen 9 9950X3D) with Zen 5 optimizations.
# CRITICAL ARCHITECTURE DECISIONS:
# • Enable C and C++ languages for system tools and applications
# • Enable Position-Independent Executables (PIE) by default (security)
# • Enable Stack Smashing Protection (SSP) by default (security)
# • Disable multilib for now (32-bit support handled separately later)
# • Disable bootstrap (faster, safer, reuses earlier GCC Pass 2)
# • Apply the lib64→lib sed fix for x86_64 unified /usr/lib
# • Fix library paths after install to avoid searching lib64
#
# Inputs: /sources/gcc-15.2.0.tar.xz
# mpfr-4.2.2.tar.xz, gmp-6.3.0.tar.xz, mpc-1.3.1.tar.gz
# binutils, glibc, linux headers already installed
# Outputs: gcc, g++, cc (symlink) in /usr/bin
# GCC runtime libraries in /usr/lib
# Ref: LFS 13.0 §8.30
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="gcc"
VERSION="15.2.0"
echo "=========================================================================="
echo "=== CRITICAL: Building FINAL NATIVE GCC-${VERSION} (Phase 3)"
echo "=== This compiler will target: AMD Zen 5 (9950X3D)"
echo "=== Compiler flags in use: ${CFLAGS}"
echo "=========================================================================="
pkg_extract "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
# Extract arithmetic library dependencies (gmp, mpfr, mpc) into gcc tree
echo ">>> Embedding GMP, MPFR, MPC into GCC source tree..."
tar -xf "${SRCDIR}/mpfr-4.2.2.tar.xz"
mv -v mpfr-4.2.2 mpfr
tar -xf "${SRCDIR}/gmp-6.3.0.tar.xz"
mv -v gmp-6.3.0 gmp
tar -xf "${SRCDIR}/mpc-1.3.1.tar.gz"
mv -v mpc-1.3.1 mpc
# FIX FOR X86_64: lib64 → lib redirection
# On x86_64, GCC defaults to installing 64-bit libraries in lib64.
# DarkForge uses a unified /usr/lib directory. This sed changes GCC's default.
# CRITICAL: This must be done before configure.
case $(uname -m) in
x86_64)
echo ">>> Applying x86_64 lib64→lib fix..."
sed -e '/m64=/s/lib64/lib/' -i.orig gcc/config/i386/t-linux64
;;
esac
# Create build directory
mkdir -v build
cd build
# CONFIGURE THE FINAL NATIVE GCC
# This is the most important configuration in the entire toolchain.
echo ">>> Configuring GCC with full security hardening..."
echo ">>> Using Zen 5 flags: ${CFLAGS}"
../configure \
--prefix=/usr \
--sysconfdir=/etc \
--localstatedir=/var \
--disable-nls \
--enable-languages=c,c++ \
--enable-default-pie \
--enable-default-ssp \
--disable-multilib \
--disable-bootstrap \
--with-system-zlib \
--enable-gnu-unique-object
# COMPILE GCC
echo ">>> Building GCC (this will take several minutes)..."
make
# INSTALL GCC
echo ">>> Installing GCC to /usr..."
make install
# CREATE cc SYMLINK FOR COMPATIBILITY
# Many build scripts expect /usr/bin/cc to exist
ln -sv gcc /usr/bin/cc
# POST-INSTALL FIXES FOR LIB PATHS
echo ">>> Verifying and fixing library paths..."
# Ensure /usr/lib is in the search path, not /usr/lib64
mkdir -pv /usr/lib/gcc/$(gcc -dumpmachine)/15.2.0
# Run a sanity check: compile and link a hello world program
echo ">>> Running GCC sanity check (compile hello world)..."
echo '#include <stdio.h>
int main() {
printf("GCC hello world sanity check\\n");
return 0;
}' > /tmp/hello.c
gcc /tmp/hello.c -o /tmp/hello
if [ ! -f /tmp/hello ]; then
echo "[ERROR] GCC sanity check failed: could not compile hello.c"
exit 1
fi
# Check the dynamic linker path (should NOT have lib64)
echo ">>> Checking dynamic linker path..."
LINKER=$(/tmp/hello 2>&1 | head -1 2>/dev/null || ldd /tmp/hello 2>/dev/null | grep "ld-" || echo "OK")
if echo "${LINKER}" | grep -q "lib64"; then
echo "[WARNING] Dynamic linker path contains lib64 — may need manual fix"
else
echo ">>> Dynamic linker path is correct (no lib64)"
fi
rm -f /tmp/hello /tmp/hello.c
# Final verification
echo ""
echo ">>> GCC Final Verification:"
echo " GCC version: $(gcc --version | head -1)"
echo " G++ version: $(g++ --version | head -1)"
echo " cc symlink: $(ls -l /usr/bin/cc)"
echo " Default PIE: $(gcc -Q --help=code-generation | grep DEFAULT | grep pie)"
echo " Default SSP: $(gcc -Q --help=code-generation | grep DEFAULT | grep ssp)"
echo ""
cd "${SRCDIR}"
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=========================================================================="
echo "=== FINAL NATIVE GCC-${VERSION} BUILD COMPLETE"
echo "=== System now has a native compiler targeting Zen 5"
echo "=========================================================================="

View File

@@ -0,0 +1,46 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.31: Ncurses
# ============================================================================
# Purpose: Build ncurses library with wide-character support. Provides
# terminal manipulation capabilities for interactive programs.
# Inputs: /sources/ncurses.tar.gz (auto-detected version)
# Outputs: ncurses library and development files in /usr/
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.31
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="ncurses"
echo "=== Building ${PACKAGE} (Phase 3) ==="
cd "${SRCDIR}"
tar -xf "${PACKAGE}.tar.gz"
cd "${PACKAGE}"
# Configure with wide character support and other options
./configure \
--prefix=/usr \
--sysconfdir=/etc \
--with-shared \
--with-normal \
--without-debug \
--without-ada \
--enable-widec \
--enable-overwrite
make
make DESTDIR="${SRCDIR}/ncurses-install" install
make install
# Create compatibility symlinks for wide-character libraries
cd /usr/lib
ln -sfv libncursesw.so.6 libncurses.so.6
ln -sfv libncurses.so.6 libncurses.so
pkg_cleanup "${PACKAGE}"
echo "=== ${PACKAGE} complete ==="

35
toolchain/scripts/129-sed.sh Executable file
View File

@@ -0,0 +1,35 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.32: Sed
# ============================================================================
# Purpose: Build GNU sed, a stream editor for filtering and transforming text.
# Essential for many build scripts and system utilities.
# Inputs: /sources/sed-4.9.tar.xz
# Outputs: sed binary in /usr/bin/
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.32
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="sed"
VERSION="4.9"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
./configure \
--prefix=/usr \
--bindir=/bin
make
make html
make install
make -C doc install-html
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

32
toolchain/scripts/130-psmisc.sh Executable file
View File

@@ -0,0 +1,32 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.33: Psmisc
# ============================================================================
# Purpose: Build psmisc (Process Signalling Miscellaneous) utilities.
# Provides killall, pstree, fuser for process management.
# Inputs: /sources/psmisc-23.7.tar.xz
# Outputs: psmisc utilities in /usr/bin/ and /usr/sbin/
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.33
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="psmisc"
VERSION="23.7"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
./configure \
--prefix=/usr
make
make install
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

View File

@@ -0,0 +1,36 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.34: Gettext
# ============================================================================
# Purpose: Build GNU gettext, the internationalization and localization
# infrastructure. Provides msgfmt, xgettext, and localization tools.
# Inputs: /sources/gettext-1.0.tar.xz
# Outputs: gettext binaries, libraries, and locale data in /usr/
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.34
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="gettext"
VERSION="1.0"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
./configure \
--prefix=/usr \
--disable-static
make
make install
# Verify msgfmt is available
msgfmt --version || { echo "ERROR: msgfmt not found"; exit 1; }
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

32
toolchain/scripts/132-bison.sh Executable file
View File

@@ -0,0 +1,32 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.35: Bison
# ============================================================================
# Purpose: Build GNU Bison, a general-purpose parser generator.
# Required for gcc and other packages to build.
# Inputs: /sources/bison-3.8.2.tar.xz
# Outputs: bison binary and libraries in /usr/
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.35
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="bison"
VERSION="3.8.2"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
./configure \
--prefix=/usr
make
make install
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

33
toolchain/scripts/133-grep.sh Executable file
View File

@@ -0,0 +1,33 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.36: Grep
# ============================================================================
# Purpose: Build GNU grep, a text search utility for pattern matching.
# Essential for scripting and text processing.
# Inputs: /sources/grep-3.12.tar.xz
# Outputs: grep binary in /bin/
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.36
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="grep"
VERSION="3.12"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
./configure \
--prefix=/usr \
--bindir=/bin
make
make install
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

49
toolchain/scripts/134-bash.sh Executable file
View File

@@ -0,0 +1,49 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.37: Bash (Final)
# ============================================================================
# Purpose: Build final bash shell (previously only had temporary version).
# Also create /bin/sh symlink to bash.
# Inputs: /sources/bash-5.3.tar.gz
# Outputs: bash binary in /bin/ and /bin/sh symlink
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.37
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="bash"
VERSION="5.3"
echo "=== Building ${PACKAGE}-${VERSION} (Final) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.gz"
cd "${PACKAGE}-${VERSION}"
./configure \
--prefix=/usr \
--exec-prefix= \
--bindir=/bin \
--sbindir=/sbin \
--libexecdir=/usr/lib \
--sysconfdir=/etc \
--sharedstatedir=/var/lib \
--localstatedir=/var \
--libdir=/usr/lib \
--includedir=/usr/include \
--oldincludedir=/usr/include \
--infodir=/usr/share/info \
--mandir=/usr/share/man \
--without-bash-malloc \
--with-installed-readline
make
make install
# Create /bin/sh symlink (required by POSIX)
ln -sfv bash /bin/sh
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

View File

@@ -0,0 +1,32 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.38: Libtool
# ============================================================================
# Purpose: Build GNU libtool, a generic library support script.
# Handles building shared and static libraries portably.
# Inputs: /sources/libtool-2.5.4.tar.xz
# Outputs: libtool binary and library support tools in /usr/
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.38
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="libtool"
VERSION="2.5.4"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
./configure \
--prefix=/usr
make
make install
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

34
toolchain/scripts/136-gdbm.sh Executable file
View File

@@ -0,0 +1,34 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.39: GDBM
# ============================================================================
# Purpose: Build GNU GDBM (GNU DataBase Manager), a hash database library.
# Required by Perl and other packages for persistent data storage.
# Inputs: /sources/gdbm-1.24.tar.gz
# Outputs: gdbm library and development files in /usr/
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.39
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="gdbm"
VERSION="1.24"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.gz"
cd "${PACKAGE}-${VERSION}"
./configure \
--prefix=/usr \
--disable-static \
--enable-libgdbm-compat
make
make install
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

32
toolchain/scripts/137-gperf.sh Executable file
View File

@@ -0,0 +1,32 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.40: Gperf
# ============================================================================
# Purpose: Build gperf, a perfect hash function generator.
# Optimizes keyword lookup tables used by compilers and tools.
# Inputs: /sources/gperf-3.1.tar.gz
# Outputs: gperf binary in /usr/bin/
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.40
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="gperf"
VERSION="3.1"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.gz"
cd "${PACKAGE}-${VERSION}"
./configure \
--prefix=/usr
make
make install
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

33
toolchain/scripts/138-expat.sh Executable file
View File

@@ -0,0 +1,33 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.41: Expat
# ============================================================================
# Purpose: Build Expat, an XML parsing library.
# Required for XML processing by many tools and libraries.
# Inputs: /sources/expat-2.7.1.tar.xz
# Outputs: expat library and development files in /usr/
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.41
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="expat"
VERSION="2.7.1"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
./configure \
--prefix=/usr \
--disable-static
make
make install
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

View File

@@ -0,0 +1,41 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.42: Inetutils
# ============================================================================
# Purpose: Build GNU inetutils, basic network utilities (ping, telnet, ftp, etc.)
# Provides essential network diagnostic and communication tools.
# Inputs: /sources/inetutils-2.6.tar.xz
# Outputs: Network utilities in /usr/bin/, /usr/sbin/
# Assumes: Running inside chroot (no systemd)
# Ref: LFS 13.0 §8.42
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="inetutils"
VERSION="2.6"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
./configure \
--prefix=/usr \
--localstatedir=/var \
--disable-logger \
--disable-syslogd \
--disable-ifdconfig \
--disable-servers
make
make install
# Move programs to proper locations per LFS
mv -v /usr/bin/{hostname,dnsdomainname} /usr/sbin/ 2>/dev/null || true
mv -v /usr/bin/ifconfig /usr/sbin/ 2>/dev/null || true
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

33
toolchain/scripts/140-less.sh Executable file
View File

@@ -0,0 +1,33 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.43: Less
# ============================================================================
# Purpose: Build less, a text pager utility for reading files and manual pages.
# Essential for viewing documentation and log files.
# Inputs: /sources/less-668.tar.gz
# Outputs: less pager binary in /usr/bin/
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.43
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="less"
VERSION="668"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.gz"
cd "${PACKAGE}-${VERSION}"
./configure \
--prefix=/usr \
--sysconfdir=/etc
make
make install
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

45
toolchain/scripts/141-perl.sh Executable file
View File

@@ -0,0 +1,45 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.44: Perl (Final)
# ============================================================================
# Purpose: Build final Perl interpreter (full install, not temporary).
# Provides Perl scripting language used by many tools and packages.
# Inputs: /sources/perl-5.40.2.tar.xz
# Outputs: perl interpreter, modules, and documentation in /usr/
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.44
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="perl"
VERSION="5.40.2"
echo "=== Building ${PACKAGE}-${VERSION} (Final) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
export BUILD_ZLIB=False
export BUILD_BZIP2=0
# Run perl's configuration script
./Configure \
-des \
-Dprefix=/usr \
-Dvendorprefix=/usr \
-Duseshrplib \
-Dvendorlib=/usr/lib/perl5/5.40/vendor_perl \
-Dsitelib=/usr/lib/perl5/5.40/site_perl
make
make test || true
make install
# Create a symlink to simplify path references
ln -sfv /usr/lib/perl5/5.40/Config_heavy.pl /usr/lib/perl5/5.40/Config_heavy.pl.bak || true
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

View File

@@ -0,0 +1,31 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.45: XML::Parser
# ============================================================================
# Purpose: Build Perl's XML::Parser module, a Perl interface to Expat.
# Required for intltool and other XML-processing Perl scripts.
# Inputs: /sources/XML-Parser-2.47.tar.gz (Perl module)
# Outputs: Perl module installed to /usr/lib/perl5/
# Assumes: Running inside chroot, perl already built
# Ref: LFS 13.0 §8.45
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="XML-Parser"
VERSION="2.47"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.gz"
cd "${PACKAGE}-${VERSION}"
perl Makefile.PL
make
make test || true
make install
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

View File

@@ -0,0 +1,35 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.46: Intltool
# ============================================================================
# Purpose: Build intltool, an internationalization tool for extracting and
# merging translations from source files.
# Inputs: /sources/intltool-0.51.0.tar.gz
# Outputs: intltool scripts and modules in /usr/
# Assumes: Running inside chroot, Perl and XML::Parser already built
# Ref: LFS 13.0 §8.46
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="intltool"
VERSION="0.51.0"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.gz"
cd "${PACKAGE}-${VERSION}"
# Fix deprecated Perl usage
sed -i 's/^iconv/# iconv/' intltool-update
./configure \
--prefix=/usr
make
make install
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

View File

@@ -0,0 +1,32 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.47: Autoconf
# ============================================================================
# Purpose: Build GNU Autoconf, an extensible package of M4 macros for
# automatic source configuration.
# Inputs: /sources/autoconf-2.72.tar.xz
# Outputs: autoconf scripts and macros in /usr/
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.47
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="autoconf"
VERSION="2.72"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
./configure \
--prefix=/usr
make
make install
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

View File

@@ -0,0 +1,32 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.48: Automake
# ============================================================================
# Purpose: Build GNU Automake, which generates Makefile.in files from
# Makefile.am templates.
# Inputs: /sources/automake-1.17.tar.xz
# Outputs: automake scripts and macros in /usr/
# Assumes: Running inside chroot, autoconf already built
# Ref: LFS 13.0 §8.48
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="automake"
VERSION="1.17"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
./configure \
--prefix=/usr
make
make install
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

View File

@@ -0,0 +1,46 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.49: OpenSSL
# ============================================================================
# Purpose: Build OpenSSL, cryptography library and tools for secure
# communications (SSL/TLS). Required by wget, curl, and many packages.
# Inputs: /sources/openssl-3.5.0.tar.gz
# Outputs: OpenSSL library and tools in /usr/
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.49
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="openssl"
VERSION="3.5.0"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.gz"
cd "${PACKAGE}-${VERSION}"
# Configure OpenSSL with shared libraries and position-independent code
./config \
--prefix=/usr \
--openssldir=/etc/ssl \
--libdir=lib \
shared \
zlib-dynamic
make
make install
# Create symlinks for compatibility
cd /usr/lib64
ln -sfv libcrypto.so.3 libcrypto.so 2>/dev/null || true
ln -sfv libssl.so.3 libssl.so 2>/dev/null || true
cd /usr/lib
ln -sfv libcrypto.so.3 libcrypto.so 2>/dev/null || true
ln -sfv libssl.so.3 libssl.so 2>/dev/null || true
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

39
toolchain/scripts/147-libelf.sh Executable file
View File

@@ -0,0 +1,39 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.50: Libelf
# ============================================================================
# Purpose: Build libelf (from elfutils), a library for reading and writing
# ELF binaries. Required for many development tools and dpack.
# Inputs: /sources/elfutils-0.192.tar.bz2
# Outputs: libelf library and header files in /usr/
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.50
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="elfutils"
VERSION="0.192"
echo "=== Building ${PACKAGE}-${VERSION} (libelf from elfutils) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.bz2"
cd "${PACKAGE}-${VERSION}"
./configure \
--prefix=/usr \
--disable-debuginfod \
--libdir=/usr/lib \
--sbindir=/usr/sbin
make
make install
# Create symlink for compatibility
cd /usr/lib
ln -sfv libelf.so.1 libelf.so 2>/dev/null || true
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

34
toolchain/scripts/148-libffi.sh Executable file
View File

@@ -0,0 +1,34 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.51: Libffi
# ============================================================================
# Purpose: Build libffi (Foreign Function Interface), a library for
# dynamically calling C functions. Required by Python, Ruby, and GCC.
# Inputs: /sources/libffi-3.4.7.tar.gz
# Outputs: libffi library and development files in /usr/
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.51
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="libffi"
VERSION="3.4.7"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.gz"
cd "${PACKAGE}-${VERSION}"
./configure \
--prefix=/usr \
--disable-static \
--with-gcc-arch=native
make
make install
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

57
toolchain/scripts/149-python.sh Executable file
View File

@@ -0,0 +1,57 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.52-53: Python (Final)
# ============================================================================
# Purpose: Build Python 3 (full install, not temporary). Provides the
# Python interpreter and standard library.
# Inputs: /sources/Python-3.13.3.tar.xz
# /sources/sqlite-autoconf-3490100.tar.gz (for SQLite support)
# Outputs: Python interpreter and modules in /usr/
# Assumes: Running inside chroot, libffi already built
# Ref: LFS 13.0 §8.52-53
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="Python"
VERSION="3.13.3"
echo "=== Building SQLite (dependency for Python) ==="
cd "${SRCDIR}"
tar -xf sqlite-autoconf-3490100.tar.gz
cd sqlite-autoconf-3490100
./configure \
--prefix=/usr \
--disable-static \
--enable-fts5
make
make install
cd "${SRCDIR}"
rm -rf sqlite-autoconf-3490100
echo "=== Building ${PACKAGE}-${VERSION} (Final) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
./configure \
--prefix=/usr \
--enable-optimizations \
--enable-loadable-sqlite-extensions \
--with-system-libmpdec
make
make install
# Create symlinks for compatibility
cd /usr/bin
ln -sfv python3 python 2>/dev/null || true
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

View File

@@ -0,0 +1,114 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8: Verify Batch 4 Scripts
# ============================================================================
# Purpose: Verify all 25 batch 4 scripts exist, are executable, and have
# valid structure before running the full batch.
# Inputs: Scripts in current directory
# Outputs: Validation report
# ============================================================================
set -u
echo "=========================================================================="
echo "DarkForge Linux — Batch 4 Verification Script"
echo "=========================================================================="
echo ""
# Expected scripts
SCRIPTS=(
"155-kmod.sh"
"156-coreutils.sh"
"157-diffutils.sh"
"158-gawk.sh"
"159-findutils.sh"
"160-groff.sh"
"161-gzip.sh"
"162-iproute2.sh"
"163-kbd.sh"
"164-libpipeline.sh"
"165-make.sh"
"166-patch.sh"
"167-tar.sh"
"168-texinfo.sh"
"169-vim.sh"
"170-markupsafe.sh"
"171-jinja2.sh"
"172-eudev.sh"
"173-man-db.sh"
"174-procps-ng.sh"
"175-util-linux.sh"
"176-e2fsprogs.sh"
"177-sysklogd.sh"
"178-sysvinit.sh"
"179-strip-and-cleanup.sh"
)
FOUND_COUNT=0
MISSING_COUNT=0
NOT_EXECUTABLE_COUNT=0
NO_HEADER_COUNT=0
echo "Checking ${#SCRIPTS[@]} scripts..."
echo ""
for script in "${SCRIPTS[@]}"; do
if [ ! -f "$script" ]; then
echo "[MISSING] $script"
((MISSING_COUNT++))
continue
fi
if [ ! -x "$script" ]; then
echo "[NOT EXEC] $script (fixing...)"
chmod +x "$script"
((NOT_EXECUTABLE_COUNT++))
fi
# Check for proper bash header
if ! head -1 "$script" | grep -q "^#!/bin/bash"; then
echo "[NO SHEBANG] $script"
((NO_HEADER_COUNT++))
continue
fi
# Check for set -euo pipefail
if ! grep -q "set -euo pipefail" "$script"; then
echo "[NO ERROR HANDLING] $script"
continue
fi
# Check for source of 100-chroot-env.sh
if ! grep -q "source /sources/toolchain-scripts/100-chroot-env.sh" "$script"; then
echo "[NO ENV SOURCE] $script"
continue
fi
((FOUND_COUNT++))
done
echo ""
echo "=========================================================================="
echo "VERIFICATION REPORT"
echo "=========================================================================="
echo ""
echo "Total scripts expected: ${#SCRIPTS[@]}"
echo "Scripts found: $FOUND_COUNT"
echo "Scripts missing: $MISSING_COUNT"
echo "Scripts not exec: $NOT_EXECUTABLE_COUNT (fixed)"
echo "Scripts no header: $NO_HEADER_COUNT"
echo ""
if [ $MISSING_COUNT -eq 0 ] && [ $NO_HEADER_COUNT -eq 0 ]; then
echo "✓ All batch 4 scripts are valid and ready to execute!"
echo ""
echo "To run all 25 scripts, execute:"
echo " ./150-run-batch4.sh"
echo ""
exit 0
else
echo "✗ Some scripts are missing or invalid."
echo " Please fix the issues listed above before proceeding."
echo ""
exit 1
fi

View File

@@ -0,0 +1,28 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.54: Flit-Core
# ============================================================================
# Purpose: Build flit-core, a minimal Python build backend for PEP 517.
# Required by setuptools and other Python packages.
# Inputs: /sources/flit_core-3.11.0.tar.gz
# Outputs: Python module installed to /usr/lib/python3.13/
# Assumes: Running inside chroot, Python already built
# Ref: LFS 13.0 §8.54
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="flit_core"
VERSION="3.11.0"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.gz"
cd "${PACKAGE}-${VERSION}"
python3 -m pip install --no-build-isolation --no-index .
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

View File

@@ -0,0 +1,131 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8: Master Batch 4 Runner
# ============================================================================
# Purpose: Execute all 25 scripts from batch 4 (Chapter 8 final) in order.
# Run this from inside the chroot.
# Inputs: All 155-179 scripts present and executable
# Outputs: Complete base system with all utilities installed
# Assumes: Running inside chroot, Phase 0-3 earlier scripts complete
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
echo "=========================================================================="
echo "DarkForge Linux — Phase 3, Chapter 8: BATCH 4 EXECUTION"
echo "=========================================================================="
echo ""
echo "This script will execute all 25 build scripts from batch 4 in sequence."
echo "Each script builds one major package or group of packages."
echo ""
echo "Total build time: expect 30-60 minutes (depends on CPU speed)"
echo ""
read -p "Press Enter to continue, or Ctrl+C to abort... " dummy
cd /sources/toolchain-scripts || { echo "ERROR: Cannot find scripts directory"; exit 1; }
# Array of all scripts in execution order
SCRIPTS=(
"155-kmod.sh"
"156-coreutils.sh"
"157-diffutils.sh"
"158-gawk.sh"
"159-findutils.sh"
"160-groff.sh"
"161-gzip.sh"
"162-iproute2.sh"
"163-kbd.sh"
"164-libpipeline.sh"
"165-make.sh"
"166-patch.sh"
"167-tar.sh"
"168-texinfo.sh"
"169-vim.sh"
"170-markupsafe.sh"
"171-jinja2.sh"
"172-eudev.sh"
"173-man-db.sh"
"174-procps-ng.sh"
"175-util-linux.sh"
"176-e2fsprogs.sh"
"177-sysklogd.sh"
"178-sysvinit.sh"
"179-strip-and-cleanup.sh"
)
SUCCESS_COUNT=0
FAIL_COUNT=0
FAILED_SCRIPTS=()
echo ""
echo "=========================================================================="
echo "Starting batch 4 build sequence..."
echo "=========================================================================="
echo ""
START_TIME=$(date +%s)
for i in "${!SCRIPTS[@]}"; do
SCRIPT="${SCRIPTS[$i]}"
CURRENT=$((i + 1))
TOTAL=${#SCRIPTS[@]}
if [ ! -f "$SCRIPT" ]; then
echo "[ERROR] Script not found: $SCRIPT"
FAILED_SCRIPTS+=("$SCRIPT (not found)")
((FAIL_COUNT++))
continue
fi
echo ""
echo "------------------------------------------------------------------------"
echo "[$CURRENT/$TOTAL] Running: $SCRIPT"
echo "------------------------------------------------------------------------"
if ./"$SCRIPT"; then
echo "[SUCCESS] $SCRIPT completed"
((SUCCESS_COUNT++))
else
echo "[FAILED] $SCRIPT exited with error code $?"
FAILED_SCRIPTS+=("$SCRIPT")
((FAIL_COUNT++))
# Don't exit on error — continue to see all failures
# (Or uncomment next line to stop on first failure)
# exit 1
fi
done
END_TIME=$(date +%s)
ELAPSED=$((END_TIME - START_TIME))
echo ""
echo "=========================================================================="
echo "BATCH 4 BUILD COMPLETE"
echo "=========================================================================="
echo ""
echo "Build Summary:"
echo " Total scripts: ${#SCRIPTS[@]}"
echo " Successful: $SUCCESS_COUNT"
echo " Failed: $FAIL_COUNT"
echo " Elapsed time: $((ELAPSED / 60))m $((ELAPSED % 60))s"
echo ""
if [ $FAIL_COUNT -gt 0 ]; then
echo "FAILED SCRIPTS:"
for script in "${FAILED_SCRIPTS[@]}"; do
echo " - $script"
done
echo ""
echo "Please review the error messages above and rerun failed scripts individually."
exit 1
else
echo "All scripts completed successfully!"
echo ""
echo "Next steps:"
echo " 1. Exit chroot (type 'exit' or press Ctrl+D)"
echo " 2. Proceed with Phase 4 — Kernel Configuration"
echo " 3. Then Phase 5 — Init System Configuration"
echo ""
fi

28
toolchain/scripts/151-wheel.sh Executable file
View File

@@ -0,0 +1,28 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.55-56: Wheel
# ============================================================================
# Purpose: Build wheel, the binary package format for Python.
# Required for setuptools and building Python packages.
# Inputs: /sources/wheel-0.45.1.tar.gz
# Outputs: Python module installed to /usr/lib/python3.13/
# Assumes: Running inside chroot, Python and flit-core already built
# Ref: LFS 13.0 §8.55-56
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="wheel"
VERSION="0.45.1"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.gz"
cd "${PACKAGE}-${VERSION}"
python3 -m pip install --no-build-isolation --no-index .
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

View File

@@ -0,0 +1,28 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.57: Setuptools
# ============================================================================
# Purpose: Build setuptools, a build system for Python packages.
# Essential for building and installing Python packages.
# Inputs: /sources/setuptools-78.1.0.tar.gz
# Outputs: Python module installed to /usr/lib/python3.13/
# Assumes: Running inside chroot, Python, wheel, and flit-core already built
# Ref: LFS 13.0 §8.57
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="setuptools"
VERSION="78.1.0"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.gz"
cd "${PACKAGE}-${VERSION}"
python3 -m pip install --no-build-isolation --no-index .
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

33
toolchain/scripts/153-ninja.sh Executable file
View File

@@ -0,0 +1,33 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.58: Ninja
# ============================================================================
# Purpose: Build Ninja, a small build system focused on speed.
# Required by Meson and used by many modern projects.
# Inputs: /sources/ninja-1.12.1.tar.gz
# Outputs: ninja binary in /usr/bin/
# Assumes: Running inside chroot, Python already built
# Ref: LFS 13.0 §8.58
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="ninja"
VERSION="1.12.1"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.gz"
cd "${PACKAGE}-${VERSION}"
python3 configure.py \
--bootstrap \
--prefix=/usr
./ninja
./ninja install
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

32
toolchain/scripts/154-meson.sh Executable file
View File

@@ -0,0 +1,32 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8.59: Meson
# ============================================================================
# Purpose: Build Meson, a modern build system designed to be user-friendly.
# Used by many packages including mesa, wayland, and others.
# Inputs: /sources/meson-1.7.0.tar.gz
# Outputs: Meson Python module and meson command in /usr/
# Assumes: Running inside chroot, Python, ninja, and setuptools already built
# Ref: LFS 13.0 §8.59
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="meson"
VERSION="1.7.0"
echo "=== Building ${PACKAGE}-${VERSION} (Phase 3) ==="
pkg_extract "${PACKAGE}-${VERSION}.tar.gz"
cd "${PACKAGE}-${VERSION}"
python3 -m pip install \
--no-build-isolation \
--no-index \
--upgrade \
.
pkg_cleanup "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

44
toolchain/scripts/155-kmod.sh Executable file
View File

@@ -0,0 +1,44 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8: kmod
# ============================================================================
# Purpose: Build kmod (modprobe, insmod, lsmod, rmmod, etc.).
# Replaces deprecated module-init-tools.
# Inputs: /sources/kmod-34.tar.xz
# Outputs: kmod programs in /usr/bin/, libraries in /usr/lib/
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.60
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="kmod"
VERSION="34"
echo "=== Building ${PACKAGE}-${VERSION} ==="
cd /sources
tar -xf "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
./configure \
--prefix=/usr \
--sysconfdir=/etc \
--with-openssl \
--with-xz \
--with-zlib
make
make install
# Create symlinks for module programs that depend on kmod
cd /usr/bin
for tool in depmod insmod modinfo modprobe rmmod; do
ln -sfv kmod ${tool}
done
cd /sources
rm -rf "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

View File

@@ -0,0 +1,50 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8: coreutils
# ============================================================================
# Purpose: Build coreutils with i18n support (full install, not temporary).
# Provides cat, ls, cp, mv, rm, chmod, chown, etc.
# Inputs: /sources/coreutils-9.10.tar.xz
# /sources/coreutils-9.10-i18n-1.patch
# Outputs: coreutils binaries and libraries in /usr/
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.61
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="coreutils"
VERSION="9.10"
echo "=== Building ${PACKAGE}-${VERSION} ==="
cd /sources
tar -xf "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
# Apply i18n patch for internationalization support
patch -Np1 -i ../coreutils-${VERSION}-i18n-1.patch
# Disable the tests that are known to fail
autoreconf -fiv
FORCE_UNSAFE_CONFIGURE=1 ./configure \
--prefix=/usr \
--enable-no-install-program=kill,uptime
make
# Optional: run tests (may take time)
# make check || true
make install
# Move programs to proper locations
cd /usr/bin
mv -v chroot ../sbin
# mkdir -pv /usr/share/man/man8
# mv -v ../share/man/man1/chroot.1 ../share/man/man8/chroot.8
# sed -i 's/"1"/"8"/' ../share/man/man8/chroot.8
cd /sources
rm -rf "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

View File

@@ -0,0 +1,35 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8: diffutils
# ============================================================================
# Purpose: Build diffutils (diff, cmp, diff3, sdiff).
# Compares files and produces difference reports.
# Inputs: /sources/diffutils-3.10.tar.xz
# Outputs: diffutils binaries in /usr/bin/
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.62
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="diffutils"
VERSION="3.10"
echo "=== Building ${PACKAGE}-${VERSION} ==="
cd /sources
tar -xf "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
./configure --prefix=/usr
make
# Optional: run tests
# make check || true
make install
cd /sources
rm -rf "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

44
toolchain/scripts/158-gawk.sh Executable file
View File

@@ -0,0 +1,44 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8: gawk
# ============================================================================
# Purpose: Build gawk (GNU awk — pattern scanning and text processing).
# Essential build tool used in many package builds.
# Inputs: /sources/gawk-5.3.1.tar.xz
# Outputs: gawk and awk binaries in /usr/bin/, libraries in /usr/lib/
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.63
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="gawk"
VERSION="5.3.1"
echo "=== Building ${PACKAGE}-${VERSION} ==="
cd /sources
tar -xf "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
sed -i 's/extras//' Makefile.in
./configure --prefix=/usr
make
# Optional: run tests
# make check || true
make install
# Create symlink for awk
ln -sfv gawk /usr/bin/awk
# Create symlink in /usr/share/doc/gawk-VERSION/
mkdir -pv /usr/share/doc/gawk-${VERSION}
cp -v doc/{awkforinit.txt,awkuser.txt,pm*.pdf} /usr/share/doc/gawk-${VERSION}
cd /sources
rm -rf "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

View File

@@ -0,0 +1,39 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8: findutils
# ============================================================================
# Purpose: Build findutils (find, xargs, locate, updatedb).
# Essential utilities for searching files and directories.
# Inputs: /sources/findutils-4.10.0.tar.xz
# Outputs: findutils binaries in /usr/bin/, libraries in /usr/lib/
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.64
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="findutils"
VERSION="4.10.0"
echo "=== Building ${PACKAGE}-${VERSION} ==="
cd /sources
tar -xf "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
./configure --prefix=/usr --localstatedir=/var/lib/locate
make
# Optional: run tests
# make check || true
make install
# Some packages expect /usr/bin/find and /usr/bin/xargs to be on $PATH
# They should already be there, but verify the binaries exist
ls -v /usr/bin/find /usr/bin/xargs
cd /sources
rm -rf "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

38
toolchain/scripts/160-groff.sh Executable file
View File

@@ -0,0 +1,38 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8: groff
# ============================================================================
# Purpose: Build groff (GNU Troff — document formatting system).
# Used for rendering man pages and other documentation.
# Inputs: /sources/groff-1.23.0.tar.gz
# Outputs: groff tools in /usr/bin/, fonts and macros in /usr/share/groff/
# Assumes: Running inside chroot, X11 libraries NOT available (no X11 support)
# Ref: LFS 13.0 §8.65
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="groff"
VERSION="1.23.0"
echo "=== Building ${PACKAGE}-${VERSION} ==="
cd /sources
tar -xf "${PACKAGE}-${VERSION}.tar.gz"
cd "${PACKAGE}-${VERSION}"
# PAGE: Set to empty for DarkForge (page size defaults to US Letter)
PAGE=
./configure --prefix=/usr
make
# Optional: run tests
# make check || true
make install
cd /sources
rm -rf "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

40
toolchain/scripts/161-gzip.sh Executable file
View File

@@ -0,0 +1,40 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8: gzip
# ============================================================================
# Purpose: Build gzip (compression utility for .gz files).
# Essential for working with compressed archives.
# Inputs: /sources/gzip-1.13.tar.xz
# Outputs: gzip, gunzip, zcat binaries in /usr/bin/
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.67 (we skip 8.66 GRUB as per DarkForge spec)
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="gzip"
VERSION="1.13"
echo "=== Building ${PACKAGE}-${VERSION} ==="
cd /sources
tar -xf "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
./configure --prefix=/usr
make
# Optional: run tests
# make check || true
make install
# Create symlinks
cd /usr/bin
ln -sfv gzip gunzip
ln -sfv gzip zcat
cd /sources
rm -rf "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

View File

@@ -0,0 +1,41 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8: iproute2
# ============================================================================
# Purpose: Build iproute2 (ip, tc, ss utilities for network configuration).
# Modern replacement for net-tools (ifconfig, route, etc).
# Inputs: /sources/iproute2-6.13.0.tar.xz
# Outputs: ip, tc, ss, tc binaries in /usr/sbin/, libraries in /usr/lib/
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.68
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="iproute2"
VERSION="6.13.0"
echo "=== Building ${PACKAGE}-${VERSION} ==="
cd /sources
tar -xf "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
sed -i /ARPD/d Makefile
rm -fv man/man8/arpd.8
./configure
make
make SBINDIR=/usr/sbin install
# Create some important symlinks
cd /usr/sbin
ln -sfv ../lib/iptables/xtables-legacy-multi xtables-legacy-multi 2>/dev/null || true
ln -sfv ../lib/iptables/xtables-nft-multi xtables-nft-multi 2>/dev/null || true
cd /sources
rm -rf "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

45
toolchain/scripts/163-kbd.sh Executable file
View File

@@ -0,0 +1,45 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8: kbd
# ============================================================================
# Purpose: Build kbd (loadkeys, dumpkeys, kbd_mode, setfont utilities).
# Provides keyboard and font configuration tools.
# Inputs: /sources/kbd-2.7.1.tar.xz
# Outputs: kbd utilities in /usr/bin/, keymaps in /usr/share/kbd/
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.69
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="kbd"
VERSION="2.7.1"
echo "=== Building ${PACKAGE}-${VERSION} ==="
cd /sources
tar -xf "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
patch -Np1 -i ../kbd-${VERSION}-backspace-1.patch 2>/dev/null || \
echo "WARNING: kbd backspace patch not found, continuing..."
sed -i '/RESIZECONS_PROGS=/s/yes/no/' configure
sed -i 's/resizecons.8 //' docs/man/man8/Makefile.in
./configure --prefix=/usr --disable-vlock
make
# Optional: run tests
# make check || true
make install
# Create /usr/share/doc/kbd-VERSION for documentation
mkdir -pv /usr/share/doc/kbd-${VERSION}
cp -R -v docs/doc/* /usr/share/doc/kbd-${VERSION}
cd /sources
rm -rf "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

View File

@@ -0,0 +1,35 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8: libpipeline
# ============================================================================
# Purpose: Build libpipeline (C library for setting up and running
# pipelines). Required dependency for man-db.
# Inputs: /sources/libpipeline-1.5.8.tar.gz
# Outputs: libpipeline library in /usr/lib/, headers in /usr/include/
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.70
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="libpipeline"
VERSION="1.5.8"
echo "=== Building ${PACKAGE}-${VERSION} ==="
cd /sources
tar -xf "${PACKAGE}-${VERSION}.tar.gz"
cd "${PACKAGE}-${VERSION}"
./configure --prefix=/usr
make
# Optional: run tests
# make check || true
make install
cd /sources
rm -rf "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

35
toolchain/scripts/165-make.sh Executable file
View File

@@ -0,0 +1,35 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8: make
# ============================================================================
# Purpose: Build GNU make (final version). This is the FULL build,
# replacing the temporary make built in Phase 0.
# Inputs: /sources/make-4.4.1.tar.gz
# Outputs: make binary in /usr/bin/, libraries in /usr/lib/
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.71
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="make"
VERSION="4.4.1"
echo "=== Building ${PACKAGE}-${VERSION} (Full) ==="
cd /sources
tar -xf "${PACKAGE}-${VERSION}.tar.gz"
cd "${PACKAGE}-${VERSION}"
./configure --prefix=/usr
make
# Optional: run tests
# make check || true
make install
cd /sources
rm -rf "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

35
toolchain/scripts/166-patch.sh Executable file
View File

@@ -0,0 +1,35 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8: patch
# ============================================================================
# Purpose: Build GNU patch (applies patches to files).
# Essential for applying LFS and DarkForge patches to source code.
# Inputs: /sources/patch-2.7.6.tar.xz
# Outputs: patch binary in /usr/bin/
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.72
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="patch"
VERSION="2.7.6"
echo "=== Building ${PACKAGE}-${VERSION} ==="
cd /sources
tar -xf "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
./configure --prefix=/usr
make
# Optional: run tests
# make check || true
make install
cd /sources
rm -rf "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

38
toolchain/scripts/167-tar.sh Executable file
View File

@@ -0,0 +1,38 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8: tar
# ============================================================================
# Purpose: Build GNU tar (archive creation and extraction).
# Essential for handling .tar, .tar.gz, .tar.xz files.
# Inputs: /sources/tar-1.35.tar.xz
# Outputs: tar binary in /usr/bin/
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.73
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="tar"
VERSION="1.35"
echo "=== Building ${PACKAGE}-${VERSION} ==="
cd /sources
tar -xf "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
FORCE_UNSAFE_CONFIGURE=1 ./configure --prefix=/usr
make
# Optional: run tests (may take significant time)
# make check || true
make install
# Create symlink for consistency with some build scripts
ln -sfv tar /usr/bin/gtar
cd /sources
rm -rf "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

View File

@@ -0,0 +1,38 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8: texinfo
# ============================================================================
# Purpose: Build texinfo (GNU documentation format tools: makeinfo, install-info).
# Used for processing .info files and generating documentation.
# Inputs: /sources/texinfo-7.2.tar.xz
# Outputs: texinfo utilities in /usr/bin/, libraries in /usr/lib/
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.74
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="texinfo"
VERSION="7.2"
echo "=== Building ${PACKAGE}-${VERSION} ==="
cd /sources
tar -xf "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
./configure --prefix=/usr
make
# Optional: run tests
# make check || true
make install
# Optional: install the Info documentation (build from source)
# make TEXMF=/usr/share/texmf install-tex
cd /sources
rm -rf "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

46
toolchain/scripts/169-vim.sh Executable file
View File

@@ -0,0 +1,46 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8: vim
# ============================================================================
# Purpose: Build vim (Vi Improved — text editor).
# Provides vi and vim commands for system administration and editing.
# Inputs: /sources/vim-9.1.1166.tar.gz
# Outputs: vim, ex, view binaries in /usr/bin/, libraries in /usr/lib/
# Assumes: Running inside chroot, without X11
# Ref: LFS 13.0 §8.75
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="vim"
VERSION="9.1.1166"
echo "=== Building ${PACKAGE}-${VERSION} ==="
cd /sources
tar -xf "${PACKAGE}-${VERSION}.tar.gz"
cd "${PACKAGE}-${VERSION}"
# Configure for a minimal build without X11 (console-only)
./configure \
--prefix=/usr \
--with-features=huge \
--enable-gui=no \
--enable-cscope=yes \
--with-python3-command=/usr/bin/python3
make
# Optional: run tests
# make check || true
make install
# Create symlinks for vi (some scripts expect it)
ln -sfv vim /usr/bin/vi
ln -sfv vim /usr/bin/ex
ln -sfv vim /usr/bin/view
cd /sources
rm -rf "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

View File

@@ -0,0 +1,32 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8: markupsafe
# ============================================================================
# Purpose: Build MarkupSafe (Python library for safe string escaping).
# Dependency for Jinja2, which is needed for various build tools.
# Inputs: /sources/markupsafe-3.0.2.tar.gz
# Outputs: Python package installed to /usr/lib/python3.x/
# Assumes: Running inside chroot, Python3 installed
# Ref: LFS 13.0 §8.76
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="MarkupSafe"
VERSION="3.0.2"
PKG_LOWER="markupsafe"
echo "=== Building ${PACKAGE}-${VERSION} ==="
cd /sources
tar -xf "${PKG_LOWER}-${VERSION}.tar.gz"
cd "${PKG_LOWER}-${VERSION}"
# Use pip to install in editable mode for development
pip3 install --no-build-isolation .
cd /sources
rm -rf "${PKG_LOWER}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

32
toolchain/scripts/171-jinja2.sh Executable file
View File

@@ -0,0 +1,32 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8: jinja2
# ============================================================================
# Purpose: Build Jinja2 (Python templating engine).
# Required by meson and other build tools for code generation.
# Inputs: /sources/jinja2-3.1.6.tar.gz
# Outputs: Python package installed to /usr/lib/python3.x/
# Assumes: Running inside chroot, Python3 and MarkupSafe installed
# Ref: LFS 13.0 §8.77
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="Jinja2"
VERSION="3.1.6"
PKG_LOWER="jinja2"
echo "=== Building ${PACKAGE}-${VERSION} ==="
cd /sources
tar -xf "${PKG_LOWER}-${VERSION}.tar.gz"
cd "${PKG_LOWER}-${VERSION}"
# Use pip to install
pip3 install --no-build-isolation .
cd /sources
rm -rf "${PKG_LOWER}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

52
toolchain/scripts/172-eudev.sh Executable file
View File

@@ -0,0 +1,52 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8: eudev
# ============================================================================
# Purpose: Build eudev (udev without systemd dependencies).
# Device manager for /dev and /sys — required for kernel device support.
# This replaces LFS §8.78 (systemd-udev) as per DarkForge spec.
# Inputs: /sources/eudev-3.2.14.tar.gz
# Outputs: eudev daemon, rules, and libraries in /usr/, /etc/udev/
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.78 (adapted for eudev instead of systemd-udev)
# https://github.com/eudev-project/eudev
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="eudev"
VERSION="3.2.14"
echo "=== Building ${PACKAGE}-${VERSION} ==="
cd /sources
tar -xf "${PACKAGE}-${VERSION}.tar.gz"
cd "${PACKAGE}-${VERSION}"
# eudev can be built standalone without systemd
./configure \
--prefix=/usr \
--sysconfdir=/etc \
--with-rootprefix=/ \
--enable-manpages \
--disable-static
make
# Optional: run tests
# make check || true
make install
# Create the udev rules directory (may not be created by default)
mkdir -pv /etc/udev/rules.d
# Create udev control socket directory
mkdir -pv /run/udev
# Set permissions on the udev socket
chmod -v 755 /run/udev
cd /sources
rm -rf "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

55
toolchain/scripts/173-man-db.sh Executable file
View File

@@ -0,0 +1,55 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8: man-db
# ============================================================================
# Purpose: Build man-db (man page indexing and viewing).
# Provides man, whatis, apropos utilities for reading documentation.
# Inputs: /sources/man-db-2.13.0.tar.xz
# /sources/man-pages-6.12.tar.xz
# Outputs: man-db utilities and man pages in /usr/bin/, /usr/share/man/
# Assumes: Running inside chroot, libpipeline installed
# Ref: LFS 13.0 §8.79
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="man-db"
VERSION="2.13.0"
PAGES_VERSION="6.12"
echo "=== Building ${PACKAGE}-${VERSION} ==="
cd /sources
tar -xf "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
# Configure man-db to use the appropriate database location
./configure \
--prefix=/usr \
--docdir=/usr/share/doc/man-db-${VERSION} \
--sysconfdir=/etc \
--disable-setuid \
--enable-cache-owner=bin \
--with-browser=/usr/bin/lynx \
--with-pager=/usr/bin/less \
--with-col=/usr/bin/col
make
# Optional: run tests
# make check || true
make install
# Install man pages
echo ">>> Installing man-pages-${PAGES_VERSION}..."
cd /sources
tar -xf man-pages-${PAGES_VERSION}.tar.xz
cd man-pages-${PAGES_VERSION}
make prefix=/usr install
cd /sources
rm -rf "${PACKAGE}-${VERSION}"
rm -rf man-pages-${PAGES_VERSION}
echo "=== ${PACKAGE}-${VERSION} and man-pages complete ==="

View File

@@ -0,0 +1,41 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8: procps-ng
# ============================================================================
# Purpose: Build procps-ng (ps, top, uptime, pgrep, pkill utilities).
# Provides tools for process monitoring and control.
# Inputs: /sources/procps-ng-4.0.5.tar.xz
# Outputs: procps utilities in /usr/bin/ and /usr/sbin/
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.80
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="procps-ng"
VERSION="4.0.5"
echo "=== Building ${PACKAGE}-${VERSION} ==="
cd /sources
tar -xf "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
./configure \
--prefix=/usr \
--exec-prefix= \
--libdir=/lib \
--docdir=/usr/share/doc/procps-ng-${VERSION} \
--disable-static \
--disable-kill
make
# Optional: run tests
# make check || true
make install
cd /sources
rm -rf "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

View File

@@ -0,0 +1,44 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8: util-linux (Full Build)
# ============================================================================
# Purpose: Build util-linux with full feature set.
# This is the FULL build after temporary build in chapter 7.
# Provides: mount, fdisk, lsblk, findfs, chfn, chsh, login, etc.
# Inputs: /sources/util-linux-2.40.4.tar.xz
# Outputs: util-linux utilities and libraries in /usr/
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.81
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="util-linux"
VERSION="2.40.4"
echo "=== Building ${PACKAGE}-${VERSION} (Full) ==="
cd /sources
tar -xf "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
# Create the adjtime file location (used by hwclock)
mkdir -pv /var/lib/hwclock
# Full build with all features (unlike temp build in chapter 7)
# --disable-lsfd: fixes conflict with glibc 2.43 bsearch macro
./configure \
--libdir=/usr/lib \
--runstatedir=/run \
--disable-lsfd
make
# Optional: run tests
# make check || true
make install
cd /sources
rm -rf "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

View File

@@ -0,0 +1,51 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8: e2fsprogs
# ============================================================================
# Purpose: Build e2fsprogs (ext2/3/4 filesystem utilities: mkfs.ext4, fsck.ext4, etc).
# Essential for creating and maintaining ext4 filesystems.
# Inputs: /sources/e2fsprogs-1.47.2.tar.gz
# Outputs: e2fsprogs utilities in /usr/sbin/, libraries in /usr/lib/
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.82
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="e2fsprogs"
VERSION="1.47.2"
echo "=== Building ${PACKAGE}-${VERSION} ==="
cd /sources
tar -xf "${PACKAGE}-${VERSION}.tar.gz"
cd "${PACKAGE}-${VERSION}"
# Note: LFS builds e2fsprogs with a split (build in separate dir)
# We do a simpler in-place build for DarkForge
mkdir -pv build
cd build
../configure \
--prefix=/usr \
--sysconfdir=/etc \
--enable-elf-shlibs \
--disable-libblkid \
--disable-libuuid \
--disable-uuidd \
--disable-fsck
make
# Optional: run tests
# make check || true
make install
make install-libs
# Set proper permissions on important utilities
chmod -v u+w /usr/lib/lib{e2p,ext2fs}.a
cd /sources
rm -rf "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

View File

@@ -0,0 +1,47 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8: sysklogd
# ============================================================================
# Purpose: Build sysklogd (syslog daemon for system logging).
# Provides syslogd and klogd for capturing kernel and system messages.
# Inputs: /sources/sysklogd-2.7.0.tar.gz
# Outputs: syslogd, klogd in /usr/sbin/, configuration in /etc/syslog.conf
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.83
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="sysklogd"
VERSION="2.7.0"
echo "=== Building ${PACKAGE}-${VERSION} ==="
cd /sources
tar -xf "${PACKAGE}-${VERSION}.tar.gz"
cd "${PACKAGE}-${VERSION}"
make
make BINDIR=/usr/sbin install
# Create a basic syslog.conf if not present
if [ ! -f /etc/syslog.conf ]; then
cat > /etc/syslog.conf << "EOF"
# /etc/syslog.conf --- syslogd configuration file
*.*;auth,authpriv.none -/var/log/syslog
auth,authpriv.* /var/log/auth.log
*.*;auth,authpriv.none -/var/log/syslog
kern.* -/var/log/kernel.log
mail.* -/var/log/mail.log
mail.err /var/log/mail.err
cron.* /var/log/cron.log
*.err /var/log/error.log
*.warn /var/log/warn.log
EOF
fi
cd /sources
rm -rf "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

View File

@@ -0,0 +1,46 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8: sysvinit
# ============================================================================
# Purpose: Build sysvinit (init, runlevels, halt, shutdown, etc.).
# Core init system for DarkForge (replaces systemd as per spec).
# Inputs: /sources/sysvinit-3.14.tar.xz
# /sources/sysvinit-3.14-consolidated-1.patch
# Outputs: init, shutdown, halt, reboot in /sbin/
# Assumes: Running inside chroot
# Ref: LFS 13.0 §8.84
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
PACKAGE="sysvinit"
VERSION="3.14"
echo "=== Building ${PACKAGE}-${VERSION} ==="
cd /sources
tar -xf "${PACKAGE}-${VERSION}.tar.xz"
cd "${PACKAGE}-${VERSION}"
# Apply consolidated patch for compatibility fixes
patch -Np1 -i ../sysvinit-${VERSION}-consolidated-1.patch
# Build without sulogin (password-protected root shell) for simplicity
make -C src
make -C src install DESTDIR=/
# Create necessary directories for sysvinit
mkdir -pv /etc/rc.d/init.d
mkdir -pv /etc/rc.d/rc0.d
mkdir -pv /etc/rc.d/rc1.d
mkdir -pv /etc/rc.d/rc2.d
mkdir -pv /etc/rc.d/rc3.d
mkdir -pv /etc/rc.d/rc4.d
mkdir -pv /etc/rc.d/rc5.d
mkdir -pv /etc/rc.d/rc6.d
cd /sources
rm -rf "${PACKAGE}-${VERSION}"
echo "=== ${PACKAGE}-${VERSION} complete ==="

View File

@@ -0,0 +1,63 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 3, Chapter 8: Strip Binaries and Clean Up
# ============================================================================
# Purpose: Remove debugging symbols from all installed binaries to reduce
# system size. This is the final cleanup step before boot testing.
# LFS §8.85-87 combined.
# Inputs: All installed binaries and libraries in /usr/
# Outputs: Stripped binaries, cleaned system
# Assumes: Running inside chroot, all Phase 3 packages built
# Ref: LFS 13.0 §8.85, §8.86, §8.87
# ============================================================================
set -euo pipefail
source /sources/toolchain-scripts/100-chroot-env.sh
echo "=== Stripping symbols from binaries and libraries ==="
# Strip unneeded symbols from all installed binaries and libraries
# This is safe to do (doesn't affect functionality) and saves disk space
strip --strip-all /usr/lib/* 2>/dev/null || true
strip --strip-all /usr/bin/* 2>/dev/null || true
strip --strip-all /usr/sbin/* 2>/dev/null || true
# Also strip libraries in standard lib directory
strip --strip-all /lib/* 2>/dev/null || true
strip --strip-all /sbin/* 2>/dev/null || true
echo ">>> Binaries stripped"
# Remove unnecessary files
echo ">>> Cleaning up unnecessary files..."
# Remove duplicate man pages if any
find /usr/share/man -type f -name "*.gz" | while read f; do
if [ -f "${f%.gz}" ]; then
rm -f "$f"
fi
done
# Remove empty directories
find /usr -type d -empty -delete 2>/dev/null || true
find /var -type d -empty -delete 2>/dev/null || true
echo ">>> Cleanup complete"
# Report final system size
echo ""
echo "=== System size report ==="
du -sh /usr 2>/dev/null || true
du -sh /lib 2>/dev/null || true
du -sh /bin 2>/dev/null || true
du -sh /sbin 2>/dev/null || true
du -sh /var 2>/dev/null || true
echo ""
echo "=== Stripping and cleanup complete ==="
echo ""
echo "System is ready for boot testing. Next steps:"
echo " 1. Exit chroot (exit or Ctrl+D)"
echo " 2. Build kernel (Phase 4)"
echo " 3. Configure init system (Phase 5)"
echo " 4. Test in QEMU"

View File

@@ -0,0 +1,227 @@
# LFS Chapter 8 Build Scripts
This directory contains 13 build scripts that construct the complete base system for DarkForge Linux inside a chroot environment.
## Quick Reference
Run these scripts in sequence **inside the chroot**:
```bash
cd /sources/toolchain-scripts
# Foundation (required before anything else)
./101-man-pages.sh
./102-iana-etc.sh
./103-glibc.sh # CRITICAL — System transitions to native here
# Compression libraries
./104-zlib.sh
./105-bzip2.sh
./106-xz.sh
./107-lz4.sh
./108-zstd.sh
# Utilities and build tools
./109-file.sh
./110-readline.sh
./111-m4.sh
./112-bc.sh
./113-flex.sh
```
## Scripts
### 101-man-pages.sh
- **Package:** Man-Pages 6.12
- **Purpose:** System call and library function documentation
- **LFS Reference:** Chapter 8.3
- **Time:** < 1 minute (just installation, no compilation)
- **Critical deps:** None
### 102-iana-etc.sh
- **Package:** IANA-Etc 20250306
- **Purpose:** Protocol and service name definitions (`/etc/services`, `/etc/protocols`)
- **LFS Reference:** Chapter 8.4
- **Time:** < 1 minute (just installation)
- **Critical deps:** None
### 103-glibc.sh ⭐ CRITICAL
- **Package:** Glibc 2.43
- **Purpose:** The GNU C Library (complete native version)
- **LFS Reference:** Chapter 8.5
- **Time:** 5-10 minutes
- **Key additions:**
- Applies `glibc-fhs-1.patch` for FHS compliance
- Generates `en_US.UTF-8` locale
- Sets up timezone data (defaults to UTC)
- Creates `/etc/nsswitch.conf`
- Runs comprehensive sanity checks
- **Critical deps:** Previous toolchain (binutils, gcc cross-compiled), Linux headers
- **Post-build verification:**
```bash
/usr/lib/libc.so.6 exists
ldd works
Simple C program executes
```
### 104-zlib.sh
- **Package:** Zlib 1.3.2
- **Purpose:** Compression library (critical for many tools)
- **LFS Reference:** Chapter 8.6
- **Time:** < 2 minutes
- **Includes:** `make check` test suite
- **Critical deps:** Glibc (103)
### 105-bzip2.sh
- **Package:** Bzip2 1.0.8
- **Purpose:** Bzip2 compression utility and library
- **LFS Reference:** Chapter 8.7
- **Time:** < 2 minutes
- **Special:** Applies `bzip2-1.0.8-install_docs-1.patch` for documentation
- **Non-standard build:** Uses `Makefile-libbz2_so` for dynamic library
- **Critical deps:** Glibc (103)
### 106-xz.sh
- **Package:** XZ Utils 5.8.1
- **Purpose:** LZMA compression utilities (needed for `.tar.xz` files)
- **LFS Reference:** Chapter 8.8
- **Time:** 2-3 minutes
- **Note:** Handles both `.tar.gz` and `.tar.xz` tarball formats
- **Critical deps:** Glibc (103)
### 107-lz4.sh
- **Package:** LZ4 1.10.0
- **Purpose:** Fast LZ4 compression library and tools
- **LFS Reference:** Chapter 8.9
- **Time:** < 1 minute
- **Non-standard:** Custom Makefile (not autoconf)
- **Critical deps:** Glibc (103)
### 108-zstd.sh
- **Package:** Zstd 1.5.7
- **Purpose:** Zstandard compression (modern compression algorithm)
- **LFS Reference:** Chapter 8.10
- **Time:** 3-5 minutes (heavy optimization)
- **Non-standard:** Custom Makefile (not autoconf)
- **Critical deps:** Glibc (103)
### 109-file.sh
- **Package:** File 5.47
- **Purpose:** File type detection command and libmagic library
- **LFS Reference:** Chapter 8.11
- **Time:** < 2 minutes
- **Includes:** `make check` test suite
- **Critical deps:** Glibc (103), Zlib (104)
### 110-readline.sh
- **Package:** Readline 8.3
- **Purpose:** Command-line editing and history library
- **LFS Reference:** Chapter 8.12
- **Time:** < 2 minutes
- **Includes:** Documentation installation
- **Links with:** ncurses library
- **Critical deps:** Glibc (103), ncurses (from earlier phases)
### 111-m4.sh
- **Package:** M4 1.4.21
- **Purpose:** Macro processing language (required for autoconf/automake)
- **LFS Reference:** Chapter 8.14
- **Time:** < 2 minutes
- **Includes:** `make check` test suite
- **Critical deps:** Glibc (103)
### 112-bc.sh
- **Package:** Bc 7.0.3
- **Purpose:** Arbitrary-precision calculator
- **LFS Reference:** Chapter 8.15
- **Time:** 1-2 minutes
- **Non-standard:** Custom configure script (not typical GNU autoconf)
- **Includes:** `make test` suite
- **Critical deps:** Glibc (103)
### 113-flex.sh
- **Package:** Flex 2.6.4
- **Purpose:** Lexical scanner generator (replaces older 'lex')
- **LFS Reference:** Chapter 8.16
- **Time:** 2-3 minutes
- **Includes:** `make check` test suite
- **Special:** Creates `/usr/bin/lex` symlink for legacy compatibility
- **Critical deps:** Glibc (103)
## Environment
All scripts automatically source `/sources/toolchain-scripts/100-chroot-env.sh`, which provides:
```bash
# AMD Zen 5 specific compilation flags
CFLAGS="-march=znver5 -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"
LDFLAGS="-Wl,-O1,--as-needed"
MAKEFLAGS="-j32" # Full CPU utilization (16 cores × 2)
# Helper functions
pkg_extract(TARBALL) # Extract and cd into source dir
pkg_cleanup(DIRNAME) # Remove source directory after build
```
## Troubleshooting
### General Issues
1. **"Permission denied" when running script**
```bash
chmod +x 10X-*.sh
```
2. **"file not found" for tarball**
- Ensure `/sources/` contains all tarballs
- Check `100-download-phase3.sh` for correct filenames
3. **"patch does not apply"**
- Verify you're in the correct directory after extraction
- Check patch is in `/sources/` with correct filename
### Build Failures
- All scripts use `set -euo pipefail`, so they stop immediately on errors
- Check the error output for missing dependencies or configuration issues
- Ensure previous scripts completed successfully before running the next one
### Most Common Issue
**Glibc (103) fails** — This is usually because:
1. The FHS patch didn't apply correctly
2. Linux headers are missing from `/usr/include/`
3. Previous cross-compiled toolchain is broken
Verify all Phase 0-2 scripts ran successfully before attempting Phase 3.
## Documentation
For detailed information about each package and the build process, see:
- `/sessions/awesome-gallant-bell/mnt/lfs_auto_install/docs/CHAPTER8-SCRIPTS.md`
For the complete LFS reference:
- `/sessions/awesome-gallant-bell/mnt/lfs_auto_install/reference/LFS-BOOK-r13.0-4-NOCHUNKS.html`
## Statistics
- **Total scripts:** 13
- **Total size:** ~20 KB
- **Estimated total build time:** 30-45 minutes (on 16-core CPU)
- **Line of code:** ~450 lines (across all scripts)
## Next Steps
After these 13 scripts complete successfully:
1. Continue with Phase 3 remaining packages (Chapter 8.17+)
2. Build the Linux kernel (Phase 4)
3. Configure init system (sysvinit) (Phase 5)
4. Install desktop environment (dwl/Wayland) (Phase 6+)
---
**Created:** 2026-03-20
**Target:** DarkForge Linux (AMD Zen 5 build)
**Reference:** LFS 13.0 Chapter 8