74 lines
2.2 KiB
Bash
Executable File
74 lines
2.2 KiB
Bash
Executable File
#!/bin/sh
|
|
set -e
|
|
|
|
echo "====================================="
|
|
echo "= Alpine Zero-OS Initramfs Build ="
|
|
echo "====================================="
|
|
echo ""
|
|
|
|
# DIAGNOSTIC: Check critical dependencies before starting
|
|
echo "[DEBUG] Checking critical dependencies..."
|
|
echo "[DEBUG] Current directory: $(pwd)"
|
|
echo "[DEBUG] Available disk space: $(df -h /build | tail -1)"
|
|
echo "[DEBUG] Available memory: $(free -h)"
|
|
echo "[DEBUG] Network connectivity: $(ping -c 1 8.8.8.8 >/dev/null 2>&1 && echo 'OK' || echo 'FAILED')"
|
|
echo "[DEBUG] GitHub API access: $(curl -s https://api.github.com/repos/threefoldtech/zinit/releases/latest >/dev/null 2>&1 && echo 'OK' || echo 'FAILED')"
|
|
echo "[DEBUG] Zinit config mount check: $(ls -la /mnt/zinit 2>/dev/null | wc -l) files"
|
|
echo "[DEBUG] APK repositories: $(apk update >/dev/null 2>&1 && echo 'OK' || echo 'FAILED')"
|
|
echo ""
|
|
|
|
# Source configuration
|
|
if [ -f /build/build.conf ]; then
|
|
. /build/build.conf
|
|
else
|
|
echo "Error: build.conf not found"
|
|
exit 1
|
|
fi
|
|
|
|
echo "[+] Build mode: $BUILDMODE"
|
|
echo "[+] Target arch: $TARGETARCH"
|
|
echo "[+] Output directory: $OUTPUT_DIR"
|
|
echo ""
|
|
|
|
# Ensure output directory exists
|
|
mkdir -p "$OUTPUT_DIR"
|
|
|
|
# Phase 1: Install Alpine packages to initramfs
|
|
echo "[+] Installing Alpine packages..."
|
|
/build/scripts/install-packages.sh
|
|
|
|
# Phase 2: Compile Zero-OS components from source (replaces problematic fetch-github)
|
|
echo "[+] Compiling Zero-OS components..."
|
|
if [ -f /build/scripts/build-smart.sh ]; then
|
|
# Use smart build if available (with caching)
|
|
/build/scripts/build-smart.sh
|
|
exit $?
|
|
else
|
|
# Fallback to direct component compilation
|
|
/build/scripts/compile-components.sh
|
|
fi
|
|
|
|
# Phase 3: Setup initramfs structure
|
|
echo "[+] Setting up initramfs structure..."
|
|
/build/scripts/setup-initramfs.sh
|
|
|
|
# Phase 4: Build kernel with embedded initramfs
|
|
echo "[+] Building kernel..."
|
|
/build/scripts/build-kernel.sh
|
|
|
|
echo ""
|
|
echo "[+] Build completed successfully!"
|
|
echo "[+] Output files:"
|
|
ls -la "$OUTPUT_DIR/"
|
|
|
|
# Verify output
|
|
if [ -f "$OUTPUT_DIR/vmlinuz.efi" ]; then
|
|
size=$(stat -c%s "$OUTPUT_DIR/vmlinuz.efi")
|
|
echo "[+] Kernel size: $size bytes"
|
|
else
|
|
echo "[-] Error: vmlinuz.efi not found!"
|
|
exit 1
|
|
fi
|
|
|
|
echo ""
|
|
echo "[+] Alpine Zero-OS initramfs build complete!" |