debian/DEBIAN/control: package metadata, depends on python3.11+, postgresql-client debian/DEBIAN/postinst: creates activeblue-ai system user, installs venv, enables service debian/DEBIAN/prerm: stops and disables service before removal debian/DEBIAN/postrm: purge removes config, logs, venv, and system user debian/lib/systemd/system/activeblue-ai.service: - Runs as dedicated user with PrivateTmp + ProtectSystem hardening - EnvironmentFile=/etc/activeblue-ai/.env - Restart=on-failure with 5s backoff debian/usr/bin/activeblue-ai: CLI with start/stop/restart/status/logs/migrate/health/sweep/privacy/version build_deb.sh: builds activeblue-ai_X.Y.Z_all.deb in dist/ publish_repo.sh: scans packages, generates Release + checksums, optional GPG signing Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
73 lines
2.2 KiB
Bash
73 lines
2.2 KiB
Bash
#!/bin/bash
|
|
# Build the ActiveBlue AI Debian package
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
VERSION=$(cat "$SCRIPT_DIR/VERSION" 2>/dev/null || echo "0.1.0")
|
|
PKG_NAME="activeblue-ai"
|
|
PKG_DIR="$SCRIPT_DIR/build/${PKG_NAME}_${VERSION}"
|
|
DIST_DIR="$SCRIPT_DIR/dist"
|
|
|
|
echo "Building $PKG_NAME v$VERSION"
|
|
|
|
# Clean previous build
|
|
rm -rf "$PKG_DIR"
|
|
mkdir -p "$PKG_DIR"
|
|
|
|
# Copy Debian control files
|
|
cp -r "$SCRIPT_DIR/debian/DEBIAN" "$PKG_DIR/DEBIAN"
|
|
|
|
# Update version in control file
|
|
sed -i "s/^Version:.*/Version: $VERSION/" "$PKG_DIR/DEBIAN/control"
|
|
|
|
# Make maintainer scripts executable
|
|
chmod 755 "$PKG_DIR/DEBIAN/postinst" \
|
|
"$PKG_DIR/DEBIAN/prerm" \
|
|
"$PKG_DIR/DEBIAN/postrm"
|
|
|
|
# Install application files to /usr/lib/activeblue-ai
|
|
APP_DIR="$PKG_DIR/usr/lib/activeblue-ai"
|
|
mkdir -p "$APP_DIR"
|
|
cp -r "$SCRIPT_DIR/agent_service" "$APP_DIR/"
|
|
cp "$SCRIPT_DIR/requirements.txt" "$APP_DIR/"
|
|
cp "$SCRIPT_DIR/VERSION" "$APP_DIR/"
|
|
|
|
# Remove Python cache
|
|
find "$APP_DIR" -name '__pycache__' -type d -exec rm -rf {} + 2>/dev/null || true
|
|
find "$APP_DIR" -name '*.pyc' -delete 2>/dev/null || true
|
|
|
|
# Install systemd unit
|
|
mkdir -p "$PKG_DIR/lib/systemd/system"
|
|
cp "$SCRIPT_DIR/debian/lib/systemd/system/activeblue-ai.service" \
|
|
"$PKG_DIR/lib/systemd/system/"
|
|
|
|
# Install CLI tool
|
|
mkdir -p "$PKG_DIR/usr/bin"
|
|
cp "$SCRIPT_DIR/debian/usr/bin/activeblue-ai" "$PKG_DIR/usr/bin/"
|
|
chmod 755 "$PKG_DIR/usr/bin/activeblue-ai"
|
|
|
|
# Install default config
|
|
mkdir -p "$PKG_DIR/etc/activeblue-ai"
|
|
cp "$SCRIPT_DIR/.env.example" "$PKG_DIR/etc/activeblue-ai/.env.example"
|
|
|
|
# Install documentation
|
|
mkdir -p "$PKG_DIR/usr/share/doc/activeblue-ai"
|
|
cp "$SCRIPT_DIR/README.md" "$PKG_DIR/usr/share/doc/activeblue-ai/"
|
|
|
|
# Calculate installed size (kB)
|
|
SIZE=$(du -sk "$PKG_DIR" | cut -f1)
|
|
sed -i "s/^Installed-Size:.*/Installed-Size: $SIZE/" "$PKG_DIR/DEBIAN/control" 2>/dev/null || \
|
|
echo "Installed-Size: $SIZE" >> "$PKG_DIR/DEBIAN/control"
|
|
|
|
# Build the .deb
|
|
mkdir -p "$DIST_DIR"
|
|
DEB_FILE="$DIST_DIR/${PKG_NAME}_${VERSION}_all.deb"
|
|
dpkg-deb --build --root-owner-group "$PKG_DIR" "$DEB_FILE"
|
|
|
|
echo ""
|
|
echo "Package built: $DEB_FILE"
|
|
echo ""
|
|
echo "Install with:"
|
|
echo " sudo dpkg -i $DEB_FILE"
|
|
echo " sudo apt-get install -f # if there are dependency issues"
|