#!/bin/bash # Local apt-layer compilation script # This script compiles apt-layer and the installer locally set -e # Exit on any error echo "==========================================" echo "๐Ÿ”ง COMPILING APT-LAYER LOCALLY" echo "==========================================" # Check if we're in the right directory if [[ ! -f "src/apt-layer/compile.sh" ]]; then echo "โŒ Error: Please run this script from the tools directory" exit 1 fi # Make compile scripts executable echo "๐Ÿ“ Making compile scripts executable..." chmod +x src/apt-layer/compile.sh chmod +x src/apt-layer/compile-installer.sh # Compile apt-layer echo "๐Ÿ”จ Compiling apt-layer..." cd src/apt-layer ./compile.sh -o ../../apt-layer.sh cd ../.. # Compile installer echo "๐Ÿ”จ Compiling installer with latest paths.json..." cd src/apt-layer ./compile-installer.sh -o ../../install-apt-layer.sh cd ../.. # Verify compilation echo "โœ… Verifying compiled scripts..." # Check apt-layer.sh if [[ ! -f apt-layer.sh ]]; then echo "โŒ apt-layer compilation failed - apt-layer.sh not found" exit 1 fi if [[ ! -x apt-layer.sh ]]; then echo "โŒ apt-layer script is not executable" exit 1 fi # Test apt-layer.sh syntax if bash -n apt-layer.sh; then echo "โœ… apt-layer.sh syntax validation passed" else echo "โŒ apt-layer.sh syntax validation failed" exit 1 fi # Check apt-layer.sh file size file_size=$(du -h apt-layer.sh | cut -f1) echo "๐Ÿ“ฆ apt-layer.sh size: $file_size" # Count apt-layer.sh lines line_count=$(wc -l < apt-layer.sh) echo "๐Ÿ“„ apt-layer.sh lines: $line_count" # Check install-apt-layer.sh if [[ ! -f install-apt-layer.sh ]]; then echo "โŒ Installer compilation failed - install-apt-layer.sh not found" exit 1 fi if [[ ! -x install-apt-layer.sh ]]; then echo "โŒ Installer script is not executable" exit 1 fi # Test install-apt-layer.sh syntax if bash -n install-apt-layer.sh; then echo "โœ… install-apt-layer.sh syntax validation passed" else echo "โŒ install-apt-layer.sh syntax validation failed" exit 1 fi # Check install-apt-layer.sh file size installer_size=$(du -h install-apt-layer.sh | cut -f1) echo "๐Ÿ“ฆ install-apt-layer.sh size: $installer_size" # Count install-apt-layer.sh lines installer_lines=$(wc -l < install-apt-layer.sh) echo "๐Ÿ“„ install-apt-layer.sh lines: $installer_lines" # Test basic functionality echo "๐Ÿงช Testing basic functionality..." # Test apt-layer.sh help command if ./apt-layer.sh --help > /dev/null 2>&1; then echo "โœ… apt-layer.sh help command works" else echo "โŒ apt-layer.sh help command failed" exit 1 fi # Test apt-layer.sh version info if ./apt-layer.sh --version > /dev/null 2>&1; then echo "โœ… apt-layer.sh version command works" else echo "โš ๏ธ apt-layer.sh version command not available (this is optional)" fi # Test install-apt-layer.sh help command if ./install-apt-layer.sh --help > /dev/null 2>&1; then echo "โœ… install-apt-layer.sh help command works" else echo "โŒ install-apt-layer.sh help command failed" exit 1 fi # Create artifacts directory echo "๐Ÿ“ Creating artifacts directory..." mkdir -p artifacts cp apt-layer.sh artifacts/ cp install-apt-layer.sh artifacts/ # Create compilation report echo "๐Ÿ“‹ Creating compilation report..." { echo "# apt-layer Compilation Report" echo "" echo "**Compilation Date:** $(date)" echo "**Branch:** $(git branch --show-current)" echo "**Commit:** $(git rev-parse HEAD)" echo "" echo "## File Information" echo "" echo "### apt-layer.sh" echo "- **File:** apt-layer.sh" echo "- **Size:** $(du -h apt-layer.sh | cut -f1)" echo "- **Lines:** $(wc -l < apt-layer.sh)" echo "- **Executable:** $(test -x apt-layer.sh && echo "Yes" || echo "No")" echo "" echo "### install-apt-layer.sh" echo "- **File:** install-apt-layer.sh" echo "- **Size:** $(du -h install-apt-layer.sh | cut -f1)" echo "- **Lines:** $(wc -l < install-apt-layer.sh)" echo "- **Executable:** $(test -x install-apt-layer.sh && echo "Yes" || echo "No")" echo "" echo "## Validation Results" echo "- **apt-layer.sh Syntax Check:** $(bash -n apt-layer.sh && echo "โœ… Passed" || echo "โŒ Failed")" echo "- **apt-layer.sh Help Command:** $(./apt-layer.sh --help > /dev/null 2>&1 && echo "โœ… Works" || echo "โŒ Failed")" echo "- **install-apt-layer.sh Syntax Check:** $(bash -n install-apt-layer.sh && echo "โœ… Passed" || echo "โŒ Failed")" echo "- **install-apt-layer.sh Help Command:** $(./install-apt-layer.sh --help > /dev/null 2>&1 && echo "โœ… Works" || echo "โŒ Failed")" echo "" echo "## Ready for Distribution" echo "Both compiled scripts are self-contained and ready for use!" } > COMPILATION_REPORT.md cp COMPILATION_REPORT.md artifacts/ echo "==========================================" echo "๐Ÿ“ฆ COMPILATION COMPLETED SUCCESSFULLY" echo "==========================================" echo "" echo "Generated files:" echo "โœ… apt-layer.sh ($(du -h apt-layer.sh | cut -f1))" echo "โœ… install-apt-layer.sh ($(du -h install-apt-layer.sh | cut -f1))" echo "โœ… COMPILATION_REPORT.md" echo "" echo "Files are available in the artifacts/ directory" echo "==========================================" # Optional: Commit to repository read -p "Do you want to commit these compiled scripts to the repository? (y/N): " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]]; then echo "๐Ÿ“ Committing compiled scripts to repository..." git add apt-layer.sh install-apt-layer.sh git diff --staged --quiet || git commit -m "Auto-compile apt-layer and installer from local build" echo "โœ… Scripts committed successfully" else echo "๐Ÿ“ Skipping commit - scripts are ready for manual commit" fi echo "๐ŸŽ‰ Compilation complete!"