Changed bootstrap

This commit is contained in:
2026-03-20 13:22:01 +01:00
parent 7de732589a
commit 4afba9b11e
4 changed files with 161 additions and 22 deletions

View File

@@ -2,6 +2,27 @@
--- ---
## V41 2026-03-21 00:30:00
**Fix chroot PATH and add combined chroot build runner**
### Changes:
- Fixed `023-chroot-setup.sh`: Added `/tools/bin` to chroot PATH. The cross-compiled
GCC lives at `/tools/bin/gcc` inside the chroot — without it in PATH, configure
fails with "C compiler cannot create executables"
- Added `023a-chroot-build-all.sh`: Combined runner that enters chroot and executes
scripts 024-031 in sequence with logging. No more manual copy-paste of 8 commands.
- Updated `toolchain/bootstrap.sh`: Now runs all 6 steps end-to-end including chroot
phase. Single `sudo -E bash toolchain/bootstrap.sh` does everything.
### Plan deviation/changes:
- None
### What is missing/needs polish:
- None
---
## V40 2026-03-21 00:00:00 ## V40 2026-03-21 00:00:00
**Fix cross-compile configure failures in diffutils, grep, coreutils, tar, findutils** **Fix cross-compile configure failures in diffutils, grep, coreutils, tar, findutils**

View File

@@ -7,7 +7,8 @@
# 2. Set up directory structure, lfs user, env files # 2. Set up directory structure, lfs user, env files
# 3. Download source tarballs # 3. Download source tarballs
# 4. Copy toolchain scripts to $LFS so lfs user can access them # 4. Copy toolchain scripts to $LFS so lfs user can access them
# 5. Launch build-all.sh as the lfs user # 5. Build cross-toolchain as lfs user (Chapters 5+6)
# 6. Enter chroot and build Chapter 7 tools
# #
# Usage: sudo -E bash toolchain/bootstrap.sh # Usage: sudo -E bash toolchain/bootstrap.sh
# (run from the project root, e.g. /home/danny/darkforge) # (run from the project root, e.g. /home/danny/darkforge)
@@ -53,28 +54,28 @@ echo ""
# ============================================================================= # =============================================================================
# Step 1: Create fresh loopback filesystem # Step 1: Create fresh loopback filesystem
# ============================================================================= # =============================================================================
info "STEP 1/5: Setting up build filesystem..." info "STEP 1/6: Setting up build filesystem..."
bash "${SCRIPT_SRC}/000-setup-disk.sh" bash "${SCRIPT_SRC}/000-setup-disk.sh"
echo "" echo ""
# ============================================================================= # =============================================================================
# Step 2: Set up directory structure, lfs user, and env # Step 2: Set up directory structure, lfs user, and env
# ============================================================================= # =============================================================================
info "STEP 2/5: Setting up environment..." info "STEP 2/6: Setting up environment..."
bash "${SCRIPT_SRC}/000-env-setup.sh" bash "${SCRIPT_SRC}/000-env-setup.sh"
echo "" echo ""
# ============================================================================= # =============================================================================
# Step 3: Download all source tarballs # Step 3: Download all source tarballs
# ============================================================================= # =============================================================================
info "STEP 3/5: Downloading source tarballs..." info "STEP 3/6: Downloading source tarballs..."
bash "${SCRIPT_SRC}/000a-download-sources.sh" bash "${SCRIPT_SRC}/000a-download-sources.sh"
echo "" echo ""
# ============================================================================= # =============================================================================
# Step 4: Copy toolchain scripts to $LFS/sources/toolchain-scripts/ # Step 4: Copy toolchain scripts to $LFS/sources/toolchain-scripts/
# ============================================================================= # =============================================================================
info "STEP 4/5: Copying toolchain scripts to ${LFS}/sources/toolchain-scripts/..." info "STEP 4/6: Copying toolchain scripts to ${LFS}/sources/toolchain-scripts/..."
SCRIPTS_DEST="${LFS}/sources/toolchain-scripts" SCRIPTS_DEST="${LFS}/sources/toolchain-scripts"
rm -rf "${SCRIPTS_DEST}" rm -rf "${SCRIPTS_DEST}"
mkdir -p "${SCRIPTS_DEST}" mkdir -p "${SCRIPTS_DEST}"
@@ -87,7 +88,7 @@ echo ""
# ============================================================================= # =============================================================================
# Step 5: Run build-all.sh as lfs user # Step 5: Run build-all.sh as lfs user
# ============================================================================= # =============================================================================
info "STEP 5/5: Building cross-toolchain as lfs user..." info "STEP 5/6: Building cross-toolchain as lfs user..."
echo " This will take a while (30-60+ minutes on 32 threads)." echo " This will take a while (30-60+ minutes on 32 threads)."
echo " Logs will be in: ${LFS}/sources/logs/" echo " Logs will be in: ${LFS}/sources/logs/"
echo "" echo ""
@@ -106,22 +107,27 @@ env -i HOME=/home/lfs TERM="${TERM}" \
fail "Build failed! Check logs in ${LFS}/sources/logs/" fail "Build failed! Check logs in ${LFS}/sources/logs/"
} }
ok "Cross-compilation phase (Chapters 5+6) complete!"
echo ""
# =============================================================================
# Step 6: Set up chroot and run Chapter 7 scripts
# =============================================================================
info "STEP 6/6: Setting up chroot and building Chapter 7 tools..."
echo ""
bash "${SCRIPTS_DEST}/023-chroot-setup.sh"
bash "${SCRIPTS_DEST}/023a-chroot-build-all.sh"
echo "" echo ""
echo "============================================================" echo "============================================================"
echo -e "${GREEN} Phase 0 cross-compilation complete!${NC}" echo -e "${GREEN} Phase 0 is FULLY COMPLETE!${NC}"
echo "============================================================" echo "============================================================"
echo "" echo ""
echo "Next steps (run as root):" echo "The DarkForge toolchain chroot is ready."
echo "To enter the chroot manually:"
echo "" echo ""
echo " # Enter the chroot environment:" echo " sudo chroot ${LFS} /usr/bin/env -i \\"
echo " sudo -E bash ${SCRIPTS_DEST}/023-chroot-setup.sh" echo " HOME=/root TERM=\${TERM} \\"
echo "" echo " PATH=/usr/bin:/usr/sbin:/tools/bin \\"
echo " # Then inside chroot, run these in order:" echo " MAKEFLAGS=\"-j32\" /bin/bash --login"
echo " bash /sources/toolchain-scripts/024-chroot-essentials.sh"
echo " bash /sources/toolchain-scripts/025-gettext.sh"
echo " bash /sources/toolchain-scripts/026-bison.sh"
echo " bash /sources/toolchain-scripts/027-perl.sh"
echo " bash /sources/toolchain-scripts/028-python.sh"
echo " bash /sources/toolchain-scripts/029-texinfo.sh"
echo " bash /sources/toolchain-scripts/030-util-linux.sh"
echo " bash /sources/toolchain-scripts/031-cleanup.sh"

View File

@@ -84,8 +84,9 @@ echo " chroot \"${LFS}\" /usr/bin/env -i \\"
echo " HOME=/root \\" echo " HOME=/root \\"
echo " TERM=\"\${TERM}\" \\" echo " TERM=\"\${TERM}\" \\"
echo " PS1='(darkforge chroot) \\u:\\w\\\$ ' \\" echo " PS1='(darkforge chroot) \\u:\\w\\\$ ' \\"
echo " PATH=/usr/bin:/usr/sbin \\" echo " PATH=/usr/bin:/usr/sbin:/tools/bin \\"
echo " MAKEFLAGS=\"-j32\" \\" echo " MAKEFLAGS=\"-j32\" \\"
echo " /bin/bash --login" echo " /bin/bash --login"
echo "" echo ""
echo "Then run the chroot build scripts (024-xxx) from inside the chroot." echo "Or run all chroot scripts automatically:"
echo " bash ${LFS}/sources/toolchain-scripts/023a-chroot-build-all.sh"

View File

@@ -0,0 +1,111 @@
#!/bin/bash
# ============================================================================
# DarkForge Linux — Phase 0, Chapter 7: Run All Chroot Build Scripts
# ============================================================================
# Purpose: Enters the chroot and runs scripts 024-031 in sequence.
# This is a convenience wrapper — run it on the HOST as root,
# AFTER 023-chroot-setup.sh has mounted virtual filesystems.
# Usage: sudo bash /mnt/darkforge/sources/toolchain-scripts/023a-chroot-build-all.sh
# Inputs: LFS environment variable (default: /mnt/darkforge)
# Outputs: Completed chroot tools (gettext, bison, perl, python, texinfo, util-linux)
# Assumes: 023-chroot-setup.sh already ran, virtual filesystems mounted
# ============================================================================
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'
NC='\033[0m'
ok() { echo -e "${GREEN}>>> $*${NC}"; }
warn() { echo -e "${YELLOW}>>> $*${NC}"; }
fail() { echo -e "${RED}>>> $*${NC}"; exit 1; }
[ "$(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
echo "============================================================"
echo " DarkForge Linux — Chroot Build Phase (Chapter 7)"
echo "============================================================"
echo ""
# Build a script that runs inside the chroot
# We write it to a temp file inside $LFS so the chroot can see it
cat > "${LFS}/tmp/chroot-build-runner.sh" << 'CHROOT_EOF'
#!/bin/bash
set -euo pipefail
SCRIPTS="/sources/toolchain-scripts"
LOG_DIR="/sources/logs"
mkdir -p "${LOG_DIR}"
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
run_script() {
local script="$1"
local name
name=$(basename "${script}" .sh)
local logfile="${LOG_DIR}/${name}.log"
echo -e "${YELLOW}>>> [$(date '+%H:%M:%S')] Starting: ${name}${NC}"
if bash "${script}" 2>&1 | tee "${logfile}"; then
echo -e "${GREEN}>>> [$(date '+%H:%M:%S')] PASSED: ${name}${NC}"
echo ""
else
echo -e "${RED}>>> [$(date '+%H:%M:%S')] FAILED: ${name}${NC}"
echo "Log file: ${logfile}"
exit 1
fi
}
echo "=== Chapter 7: Chroot Build Scripts ==="
echo ""
run_script "${SCRIPTS}/024-chroot-essentials.sh"
run_script "${SCRIPTS}/025-gettext.sh"
run_script "${SCRIPTS}/026-bison.sh"
run_script "${SCRIPTS}/027-perl.sh"
run_script "${SCRIPTS}/028-python.sh"
run_script "${SCRIPTS}/029-texinfo.sh"
run_script "${SCRIPTS}/030-util-linux.sh"
run_script "${SCRIPTS}/031-cleanup.sh"
echo ""
echo "============================================================"
echo " Chapter 7 chroot builds complete!"
echo "============================================================"
CHROOT_EOF
chmod +x "${LFS}/tmp/chroot-build-runner.sh"
# Enter chroot and run the build script
# PATH includes /tools/bin where the cross-compiled gcc lives
chroot "${LFS}" /usr/bin/env -i \
HOME=/root \
TERM="${TERM}" \
PS1='(darkforge chroot) \u:\w\$ ' \
PATH=/usr/bin:/usr/sbin:/tools/bin \
MAKEFLAGS="-j32" \
/bin/bash /tmp/chroot-build-runner.sh
# Clean up
rm -f "${LFS}/tmp/chroot-build-runner.sh"
echo ""
echo -e "${GREEN}Phase 0 is FULLY COMPLETE.${NC}"
echo ""
echo "The toolchain chroot environment is ready."
echo "Next: Phase 1 (dpack) or Phase 3 (base system packages)."