#!/bin/bash # ============================================================================ # DarkForge Linux — Phase 0, Chapter 7: Cleanup Temporary Tools # ============================================================================ # Purpose: Clean up the temporary toolchain now that we have native tools # in the chroot. Remove documentation, static libraries, and the # cross-compiler tools directory. # Inputs: None # Outputs: Cleaned filesystem, removed /tools # Assumes: Running inside chroot, all chroot builds (024-030) complete # Ref: LFS 13.0 §7.13 # ============================================================================ set -euo pipefail echo "=== DarkForge: Cleaning up temporary tools ===" # Remove documentation installed by temporary packages rm -rf /usr/share/{info,man,doc}/* # Remove libtool .la files (they cause problems in final builds) find /usr/{lib,libexec} -name \*.la -delete 2>/dev/null || true # Remove the cross-compiler toolchain directory # We no longer need it — native compiler is in /usr/bin/gcc rm -rf /tools echo "=== Cleanup complete ===" echo "" echo ">>> PHASE 0 COMPLETE!" echo "" echo "The chroot environment now has:" echo " - Native GCC ${GCC_VERSION:-15.2.0} compiler" echo " - GNU binutils" echo " - glibc" echo " - Bash, coreutils, make, and essential build tools" echo " - Perl, Python 3, bison, gettext, texinfo" echo " - util-linux" echo "" echo "Exit criteria check: Can we compile a Hello World?" echo "" # --- Exit criteria test ------------------------------------------------------- cat > /tmp/hello.c << 'EOF' #include int main(void) { printf("DarkForge Linux: Phase 0 toolchain bootstrap successful!\n"); return 0; } EOF echo "Compiling test program..." gcc -o /tmp/hello /tmp/hello.c echo "Running test program..." /tmp/hello # Verify the binary is dynamically linked to our glibc echo "" echo "Binary details:" file /tmp/hello ldd /tmp/hello # Cleanup test rm -f /tmp/hello /tmp/hello.c echo "" echo ">>> Phase 0 exit criteria: PASSED" echo ">>> Ready to proceed to Phase 1 (dpack core)."