111 lines
3.2 KiB
Bash
Executable File
111 lines
3.2 KiB
Bash
Executable File
#!/bin/bash
|
|
# Native Alpine build script
|
|
# Must be run on Alpine Linux or in Alpine container
|
|
|
|
set -e
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
BUILD_TYPE="${1:-iso}"
|
|
|
|
ARCHIPELAGO_VERSION="${ARCHIPELAGO_VERSION:-0.1.0}"
|
|
ALPINE_VERSION="${ALPINE_VERSION:-3.19}"
|
|
ARCH="${ARCH:-x86_64}"
|
|
OUTPUT_DIR="${OUTPUT_DIR:-$SCRIPT_DIR/results}"
|
|
|
|
echo "🏔️ Building Alpine image natively"
|
|
echo ""
|
|
|
|
# Install build dependencies
|
|
echo "📦 Installing build dependencies..."
|
|
apk add --no-cache \
|
|
bash \
|
|
git \
|
|
alpine-sdk \
|
|
abuild \
|
|
alpine-conf \
|
|
syslinux \
|
|
xorriso \
|
|
squashfs-tools \
|
|
grub \
|
|
grub-efi \
|
|
mtools \
|
|
dosfstools \
|
|
e2fsprogs \
|
|
rsync \
|
|
|| true
|
|
|
|
# Setup abuild keys if needed
|
|
if [ ! -f ~/.abuild/abuild.conf ]; then
|
|
echo "🔑 Setting up abuild keys..."
|
|
abuild-keygen -a -n || true
|
|
fi
|
|
|
|
# Clone Alpine aports if needed
|
|
APORTS_DIR="$SCRIPT_DIR/aports"
|
|
if [ ! -d "$APORTS_DIR" ]; then
|
|
echo "📥 Cloning Alpine aports repository..."
|
|
git clone --depth=1 --branch "v${ALPINE_VERSION}" \
|
|
https://gitlab.alpinelinux.org/alpine/aports.git "$APORTS_DIR" || {
|
|
echo "⚠️ Failed to clone aports, trying without branch..."
|
|
git clone --depth=1 https://gitlab.alpinelinux.org/alpine/aports.git "$APORTS_DIR"
|
|
}
|
|
fi
|
|
|
|
# Copy custom profile
|
|
echo "📝 Setting up custom Archipelago profile..."
|
|
PROFILE_DIR="$APORTS_DIR/scripts/mkimg.archipelago"
|
|
mkdir -p "$PROFILE_DIR"
|
|
cp -r "$SCRIPT_DIR/alpine-profile/"* "$PROFILE_DIR/" 2>/dev/null || true
|
|
|
|
# Build ISO or disk image
|
|
cd "$APORTS_DIR/scripts"
|
|
|
|
if [ "$BUILD_TYPE" = "iso" ]; then
|
|
echo "💿 Building ISO image..."
|
|
./mkimage.sh \
|
|
--arch "$ARCH" \
|
|
--profile archipelago \
|
|
--repository "http://dl-cdn.alpinelinux.org/alpine/v${ALPINE_VERSION}/main" \
|
|
--repository "http://dl-cdn.alpinelinux.org/alpine/v${ALPINE_VERSION}/community" \
|
|
--outdir "$OUTPUT_DIR" \
|
|
--tag "$ALPINE_VERSION" || {
|
|
echo "❌ ISO build failed"
|
|
exit 1
|
|
}
|
|
|
|
# Rename output
|
|
if [ -f "$OUTPUT_DIR/alpine-archipelago-${ALPINE_VERSION}-${ARCH}.iso" ]; then
|
|
mv "$OUTPUT_DIR/alpine-archipelago-${ALPINE_VERSION}-${ARCH}.iso" \
|
|
"$OUTPUT_DIR/archipelago-${ARCHIPELAGO_VERSION}-${ARCH}.iso"
|
|
fi
|
|
elif [ "$BUILD_TYPE" = "disk" ]; then
|
|
echo "💾 Building disk image..."
|
|
# Build ISO first, then convert to disk image
|
|
./mkimage.sh \
|
|
--arch "$ARCH" \
|
|
--profile archipelago \
|
|
--repository "http://dl-cdn.alpinelinux.org/alpine/v${ALPINE_VERSION}/main" \
|
|
--repository "http://dl-cdn.alpinelinux.org/alpine/v${ALPINE_VERSION}/community" \
|
|
--outdir "$OUTPUT_DIR" \
|
|
--tag "$ALPINE_VERSION" || {
|
|
echo "❌ Image build failed"
|
|
exit 1
|
|
}
|
|
|
|
# Convert to disk image (will be done in install script)
|
|
echo "📦 Disk image will be created in install step"
|
|
else
|
|
echo "❌ Unknown build type: $BUILD_TYPE"
|
|
exit 1
|
|
fi
|
|
|
|
# Install Archipelago into the image
|
|
echo "🔧 Installing Archipelago components..."
|
|
"$SCRIPT_DIR/scripts/install-archipelago.sh" "$OUTPUT_DIR" || {
|
|
echo "⚠️ Archipelago installation had issues, but image was built"
|
|
}
|
|
|
|
echo ""
|
|
echo "✅ Build complete!"
|