skyview/scripts/build-deb.sh
Ole-Morten Duesund be5369c195 Rename Debian package from skyview to skyview-adsb
The official Debian repositories already contain a package named
"skyview" which is associated with NASA's SkyView Virtual Observatory
(https://skyview.gsfc.nasa.gov/), a tool for astronomical data
visualization.

To avoid package naming conflicts and potential confusion for users,
this commit renames our ADS-B aircraft tracking application package
to "skyview-adsb". This clearly indicates the package's purpose
(ADS-B tracking) while maintaining the SkyView brand identity.

Changes:
- Package name: skyview → skyview-adsb
- System user/group: skyview → skyview-adsb
- Config directory: /etc/skyview → /etc/skyview-adsb
- Data directory: /var/lib/skyview → /var/lib/skyview-adsb
- Log directory: /var/log/skyview → /var/log/skyview-adsb
- Systemd service: skyview.service → skyview-adsb.service
- Documentation path: /usr/share/doc/skyview → /usr/share/doc/skyview-adsb

The binaries (/usr/bin/skyview and /usr/bin/beast-dump) remain
unchanged as they don't conflict at the filesystem level.

This ensures clean installation alongside any existing skyview
packages and prevents apt/dpkg conflicts during installation.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-25 08:23:11 +02:00

150 lines
No EOL
4.4 KiB
Bash
Executable file

#!/bin/bash
set -e
# Build script for creating Debian package
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
BUILD_DIR="$PROJECT_DIR/build"
DEB_DIR="$PROJECT_DIR/debian"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo_info() {
echo -e "${GREEN}[INFO]${NC} $1"
}
echo_warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
echo_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Clean previous builds
echo_info "Cleaning previous builds..."
rm -rf "$BUILD_DIR"
mkdir -p "$BUILD_DIR"
# Change to project directory
cd "$PROJECT_DIR"
# Build the applications
echo_info "Building SkyView applications..."
export CGO_ENABLED=0
export GOOS=linux
export GOARCH=amd64
VERSION=$(git describe --tags --always --dirty)
LDFLAGS="-w -s -X main.version=$VERSION"
# Build main skyview binary
echo_info "Building skyview..."
if ! go build -ldflags="$LDFLAGS" \
-o "$DEB_DIR/usr/bin/skyview" \
./cmd/skyview; then
echo_error "Failed to build skyview"
exit 1
fi
# Build beast-dump utility
echo_info "Building beast-dump..."
if ! go build -ldflags="$LDFLAGS" \
-o "$DEB_DIR/usr/bin/beast-dump" \
./cmd/beast-dump; then
echo_error "Failed to build beast-dump"
exit 1
fi
echo_info "Built binaries:"
echo_info " skyview: $(file "$DEB_DIR/usr/bin/skyview")"
echo_info " beast-dump: $(file "$DEB_DIR/usr/bin/beast-dump")"
# Set executable permissions
chmod +x "$DEB_DIR/usr/bin/skyview"
chmod +x "$DEB_DIR/usr/bin/beast-dump"
# Generate changelog from git history
echo_info "Generating changelog from git history..."
CHANGELOG_DIR="$DEB_DIR/usr/share/doc/skyview-adsb"
mkdir -p "$CHANGELOG_DIR"
# Get the current version and previous version
CURRENT_VERSION=$(git describe --tags --always)
PREV_VERSION=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
if [ -n "$PREV_VERSION" ]; then
echo_info "Generating changelog from $PREV_VERSION to $CURRENT_VERSION"
# Create changelog with proper Debian format
{
echo "skyview-adsb ($CURRENT_VERSION) unstable; urgency=medium"
echo ""
echo " Changes since $PREV_VERSION:"
git log --pretty=format:" * %s" "$PREV_VERSION..HEAD" | head -20
echo ""
echo " -- $(git config user.name) <$(git config user.email)> $(date -R)"
echo ""
} > "$CHANGELOG_DIR/changelog"
else
echo_info "No previous version found, generating initial changelog"
# Create initial changelog
{
echo "skyview-adsb ($CURRENT_VERSION) unstable; urgency=medium"
echo ""
echo " * Initial release"
echo " * Multi-source ADS-B aircraft tracker with Beast format support"
echo ""
echo " -- $(git config user.name) <$(git config user.email)> $(date -R)"
echo ""
} > "$CHANGELOG_DIR/changelog"
fi
# Compress changelog as per Debian standards
gzip -9 "$CHANGELOG_DIR/changelog"
echo_info "Generated changelog: $CHANGELOG_DIR/changelog.gz"
# Get package info
VERSION=$(grep "Version:" "$DEB_DIR/DEBIAN/control" | cut -d' ' -f2)
PACKAGE=$(grep "Package:" "$DEB_DIR/DEBIAN/control" | cut -d' ' -f2)
ARCH=$(grep "Architecture:" "$DEB_DIR/DEBIAN/control" | cut -d' ' -f2)
DEB_FILE="${PACKAGE}_${VERSION}_${ARCH}.deb"
echo_info "Creating Debian package: $DEB_FILE"
# Calculate installed size
INSTALLED_SIZE=$(du -sk "$DEB_DIR" | cut -f1)
sed -i "s/Installed-Size:.*/Installed-Size: $INSTALLED_SIZE/" "$DEB_DIR/DEBIAN/control" 2>/dev/null || \
echo "Installed-Size: $INSTALLED_SIZE" >> "$DEB_DIR/DEBIAN/control"
# Build the package
if dpkg-deb --root-owner-group --build "$DEB_DIR" "$BUILD_DIR/$DEB_FILE"; then
echo_info "Successfully created: $BUILD_DIR/$DEB_FILE"
# Show package info
echo_info "Package information:"
dpkg-deb --info "$BUILD_DIR/$DEB_FILE"
echo_info "Package contents:"
dpkg-deb --contents "$BUILD_DIR/$DEB_FILE"
# Test the package (requires root)
if [ "$EUID" -eq 0 ]; then
echo_info "Testing package installation (as root)..."
dpkg --dry-run -i "$BUILD_DIR/$DEB_FILE"
else
echo_warn "Run as root to test package installation"
fi
echo_info "Debian package build complete!"
echo_info "Install with: sudo dpkg -i $BUILD_DIR/$DEB_FILE"
echo_info "Or upload to repository for apt installation"
else
echo_error "Failed to create Debian package"
exit 1
fi