130 lines
3.2 KiB
Bash
Executable File
130 lines
3.2 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# EcoOS ISO Build Script
|
|
# Wrapper script for building the EcoOS ISO
|
|
#
|
|
|
|
set -e
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
ROOT_DIR="$(dirname "$SCRIPT_DIR")"
|
|
|
|
echo "=== EcoOS ISO Builder ==="
|
|
echo ""
|
|
|
|
# Check if running as root (required for live-build)
|
|
if [ "$EUID" -ne 0 ]; then
|
|
echo "This script requires root privileges for live-build."
|
|
echo "Running with sudo..."
|
|
exec sudo "$0" "$@"
|
|
fi
|
|
|
|
# Check prerequisites
|
|
echo "[1/6] Checking prerequisites..."
|
|
|
|
check_command() {
|
|
if ! command -v "$1" &> /dev/null; then
|
|
echo "Error: $1 is not installed"
|
|
echo "Install with: apt install $2"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
check_command lb live-build
|
|
check_command debootstrap debootstrap
|
|
check_command xorriso xorriso
|
|
check_command deno deno
|
|
|
|
echo " All prerequisites found."
|
|
|
|
# Check Ubuntu version
|
|
. /etc/os-release
|
|
if [[ "$VERSION_ID" != "24.04" && "$VERSION_ID" != "24.10" ]]; then
|
|
echo "Warning: This script is designed for Ubuntu 24.04+"
|
|
echo "Current version: $VERSION_ID"
|
|
fi
|
|
|
|
# Bundle the daemon
|
|
echo ""
|
|
echo "[2/6] Bundling ecoos_daemon..."
|
|
|
|
DAEMON_DIR="$(dirname "$ROOT_DIR")/ecoos_daemon"
|
|
cd "$DAEMON_DIR"
|
|
deno compile --allow-all --output bundle/eco-daemon mod.ts
|
|
echo " Daemon bundled."
|
|
|
|
# Prepare build directory
|
|
echo ""
|
|
echo "[3/6] Preparing build directory..."
|
|
|
|
BUILD_DIR="$ROOT_DIR/build"
|
|
rm -rf "$BUILD_DIR"
|
|
mkdir -p "$BUILD_DIR"
|
|
cd "$BUILD_DIR"
|
|
|
|
# Configure live-build
|
|
echo ""
|
|
echo "[4/6] Configuring live-build..."
|
|
|
|
lb config \
|
|
--architectures amd64 \
|
|
--distribution noble \
|
|
--archive-areas "main restricted universe multiverse" \
|
|
--binary-images iso-hybrid \
|
|
--debian-installer false \
|
|
--memtest none \
|
|
--firmware-binary true \
|
|
--firmware-chroot true \
|
|
--updates true \
|
|
--security true \
|
|
--bootloaders "grub-efi" \
|
|
--uefi-secure-boot enable \
|
|
--iso-application "EcoOS" \
|
|
--iso-publisher "EcoBridge" \
|
|
--iso-volume "EcoOS"
|
|
|
|
# Copy package lists
|
|
echo ""
|
|
echo "[5/6] Copying configuration files..."
|
|
|
|
cp "$ROOT_DIR/config/live-build/package-lists/"*.list.chroot config/package-lists/
|
|
|
|
# Prepare includes.chroot
|
|
mkdir -p config/includes.chroot/opt/eco/bin
|
|
mkdir -p config/includes.chroot/opt/eco/daemon
|
|
mkdir -p config/includes.chroot/etc/systemd/system
|
|
|
|
# Copy daemon
|
|
cp "$DAEMON_DIR/bundle/eco-daemon" config/includes.chroot/opt/eco/bin/
|
|
chmod +x config/includes.chroot/opt/eco/bin/eco-daemon
|
|
|
|
# Copy daemon source as backup
|
|
cp -r "$DAEMON_DIR/ts" config/includes.chroot/opt/eco/daemon/
|
|
cp "$DAEMON_DIR/mod.ts" config/includes.chroot/opt/eco/daemon/
|
|
cp "$DAEMON_DIR/deno.json" config/includes.chroot/opt/eco/daemon/
|
|
|
|
# Copy systemd service
|
|
cp "$ROOT_DIR/config/systemd/eco-daemon.service" config/includes.chroot/etc/systemd/system/
|
|
|
|
# Copy autoinstall config to binary includes
|
|
mkdir -p config/includes.binary/autoinstall
|
|
cp "$ROOT_DIR/config/autoinstall/user-data" config/includes.binary/autoinstall/
|
|
touch config/includes.binary/autoinstall/meta-data
|
|
|
|
echo " Configuration complete."
|
|
|
|
# Build ISO
|
|
echo ""
|
|
echo "[6/6] Building ISO (this may take 15-30 minutes)..."
|
|
echo ""
|
|
|
|
lb build
|
|
|
|
# Move ISO to output
|
|
mkdir -p "$ROOT_DIR/output"
|
|
mv *.iso "$ROOT_DIR/output/ecoos.iso" 2>/dev/null || true
|
|
|
|
echo ""
|
|
echo "=== Build Complete ==="
|
|
echo "ISO: $ROOT_DIR/output/ecoos.iso"
|