mid coding commit
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
# Build Scripts
|
||||
|
||||
Helper scripts for building Archipelago OS images.
|
||||
|
||||
## Scripts
|
||||
|
||||
### `build-backend.sh`
|
||||
Compiles the Archipelago Rust backend binary.
|
||||
- Output: `../build/backend/archipelago`
|
||||
- Requires: Rust toolchain
|
||||
- Optional: musl target for static binary
|
||||
|
||||
### `build-frontend.sh`
|
||||
Builds the Vue.js frontend for production.
|
||||
- Output: `../build/frontend/`
|
||||
- Requires: Node.js 18+, npm
|
||||
- Builds static files for serving
|
||||
|
||||
### `create-backend-apk.sh`
|
||||
Creates Alpine APK package from backend binary.
|
||||
- Output: `../apks/archipelago-backend-*.apk`
|
||||
- Includes: binary, systemd service, config files
|
||||
- Format: Alpine package format (tar.gz with metadata)
|
||||
|
||||
### `install-archipelago.sh`
|
||||
Installs Archipelago components into built image.
|
||||
- Called after image is created
|
||||
- Installs APK and frontend files
|
||||
- Configures services
|
||||
|
||||
### `convert-iso-to-disk.sh`
|
||||
Converts ISO image to raw disk image.
|
||||
- Input: ISO file
|
||||
- Output: `.img` file ready for `dd`
|
||||
- Creates partition layout (EFI + root)
|
||||
|
||||
### `check-dependencies.sh`
|
||||
Checks if all build dependencies are available.
|
||||
- Checks: Rust, Node.js, Docker (if needed)
|
||||
- Provides installation instructions
|
||||
- Non-blocking (warns but continues)
|
||||
|
||||
### `setup-alpine-build.sh`
|
||||
Sets up Alpine build environment.
|
||||
- Installs Alpine build tools
|
||||
- Configures abuild keys
|
||||
- Only needed for native Alpine builds
|
||||
|
||||
## Usage
|
||||
|
||||
These scripts are called automatically by the main build process. You typically don't need to run them manually, but you can for testing:
|
||||
|
||||
```bash
|
||||
# Build just the backend
|
||||
./scripts/build-backend.sh
|
||||
|
||||
# Build just the frontend
|
||||
./scripts/build-frontend.sh
|
||||
|
||||
# Create APK package
|
||||
./scripts/create-backend-apk.sh
|
||||
```
|
||||
Executable
+51
@@ -0,0 +1,51 @@
|
||||
#!/bin/bash
|
||||
# Build Archipelago backend binary for Alpine Linux
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
BACKEND_DIR="$PROJECT_ROOT/core/archipelago"
|
||||
OUTPUT_DIR="$SCRIPT_DIR/../build/backend"
|
||||
|
||||
echo "🔨 Building Archipelago backend..."
|
||||
echo " Source: $BACKEND_DIR"
|
||||
echo " Output: $OUTPUT_DIR"
|
||||
echo ""
|
||||
|
||||
# Check if Rust is installed
|
||||
if ! command -v rustc >/dev/null 2>&1; then
|
||||
echo "❌ Rust not found. Installing..."
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
||||
source "$HOME/.cargo/env"
|
||||
fi
|
||||
|
||||
# Create output directory
|
||||
mkdir -p "$OUTPUT_DIR"
|
||||
|
||||
# Build backend
|
||||
cd "$BACKEND_DIR"
|
||||
echo "📦 Compiling backend..."
|
||||
cargo build --release --target x86_64-unknown-linux-musl || {
|
||||
# Try without musl target if cross-compilation not set up
|
||||
echo "⚠️ Musl target not available, building for host..."
|
||||
cargo build --release
|
||||
}
|
||||
|
||||
# Copy binary
|
||||
if [ -f "target/x86_64-unknown-linux-musl/release/archipelago" ]; then
|
||||
cp "target/x86_64-unknown-linux-musl/release/archipelago" "$OUTPUT_DIR/archipelago"
|
||||
elif [ -f "target/release/archipelago" ]; then
|
||||
cp "target/release/archipelago" "$OUTPUT_DIR/archipelago"
|
||||
else
|
||||
echo "❌ Binary not found after build"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Strip binary for smaller size
|
||||
if command -v strip >/dev/null 2>&1; then
|
||||
strip "$OUTPUT_DIR/archipelago"
|
||||
fi
|
||||
|
||||
echo "✅ Backend built: $OUTPUT_DIR/archipelago"
|
||||
ls -lh "$OUTPUT_DIR/archipelago"
|
||||
Executable
+47
@@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
# Build Archipelago frontend for production
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
FRONTEND_DIR="$PROJECT_ROOT/neode-ui"
|
||||
OUTPUT_DIR="$SCRIPT_DIR/../build/frontend"
|
||||
|
||||
echo "🎨 Building Archipelago frontend..."
|
||||
echo " Source: $FRONTEND_DIR"
|
||||
echo " Output: $OUTPUT_DIR"
|
||||
echo ""
|
||||
|
||||
# Check if Node.js is installed
|
||||
if ! command -v node >/dev/null 2>&1; then
|
||||
echo "❌ Node.js not found. Please install Node.js 18+"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create output directory
|
||||
mkdir -p "$OUTPUT_DIR"
|
||||
|
||||
# Install dependencies if needed
|
||||
cd "$FRONTEND_DIR"
|
||||
if [ ! -d "node_modules" ]; then
|
||||
echo "📦 Installing frontend dependencies..."
|
||||
npm install
|
||||
fi
|
||||
|
||||
# Build frontend
|
||||
echo "🔨 Building frontend..."
|
||||
DOCKER_BUILD=true npm run build || npm run build
|
||||
|
||||
# Copy built files
|
||||
if [ -d "dist" ]; then
|
||||
cp -r dist/* "$OUTPUT_DIR/"
|
||||
elif [ -d "../web/dist/neode-ui" ]; then
|
||||
cp -r ../web/dist/neode-ui/* "$OUTPUT_DIR/"
|
||||
else
|
||||
echo "❌ Build output not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ Frontend built: $OUTPUT_DIR"
|
||||
du -sh "$OUTPUT_DIR"
|
||||
Executable
+132
@@ -0,0 +1,132 @@
|
||||
#!/bin/bash
|
||||
# Create Alpine APK package for Archipelago backend
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
BUILD_DIR="$SCRIPT_DIR/../build"
|
||||
APK_DIR="$SCRIPT_DIR/../apks"
|
||||
ARCHIPELAGO_VERSION="${ARCHIPELAGO_VERSION:-0.1.0}"
|
||||
|
||||
echo "📦 Creating Archipelago backend APK..."
|
||||
echo ""
|
||||
|
||||
# Create APK directory
|
||||
mkdir -p "$APK_DIR"
|
||||
|
||||
# Create temporary APK build directory
|
||||
APK_BUILD_DIR=$(mktemp -d)
|
||||
trap "rm -rf $APK_BUILD_DIR" EXIT
|
||||
|
||||
cd "$APK_BUILD_DIR"
|
||||
|
||||
# APK package structure
|
||||
mkdir -p usr/bin
|
||||
mkdir -p usr/lib/systemd/system
|
||||
mkdir -p etc/archipelago
|
||||
mkdir -p etc/init.d
|
||||
|
||||
# Copy binary
|
||||
if [ -f "$BUILD_DIR/backend/archipelago" ]; then
|
||||
cp "$BUILD_DIR/backend/archipelago" usr/bin/archipelago
|
||||
chmod +x usr/bin/archipelago
|
||||
else
|
||||
echo "❌ Backend binary not found. Run build-backend.sh first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create systemd service file
|
||||
cat > usr/lib/systemd/system/archipelago.service <<'EOF'
|
||||
[Unit]
|
||||
Description=Archipelago Bitcoin Node OS Backend
|
||||
After=network.target podman.service
|
||||
Wants=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=archipelago
|
||||
Group=archipelago
|
||||
WorkingDirectory=/var/lib/archipelago
|
||||
ExecStart=/usr/bin/archipelago
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
|
||||
# Security
|
||||
NoNewPrivileges=true
|
||||
PrivateTmp=true
|
||||
ProtectSystem=strict
|
||||
ProtectHome=true
|
||||
ReadWritePaths=/var/lib/archipelago /tmp
|
||||
|
||||
# Environment
|
||||
Environment="RUST_LOG=info"
|
||||
Environment="ARCHIPELAGO_DATA_DIR=/var/lib/archipelago"
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
# Create init.d script (for openrc)
|
||||
cat > etc/init.d/archipelago <<'EOF'
|
||||
#!/sbin/openrc-run
|
||||
# Archipelago Bitcoin Node OS Backend
|
||||
|
||||
name="Archipelago"
|
||||
command="/usr/bin/archipelago"
|
||||
command_user="archipelago:archipelago"
|
||||
command_background=true
|
||||
pidfile="/var/run/archipelago.pid"
|
||||
start_stop_daemon_args="--make-pidfile"
|
||||
|
||||
depend() {
|
||||
need net
|
||||
use podman
|
||||
}
|
||||
EOF
|
||||
chmod +x etc/init.d/archipelago
|
||||
|
||||
# Create default config
|
||||
mkdir -p etc/archipelago
|
||||
cat > etc/archipelago/config.toml <<EOF
|
||||
data_dir = "/var/lib/archipelago"
|
||||
bind_host = "0.0.0.0"
|
||||
bind_port = 5959
|
||||
log_level = "info"
|
||||
dev_mode = false
|
||||
container_runtime = "podman"
|
||||
port_offset = 0
|
||||
bitcoin_simulation = "none"
|
||||
EOF
|
||||
|
||||
# Calculate package size
|
||||
PKG_SIZE=$(du -sb "$APK_BUILD_DIR" | cut -f1)
|
||||
|
||||
# Create .PKGINFO (Alpine package format)
|
||||
cat > "$APK_BUILD_DIR/.PKGINFO" <<EOF
|
||||
pkgname = archipelago-backend
|
||||
pkgver = ${ARCHIPELAGO_VERSION}-r0
|
||||
pkgdesc = Archipelago Bitcoin Node OS Backend
|
||||
url = https://github.com/archipelago/archipelago
|
||||
arch = x86_64
|
||||
license = MIT
|
||||
size = ${PKG_SIZE}
|
||||
origin = archipelago
|
||||
EOF
|
||||
|
||||
# Create .SIGN.RSA (placeholder - would need signing key for production)
|
||||
touch "$APK_BUILD_DIR/.SIGN.RSA"
|
||||
|
||||
# Create tarball (Alpine APK format)
|
||||
cd "$APK_BUILD_DIR"
|
||||
tar -czf "$APK_DIR/archipelago-backend-${ARCHIPELAGO_VERSION}-r0.apk" \
|
||||
.PKGINFO .SIGN.RSA usr etc 2>/dev/null || {
|
||||
# Fallback: create without signing
|
||||
tar -czf "$APK_DIR/archipelago-backend-${ARCHIPELAGO_VERSION}-r0.apk" \
|
||||
.PKGINFO usr etc
|
||||
}
|
||||
|
||||
echo "✅ APK created: $APK_DIR/archipelago-backend-${ARCHIPELAGO_VERSION}-r0.apk"
|
||||
ls -lh "$APK_DIR/archipelago-backend-${ARCHIPELAGO_VERSION}-r0.apk"
|
||||
Executable
+93
@@ -0,0 +1,93 @@
|
||||
#!/bin/bash
|
||||
# Install Archipelago components into Alpine image
|
||||
# This script is called after the base image is built
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
OUTPUT_DIR="${1:-$SCRIPT_DIR/../results}"
|
||||
BUILD_DIR="$SCRIPT_DIR/../build"
|
||||
APK_DIR="$SCRIPT_DIR/../apks"
|
||||
|
||||
echo "🔧 Installing Archipelago into image..."
|
||||
echo " Output: $OUTPUT_DIR"
|
||||
echo ""
|
||||
|
||||
# Find the built image (ISO or extracted)
|
||||
if [ -f "$OUTPUT_DIR"/*.iso ]; then
|
||||
ISO_FILE=$(ls "$OUTPUT_DIR"/*.iso | head -1)
|
||||
echo "📦 Found ISO: $ISO_FILE"
|
||||
echo " (Archipelago will be installed when ISO is booted)"
|
||||
# For ISO, we'd need to extract, modify, and rebuild
|
||||
# This is complex, so we'll do it in the init script instead
|
||||
elif [ -d "$OUTPUT_DIR" ]; then
|
||||
# Extracted image directory
|
||||
IMAGE_ROOT="$OUTPUT_DIR"
|
||||
echo "📁 Installing into extracted image: $IMAGE_ROOT"
|
||||
|
||||
# Install backend APK
|
||||
if [ -f "$APK_DIR"/*.apk ]; then
|
||||
APK_FILE=$(ls "$APK_DIR"/*.apk | head -1)
|
||||
echo "📦 Installing backend APK: $APK_FILE"
|
||||
# In a real chroot, we'd do: apk add --allow-untrusted "$APK_FILE"
|
||||
# For now, we'll extract and copy manually
|
||||
TEMP_DIR=$(mktemp -d)
|
||||
cd "$TEMP_DIR"
|
||||
tar -xzf "$APK_FILE"
|
||||
|
||||
# Copy files to image
|
||||
if [ -d "$IMAGE_ROOT" ]; then
|
||||
cp -r usr/* "$IMAGE_ROOT/usr/" 2>/dev/null || true
|
||||
cp -r etc/* "$IMAGE_ROOT/etc/" 2>/dev/null || true
|
||||
fi
|
||||
rm -rf "$TEMP_DIR"
|
||||
fi
|
||||
|
||||
# Install frontend
|
||||
if [ -d "$BUILD_DIR/frontend" ]; then
|
||||
echo "🎨 Installing frontend..."
|
||||
mkdir -p "$IMAGE_ROOT/usr/share/archipelago/web"
|
||||
cp -r "$BUILD_DIR/frontend/"* "$IMAGE_ROOT/usr/share/archipelago/web/"
|
||||
fi
|
||||
else
|
||||
echo "⚠️ No image found to install into"
|
||||
echo " Archipelago will be installed on first boot"
|
||||
fi
|
||||
|
||||
# Create first boot script
|
||||
cat > "$SCRIPT_DIR/../alpine-profile/overlay/etc/local.d/archipelago-install.start" <<'EOF'
|
||||
#!/bin/sh
|
||||
# First boot installation script for Archipelago
|
||||
|
||||
# Install backend APK if available
|
||||
if [ -f /tmp/archipelago-backend.apk ]; then
|
||||
apk add --allow-untrusted /tmp/archipelago-backend.apk
|
||||
rm /tmp/archipelago-backend.apk
|
||||
fi
|
||||
|
||||
# Enable services
|
||||
rc-update add archipelago default || true
|
||||
systemctl enable archipelago || true
|
||||
|
||||
# Create archipelago user if needed
|
||||
if ! id archipelago >/dev/null 2>&1; then
|
||||
adduser -D -s /bin/bash archipelago
|
||||
echo "archipelago ALL=(ALL) NOPASSWD: /usr/bin/podman" >> /etc/sudoers
|
||||
fi
|
||||
|
||||
# Setup Podman for archipelago user
|
||||
mkdir -p /home/archipelago/.config/containers
|
||||
chown -R archipelago:archipelago /home/archipelago
|
||||
|
||||
# Create data directories
|
||||
mkdir -p /var/lib/archipelago/{apps,secrets,logs,backups}
|
||||
chown -R archipelago:archipelago /var/lib/archipelago
|
||||
|
||||
# Start services
|
||||
rc-service archipelago start || systemctl start archipelago || true
|
||||
EOF
|
||||
|
||||
chmod +x "$SCRIPT_DIR/../alpine-profile/overlay/etc/local.d/archipelago-install.start"
|
||||
|
||||
echo "✅ Archipelago installation configured"
|
||||
Executable
+57
@@ -0,0 +1,57 @@
|
||||
#!/bin/bash
|
||||
# Setup Alpine build environment
|
||||
# Installs dependencies and prepares build environment
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
echo "🔧 Setting up Alpine build environment..."
|
||||
echo ""
|
||||
|
||||
# Detect OS
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
echo "🍎 macOS detected - Docker will be used"
|
||||
echo " Make sure Docker Desktop is installed and running"
|
||||
exit 0
|
||||
elif [ -f /etc/alpine-release ]; then
|
||||
echo "🏔️ Alpine Linux detected - installing native tools..."
|
||||
|
||||
# Install build dependencies
|
||||
apk add --no-cache \
|
||||
bash \
|
||||
git \
|
||||
alpine-sdk \
|
||||
abuild \
|
||||
alpine-conf \
|
||||
syslinux \
|
||||
xorriso \
|
||||
squashfs-tools \
|
||||
grub \
|
||||
grub-efi \
|
||||
mtools \
|
||||
dosfstools \
|
||||
e2fsprogs \
|
||||
rsync \
|
||||
curl \
|
||||
wget \
|
||||
ca-certificates || {
|
||||
echo "❌ Failed to install dependencies"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Setup abuild keys
|
||||
if [ ! -f ~/.abuild/abuild.conf ]; then
|
||||
echo "🔑 Generating abuild keys..."
|
||||
abuild-keygen -a -n
|
||||
fi
|
||||
|
||||
echo "✅ Alpine build environment ready!"
|
||||
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||
echo "🐧 Linux detected (not Alpine) - Docker will be used"
|
||||
echo " Install Docker: https://docs.docker.com/get-docker/"
|
||||
exit 0
|
||||
else
|
||||
echo "❌ Unsupported OS: $OSTYPE"
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user