particle-os-tools/compile-apt-layer-local.sh
robojerk f45378237c
Some checks failed
Compile apt-layer / compile (push) Failing after 0s
maybe it works this time
2025-07-15 00:39:17 -07:00

183 lines
No EOL
5.7 KiB
Bash

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