Big script
This commit is contained in:
63
toolchain/scripts/179-strip-and-cleanup.sh
Executable file
63
toolchain/scripts/179-strip-and-cleanup.sh
Executable 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"
|
||||
Reference in New Issue
Block a user