Files
venus/dbus-generator-ramp/build-package.sh
dev 9756538f16 Initial commit: Venus OS boat addons monorepo
Organizes 11 projects for Cerbo GX/Venus OS into a single repository:
- axiom-nmea: Raymarine LightHouse protocol decoder
- dbus-generator-ramp: Generator current ramp controller
- dbus-lightning: Blitzortung lightning monitor
- dbus-meteoblue-forecast: Meteoblue weather forecast
- dbus-no-foreign-land: noforeignland.com tracking
- dbus-tides: Tide prediction from depth + harmonics
- dbus-vrm-history: VRM cloud history proxy
- dbus-windy-station: Windy.com weather upload
- mfd-custom-app: MFD app deployment package
- venus-html5-app: Custom Victron HTML5 app fork
- watermaker: Watermaker PLC control UI

Adds root README, .gitignore, project template, and per-project
.gitignore files. Sensitive config files excluded via .gitignore
with .example templates provided.

Made-with: Cursor
2026-03-16 17:04:16 +00:00

191 lines
5.4 KiB
Bash
Executable File

#!/bin/bash
#
# Build script for Generator Current Ramp Controller
#
# Creates a tar.gz package that can be:
# 1. Copied to a CerboGX device
# 2. Untarred to /data/
# 3. Installed by running install.sh
#
# Usage:
# ./build-package.sh # Creates package with default name
# ./build-package.sh --version 1.0.0 # Creates package with version in name
# ./build-package.sh --output /path/ # Specify output directory
#
# Output: dbus-generator-ramp-<version>.tar.gz
#
# Installation on CerboGX:
# scp dbus-generator-ramp-*.tar.gz root@<cerbo-ip>:/data/
# ssh root@<cerbo-ip>
# cd /data
# tar -xzf dbus-generator-ramp-*.tar.gz
# cd dbus-generator-ramp
# ./install.sh [--webui]
#
set -e
# Script directory (where the source files are)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Default values
VERSION="1.0.0"
OUTPUT_DIR="$SCRIPT_DIR"
PACKAGE_NAME="dbus-generator-ramp"
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
--version|-v)
VERSION="$2"
shift 2
;;
--output|-o)
OUTPUT_DIR="$2"
shift 2
;;
--help|-h)
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo " -v, --version VERSION Set package version (default: 1.0.0)"
echo " -o, --output PATH Output directory (default: script directory)"
echo " -h, --help Show this help message"
echo ""
echo "Example:"
echo " $0 --version 1.2.0 --output ./dist/"
exit 0
;;
*)
echo "Unknown option: $1"
echo "Use --help for usage information"
exit 1
;;
esac
done
# Build timestamp
BUILD_DATE=$(date -u +"%Y-%m-%d %H:%M:%S UTC")
BUILD_TIMESTAMP=$(date +%Y%m%d%H%M%S)
# Temporary build directory
BUILD_DIR=$(mktemp -d)
PACKAGE_DIR="$BUILD_DIR/$PACKAGE_NAME"
echo "=================================================="
echo "Building $PACKAGE_NAME package"
echo "=================================================="
echo "Version: $VERSION"
echo "Build date: $BUILD_DATE"
echo "Source: $SCRIPT_DIR"
echo "Output: $OUTPUT_DIR"
echo ""
# Create package directory structure
echo "1. Creating package structure..."
mkdir -p "$PACKAGE_DIR"
mkdir -p "$PACKAGE_DIR/service/log"
mkdir -p "$PACKAGE_DIR/service-webui/log"
mkdir -p "$PACKAGE_DIR/qml"
# Copy main Python files
echo "2. Copying application files..."
cp "$SCRIPT_DIR/dbus-generator-ramp.py" "$PACKAGE_DIR/"
cp "$SCRIPT_DIR/config.py" "$PACKAGE_DIR/"
cp "$SCRIPT_DIR/ramp_controller.py" "$PACKAGE_DIR/"
cp "$SCRIPT_DIR/overload_detector.py" "$PACKAGE_DIR/"
cp "$SCRIPT_DIR/web_ui.py" "$PACKAGE_DIR/"
# Copy service files
echo "3. Copying service files..."
cp "$SCRIPT_DIR/service/run" "$PACKAGE_DIR/service/"
cp "$SCRIPT_DIR/service/log/run" "$PACKAGE_DIR/service/log/"
cp "$SCRIPT_DIR/service-webui/run" "$PACKAGE_DIR/service-webui/"
cp "$SCRIPT_DIR/service-webui/log/run" "$PACKAGE_DIR/service-webui/log/"
# Copy QML files
echo "4. Copying GUI files..."
cp "$SCRIPT_DIR/qml/PageSettingsGeneratorRamp.qml" "$PACKAGE_DIR/qml/"
# Copy installation scripts
echo "5. Copying installation scripts..."
cp "$SCRIPT_DIR/install.sh" "$PACKAGE_DIR/"
cp "$SCRIPT_DIR/uninstall.sh" "$PACKAGE_DIR/"
cp "$SCRIPT_DIR/install_gui.sh" "$PACKAGE_DIR/"
# Copy documentation
echo "6. Copying documentation..."
cp "$SCRIPT_DIR/README.md" "$PACKAGE_DIR/"
# Create version file with build info
echo "7. Creating version info..."
cat > "$PACKAGE_DIR/VERSION" << EOF
Package: $PACKAGE_NAME
Version: $VERSION
Build Date: $BUILD_DATE
Build Timestamp: $BUILD_TIMESTAMP
Installation:
1. Copy this package to CerboGX: scp $PACKAGE_NAME-$VERSION.tar.gz root@<cerbo-ip>:/data/
2. SSH to CerboGX: ssh root@<cerbo-ip>
3. Extract: cd /data && tar -xzf $PACKAGE_NAME-$VERSION.tar.gz
4. Install: cd $PACKAGE_NAME && ./install.sh [--webui]
For more information, see README.md
EOF
# Set executable permissions
echo "8. Setting permissions..."
chmod +x "$PACKAGE_DIR/dbus-generator-ramp.py"
chmod +x "$PACKAGE_DIR/web_ui.py"
chmod +x "$PACKAGE_DIR/install.sh"
chmod +x "$PACKAGE_DIR/uninstall.sh"
chmod +x "$PACKAGE_DIR/install_gui.sh"
chmod +x "$PACKAGE_DIR/service/run"
chmod +x "$PACKAGE_DIR/service/log/run"
chmod +x "$PACKAGE_DIR/service-webui/run"
chmod +x "$PACKAGE_DIR/service-webui/log/run"
# Create output directory if needed
mkdir -p "$OUTPUT_DIR"
# Create the tar.gz package
TARBALL_NAME="$PACKAGE_NAME-$VERSION.tar.gz"
TARBALL_PATH="$OUTPUT_DIR/$TARBALL_NAME"
echo "9. Creating package archive..."
cd "$BUILD_DIR"
tar -czf "$TARBALL_PATH" "$PACKAGE_NAME"
# Calculate checksum
CHECKSUM=$(sha256sum "$TARBALL_PATH" | cut -d' ' -f1)
# Create checksum file
echo "$CHECKSUM $TARBALL_NAME" > "$OUTPUT_DIR/$TARBALL_NAME.sha256"
# Clean up
echo "10. Cleaning up..."
rm -rf "$BUILD_DIR"
# Get file size
FILE_SIZE=$(du -h "$TARBALL_PATH" | cut -f1)
echo ""
echo "=================================================="
echo "Build complete!"
echo "=================================================="
echo ""
echo "Package: $TARBALL_PATH"
echo "Size: $FILE_SIZE"
echo "SHA256: $CHECKSUM"
echo ""
echo "Installation on CerboGX:"
echo " scp $TARBALL_PATH root@<cerbo-ip>:/data/"
echo " ssh root@<cerbo-ip>"
echo " cd /data"
echo " tar -xzf $TARBALL_NAME"
echo " cd $PACKAGE_NAME"
echo " ./install.sh # Main service only"
echo " ./install.sh --webui # With web UI"
echo ""