#!/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