122 lines
3.2 KiB
Bash
Executable File
122 lines
3.2 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Build EcoOS ISO using Docker
|
|
# This avoids needing to install live-build on the host
|
|
#
|
|
# Usage: ./docker-build.sh [--arch=amd64|arm64|rpi]
|
|
#
|
|
|
|
set -e
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
ISOBUILD_DIR="$(dirname "$SCRIPT_DIR")"
|
|
ECO_OS_DIR="$(dirname "$ISOBUILD_DIR")"
|
|
|
|
# Default architecture
|
|
TARGET_ARCH="amd64"
|
|
|
|
# Parse arguments
|
|
for arg in "$@"; do
|
|
case $arg in
|
|
--arch=*)
|
|
TARGET_ARCH="${arg#*=}"
|
|
;;
|
|
-h|--help)
|
|
echo "Usage: $0 [--arch=amd64|arm64|rpi]"
|
|
echo ""
|
|
echo "Architectures:"
|
|
echo " amd64 - x86_64 with UEFI/GRUB boot (default)"
|
|
echo " arm64 - Generic ARM64 with UEFI/GRUB boot"
|
|
echo " rpi - Raspberry Pi 3/4/5 with native bootloader"
|
|
exit 0
|
|
;;
|
|
*)
|
|
echo "Unknown argument: $arg"
|
|
echo "Use --help for usage information"
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
# Validate architecture
|
|
case "$TARGET_ARCH" in
|
|
amd64|arm64|rpi)
|
|
;;
|
|
*)
|
|
echo "ERROR: Invalid architecture '$TARGET_ARCH'"
|
|
echo "Valid options: amd64, arm64, rpi"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
# Determine output filename based on architecture
|
|
case "$TARGET_ARCH" in
|
|
amd64)
|
|
OUTPUT_FILE="ecoos.iso"
|
|
;;
|
|
arm64)
|
|
OUTPUT_FILE="ecoos-arm64.iso"
|
|
;;
|
|
rpi)
|
|
OUTPUT_FILE="ecoos-rpi.img"
|
|
;;
|
|
esac
|
|
|
|
echo "=== EcoOS ISO Builder (Docker) ==="
|
|
echo "Target architecture: $TARGET_ARCH"
|
|
echo "Output file: $OUTPUT_FILE"
|
|
echo ""
|
|
|
|
cd "$ECO_OS_DIR"
|
|
|
|
# Build the Docker image with architecture argument
|
|
echo "[1/2] Building Docker image for $TARGET_ARCH..."
|
|
|
|
# For ARM builds on x86 hosts, we need to use buildx with platform emulation
|
|
if [ "$TARGET_ARCH" = "arm64" ] || [ "$TARGET_ARCH" = "rpi" ]; then
|
|
HOST_ARCH=$(uname -m)
|
|
if [ "$HOST_ARCH" = "x86_64" ]; then
|
|
echo "Cross-building ARM on x86_64 host - using Docker buildx with QEMU emulation"
|
|
echo "Note: This requires QEMU binfmt. If this fails, run:"
|
|
echo " docker run --privileged --rm tonistiigi/binfmt --install all"
|
|
echo ""
|
|
|
|
# Ensure buildx is available and create builder if needed
|
|
docker buildx inspect ecoos-builder >/dev/null 2>&1 || \
|
|
docker buildx create --name ecoos-builder --use
|
|
|
|
docker buildx build \
|
|
--platform linux/arm64 \
|
|
--build-arg TARGET_ARCH="$TARGET_ARCH" \
|
|
--load \
|
|
-t ecoos-builder-$TARGET_ARCH \
|
|
-f isobuild/Dockerfile .
|
|
else
|
|
# Running on ARM host, use regular build
|
|
docker build \
|
|
--build-arg TARGET_ARCH="$TARGET_ARCH" \
|
|
-t ecoos-builder-$TARGET_ARCH \
|
|
-f isobuild/Dockerfile .
|
|
fi
|
|
else
|
|
docker build \
|
|
--build-arg TARGET_ARCH="$TARGET_ARCH" \
|
|
-t ecoos-builder-$TARGET_ARCH \
|
|
-f isobuild/Dockerfile .
|
|
fi
|
|
|
|
# Run the build
|
|
echo ""
|
|
echo "[2/2] Building image (this may take 15-30 minutes)..."
|
|
mkdir -p "$ISOBUILD_DIR/output"
|
|
|
|
docker run --rm \
|
|
--privileged \
|
|
-e TARGET_ARCH="$TARGET_ARCH" \
|
|
-v "$ISOBUILD_DIR/output:/output" \
|
|
ecoos-builder-$TARGET_ARCH
|
|
|
|
echo ""
|
|
echo "=== Build Complete ==="
|
|
echo "Output: $ISOBUILD_DIR/output/$OUTPUT_FILE"
|