This commit is contained in:
2026-03-20 11:21:20 +01:00
parent 0d041913be
commit ad3819c9c9
4 changed files with 150 additions and 21 deletions

View File

@@ -2,6 +2,35 @@
--- ---
## V37 2026-03-20 22:30:00
**Use Danish GNU mirror and add loopback disk setup script**
### Changes:
- Updated `toolchain/scripts/000a-download-sources.sh`:
- Switched all GNU package URLs to use `http://ftp.klid.dk/ftp/gnu` mirror
(faster from Denmark than ftp.gnu.org)
- Added `GNU_MIRROR` variable at top for easy mirror switching
- Non-GNU packages (kernel, mpfr, gmp, xz, zstd, perl, python, etc.) still
use their canonical upstream URLs
- Added `toolchain/scripts/000-setup-disk.sh`:
- Creates a 50GB loopback ext4 filesystem at /opt/darkforge.img
- Mounts it at /mnt/darkforge — acts exactly like a real partition
- Uses fallocate for instant allocation (no slow dd)
- Includes remount instructions and fstab entry
- Safe: no repartitioning needed, uses free space on root
- Updated `toolchain/scripts/000-env-setup.sh`:
- Improved error message to point users to 000-setup-disk.sh
### Plan deviation/changes:
- Using loopback file instead of a dedicated partition (user has no spare
partition but has 1.5TB free on root)
### What is missing/needs polish:
- None
---
## V36 2026-03-20 22:00:00 ## V36 2026-03-20 22:00:00
**Fix Phase 0 download script — 10+ version/filename mismatches with build scripts** **Fix Phase 0 download script — 10+ version/filename mismatches with build scripts**

View File

@@ -27,7 +27,8 @@ DF_LDFLAGS="-Wl,-O1,--as-needed"
# --- Verify mount point ------------------------------------------------------ # --- Verify mount point ------------------------------------------------------
if ! mountpoint -q "${LFS}" 2>/dev/null; then if ! mountpoint -q "${LFS}" 2>/dev/null; then
echo "ERROR: ${LFS} is not a mount point." echo "ERROR: ${LFS} is not a mount point."
echo "Mount the target partition first: mount /dev/<partition> ${LFS}" echo "Run 000-setup-disk.sh first to create and mount the LFS filesystem,"
echo "or mount a partition manually: mount /dev/<partition> ${LFS}"
exit 1 exit 1
fi fi

View File

@@ -0,0 +1,97 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 0: Create LFS Build Partition (Loopback)
# ============================================================================
# Purpose: Create a loopback ext4 filesystem for the LFS build environment.
# This avoids repartitioning and uses free space on your root drive.
# The loopback file acts exactly like a real partition.
# Inputs: None (uses defaults below, override via environment)
# Outputs: 50GB ext4 filesystem mounted at /mnt/darkforge
# Assumes: Running as root, ~50GB free on root filesystem
# ============================================================================
set -euo pipefail
# --- Configuration -----------------------------------------------------------
LFS="${LFS:-/mnt/darkforge}"
LFS_IMAGE="${LFS_IMAGE:-/opt/darkforge.img}"
LFS_SIZE="${LFS_SIZE:-50G}"
# Color output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
ok() { echo -e "${GREEN}>>> $*${NC}"; }
warn() { echo -e "${YELLOW}>>> $*${NC}"; }
fail() { echo -e "${RED}>>> $*${NC}"; exit 1; }
# --- Verify running as root --------------------------------------------------
[ "$(id -u)" -eq 0 ] || fail "This script must be run as root."
echo "============================================================"
echo " DarkForge Linux — LFS Build Partition Setup"
echo "============================================================"
echo ""
echo " Image file: ${LFS_IMAGE}"
echo " Image size: ${LFS_SIZE}"
echo " Mount point: ${LFS}"
echo ""
# --- Check if already mounted ------------------------------------------------
if mountpoint -q "${LFS}" 2>/dev/null; then
ok "${LFS} is already mounted:"
df -h "${LFS}"
echo ""
echo "To start over: umount ${LFS} && rm ${LFS_IMAGE}"
exit 0
fi
# --- Check free space ---------------------------------------------------------
AVAIL_KB=$(df --output=avail / | tail -1 | tr -d ' ')
AVAIL_GB=$((AVAIL_KB / 1024 / 1024))
NEED_GB=$(echo "${LFS_SIZE}" | sed 's/G//')
if [ "${AVAIL_GB}" -lt "${NEED_GB}" ]; then
fail "Not enough free space: ${AVAIL_GB}GB available, need ${NEED_GB}GB"
fi
ok "Free space check: ${AVAIL_GB}GB available, need ${NEED_GB}GB"
# --- Create the loopback image -----------------------------------------------
if [ -f "${LFS_IMAGE}" ]; then
warn "Image file already exists: ${LFS_IMAGE}"
echo " Reusing existing image."
else
echo ">>> Creating ${LFS_SIZE} image file (this takes a moment)..."
# Use fallocate for instant allocation (no slow dd)
fallocate -l "${LFS_SIZE}" "${LFS_IMAGE}" || {
warn "fallocate failed, falling back to truncate..."
truncate -s "${LFS_SIZE}" "${LFS_IMAGE}"
}
ok "Image created: ${LFS_IMAGE}"
echo ">>> Formatting as ext4..."
mkfs.ext4 -q -L darkforge "${LFS_IMAGE}"
ok "Formatted as ext4"
fi
# --- Mount it -----------------------------------------------------------------
mkdir -p "${LFS}"
mount -o loop "${LFS_IMAGE}" "${LFS}"
ok "Mounted ${LFS_IMAGE} at ${LFS}"
echo ""
df -h "${LFS}"
echo ""
ok "LFS build partition is ready."
echo ""
echo "Next steps:"
echo " export LFS=${LFS}"
echo " bash toolchain/scripts/000-env-setup.sh"
echo ""
echo "To remount after reboot:"
echo " sudo mount -o loop ${LFS_IMAGE} ${LFS}"
echo ""
echo "To add to /etc/fstab (auto-mount on boot):"
echo " ${LFS_IMAGE} ${LFS} ext4 loop 0 0"

View File

@@ -9,17 +9,20 @@
# Outputs: Source tarballs in ${LFS}/sources/ # Outputs: Source tarballs in ${LFS}/sources/
# Assumes: Internet access, wget or curl available # Assumes: Internet access, wget or curl available
# Updated: 2026-03-20 — synced all versions with build scripts # Updated: 2026-03-20 — synced all versions with build scripts
# Mirror: Uses ftp.klid.dk (Denmark) for GNU packages — fast in EU
# ============================================================================ # ============================================================================
set -euo pipefail set -euo pipefail
LFS="${LFS:-/mnt/darkforge}" LFS="${LFS:-/mnt/darkforge}"
SRCDIR="${LFS}/sources" SRCDIR="${LFS}/sources"
GNU_MIRROR="http://ftp.klid.dk/ftp/gnu"
mkdir -p "${SRCDIR}" mkdir -p "${SRCDIR}"
cd "${SRCDIR}" cd "${SRCDIR}"
echo "=== DarkForge: Downloading source tarballs ===" echo "=== DarkForge: Downloading source tarballs ==="
echo "GNU mirror: ${GNU_MIRROR}"
# --- Helper function ---------------------------------------------------------- # --- Helper function ----------------------------------------------------------
download() { download() {
@@ -45,32 +48,32 @@ download() {
# Cross-Toolchain (Chapter 5) # Cross-Toolchain (Chapter 5)
# ============================================================================== # ==============================================================================
echo ">>> Cross-Toolchain packages..." echo ">>> Cross-Toolchain packages..."
download "https://ftp.gnu.org/gnu/binutils/binutils-2.46.tar.xz" download "${GNU_MIRROR}/binutils/binutils-2.46.tar.xz"
download "https://ftp.gnu.org/gnu/gcc/gcc-15.2.0/gcc-15.2.0.tar.xz" download "${GNU_MIRROR}/gcc/gcc-15.2.0/gcc-15.2.0.tar.xz"
download "https://ftp.gnu.org/gnu/glibc/glibc-2.43.tar.xz" download "${GNU_MIRROR}/glibc/glibc-2.43.tar.xz"
download "https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.19.8.tar.xz" download "https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.19.8.tar.xz"
download "https://www.mpfr.org/mpfr-4.2.2/mpfr-4.2.2.tar.xz" download "https://www.mpfr.org/mpfr-4.2.2/mpfr-4.2.2.tar.xz"
download "https://gmplib.org/download/gmp/gmp-6.3.0.tar.xz" download "https://gmplib.org/download/gmp/gmp-6.3.0.tar.xz"
download "https://ftp.gnu.org/gnu/mpc/mpc-1.3.1.tar.gz" download "${GNU_MIRROR}/mpc/mpc-1.3.1.tar.gz"
# ============================================================================== # ==============================================================================
# Temporary Tools (Chapter 6) # Temporary Tools (Chapter 6)
# ============================================================================== # ==============================================================================
echo ">>> Temporary tools packages..." echo ">>> Temporary tools packages..."
download "https://ftp.gnu.org/gnu/m4/m4-1.4.21.tar.xz" download "${GNU_MIRROR}/m4/m4-1.4.21.tar.xz"
download "https://invisible-island.net/datafiles/release/ncurses-6.5.tar.gz" download "https://invisible-island.net/datafiles/release/ncurses-6.5.tar.gz"
download "https://ftp.gnu.org/gnu/bash/bash-5.3.tar.gz" download "${GNU_MIRROR}/bash/bash-5.3.tar.gz"
download "https://ftp.gnu.org/gnu/coreutils/coreutils-9.6.tar.xz" download "${GNU_MIRROR}/coreutils/coreutils-9.6.tar.xz"
download "https://ftp.gnu.org/gnu/diffutils/diffutils-3.10.tar.xz" download "${GNU_MIRROR}/diffutils/diffutils-3.10.tar.xz"
download "https://astron.com/pub/file/file-5.47.tar.gz" download "https://astron.com/pub/file/file-5.47.tar.gz"
download "https://ftp.gnu.org/gnu/findutils/findutils-4.10.0.tar.xz" download "${GNU_MIRROR}/findutils/findutils-4.10.0.tar.xz"
download "https://ftp.gnu.org/gnu/gawk/gawk-5.4.0.tar.xz" download "${GNU_MIRROR}/gawk/gawk-5.4.0.tar.xz"
download "https://ftp.gnu.org/gnu/grep/grep-3.14.tar.xz" download "${GNU_MIRROR}/grep/grep-3.14.tar.xz"
download "https://ftp.gnu.org/gnu/gzip/gzip-1.14.tar.xz" download "${GNU_MIRROR}/gzip/gzip-1.14.tar.xz"
download "https://ftp.gnu.org/gnu/make/make-4.4.1.tar.gz" download "${GNU_MIRROR}/make/make-4.4.1.tar.gz"
download "https://ftp.gnu.org/gnu/patch/patch-2.8.tar.xz" download "${GNU_MIRROR}/patch/patch-2.8.tar.xz"
download "https://ftp.gnu.org/gnu/sed/sed-4.9.tar.xz" download "${GNU_MIRROR}/sed/sed-4.9.tar.xz"
download "https://ftp.gnu.org/gnu/tar/tar-1.35.tar.xz" download "${GNU_MIRROR}/tar/tar-1.35.tar.xz"
download "https://github.com/tukaani-project/xz/releases/download/v5.8.1/xz-5.8.1.tar.gz" download "https://github.com/tukaani-project/xz/releases/download/v5.8.1/xz-5.8.1.tar.gz"
download "https://github.com/facebook/zstd/releases/download/v1.5.7/zstd-1.5.7.tar.gz" download "https://github.com/facebook/zstd/releases/download/v1.5.7/zstd-1.5.7.tar.gz"
@@ -78,11 +81,11 @@ download "https://github.com/facebook/zstd/releases/download/v1.5.7/zstd-1.5.7.t
# Chroot Packages (Chapter 7) # Chroot Packages (Chapter 7)
# ============================================================================== # ==============================================================================
echo ">>> Chroot packages..." echo ">>> Chroot packages..."
download "https://ftp.gnu.org/gnu/gettext/gettext-0.23.1.tar.xz" download "${GNU_MIRROR}/gettext/gettext-0.23.1.tar.xz"
download "https://ftp.gnu.org/gnu/bison/bison-3.8.2.tar.xz" download "${GNU_MIRROR}/bison/bison-3.8.2.tar.xz"
download "https://www.cpan.org/src/5.0/perl-5.40.2.tar.xz" download "https://www.cpan.org/src/5.0/perl-5.40.2.tar.xz"
download "https://www.python.org/ftp/python/3.13.3/Python-3.13.3.tar.xz" download "https://www.python.org/ftp/python/3.13.3/Python-3.13.3.tar.xz"
download "https://ftp.gnu.org/gnu/texinfo/texinfo-7.3.tar.xz" download "${GNU_MIRROR}/texinfo/texinfo-7.3.tar.xz"
download "https://zlib.net/zlib-1.3.1.tar.xz" download "https://zlib.net/zlib-1.3.1.tar.xz"
download "https://www.kernel.org/pub/linux/utils/util-linux/v2.40/util-linux-2.40.4.tar.xz" download "https://www.kernel.org/pub/linux/utils/util-linux/v2.40/util-linux-2.40.4.tar.xz"
@@ -90,7 +93,6 @@ download "https://www.kernel.org/pub/linux/utils/util-linux/v2.40/util-linux-2.4
# Patches # Patches
# ============================================================================== # ==============================================================================
echo ">>> Patches..." echo ">>> Patches..."
# LFS 13.0 patch: glibc-2.43-fhs-1.patch (matches glibc version)
download "https://www.linuxfromscratch.org/patches/lfs/13.0/glibc-2.43-fhs-1.patch" download "https://www.linuxfromscratch.org/patches/lfs/13.0/glibc-2.43-fhs-1.patch"
echo "" echo ""