Files
venus/dbus-windy-station/build-package.sh
Paul G 36a07dacb9 Extract shared signal-based D-Bus readers into lib/signal_reader.py
- Added lib/signal_reader.py with SignalGpsReader, SignalMeteoReader, and
  SignalDepthReader that use PropertiesChanged signal subscriptions instead
  of polling via GetValue(), reducing D-Bus overhead at steady state.
- Each reader discovers its service dynamically, seeds its cache with a
  one-shot GetValue, then relies on signals for all subsequent updates.
- Refactored dbus-tides, dbus-windy-station, dbus-no-foreign-land,
  dbus-lightning, and dbus-meteoblue-forecast to import from the shared
  library, removing ~600 lines of duplicated _unwrap() helpers and
  per-service GPS/meteo/depth reader classes.
- Updated install.sh for all five services to deploy signal_reader.py
  to /data/lib/ on the target device.
- Updated build-package.sh for all five services to bundle
  signal_reader.py into the .tar.gz package.
- Updated README.md with the new lib/ entry in the project table and
  documented the shared D-Bus readers pattern.
- Bumped version numbers in affected services (e.g. nfl_tracking 2.0.1).

Made-with: Cursor
2026-03-27 01:03:16 +00:00

189 lines
5.9 KiB
Bash
Executable File

#!/bin/bash
#
# Build script for Windy Station Venus OS package
#
# Creates a tar.gz package that can be:
# 1. Copied to a Venus OS device (Cerbo GX, Venus GX, etc.)
# 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
#
# Installation on Venus OS:
# scp dbus-windy-station-*.tar.gz root@<device-ip>:/data/
# ssh root@<device-ip>
# cd /data && tar -xzf dbus-windy-station-*.tar.gz
# bash /data/dbus-windy-station/install.sh
# bash /data/dbus-windy-station/install_gui.sh # v1 GUI (legacy)
# bash /data/dbus-windy-station/install_gui_v2.sh # v2 GUI plugin (v3.70+)
# Configure via Settings > Windy Station (v1) or Settings > Integrations (v2)
#
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
VERSION="1.0.0"
OUTPUT_DIR="$SCRIPT_DIR"
PACKAGE_NAME="dbus-windy-station"
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"
exit 0
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done
BUILD_DATE=$(date -u +"%Y-%m-%d %H:%M:%S UTC")
BUILD_TIMESTAMP=$(date +%Y%m%d%H%M%S)
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 ""
echo "1. Creating package structure..."
mkdir -p "$PACKAGE_DIR"
mkdir -p "$PACKAGE_DIR/service/log"
mkdir -p "$PACKAGE_DIR/qml"
mkdir -p "$PACKAGE_DIR/gui-v2-source"
[ "$(uname)" = "Darwin" ] && export COPYFILE_DISABLE=1
echo "2. Copying application files..."
cp "$SCRIPT_DIR/windy_station.py" "$PACKAGE_DIR/"
cp "$SCRIPT_DIR/config.py" "$PACKAGE_DIR/"
if [ -f "$SCRIPT_DIR/../lib/signal_reader.py" ]; then
cp "$SCRIPT_DIR/../lib/signal_reader.py" "$PACKAGE_DIR/"
echo " Bundled shared library: signal_reader.py"
fi
echo "3. Copying service files..."
cp "$SCRIPT_DIR/service/run" "$PACKAGE_DIR/service/"
cp "$SCRIPT_DIR/service/log/run" "$PACKAGE_DIR/service/log/"
echo "4. Copying GUI files..."
if [ -f "$SCRIPT_DIR/qml/PageSettingsWindyStation.qml" ]; then
cp "$SCRIPT_DIR/qml/PageSettingsWindyStation.qml" "$PACKAGE_DIR/qml/"
fi
if [ -f "$SCRIPT_DIR/gui-v2-source/WindyStation_PageSettings.qml" ]; then
cp "$SCRIPT_DIR/gui-v2-source/WindyStation_PageSettings.qml" "$PACKAGE_DIR/gui-v2-source/"
fi
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/"
cp "$SCRIPT_DIR/install_gui_v2.sh" "$PACKAGE_DIR/"
cp "$SCRIPT_DIR/compile_gui_v2_plugin.py" "$PACKAGE_DIR/"
echo "6. Copying documentation..."
if [ -f "$SCRIPT_DIR/README.md" ]; then
cp "$SCRIPT_DIR/README.md" "$PACKAGE_DIR/"
fi
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 to Venus OS: scp $PACKAGE_NAME-$VERSION.tar.gz root@<device-ip>:/data/
2. SSH to device: ssh root@<device-ip>
3. Extract: cd /data && tar -xzf $PACKAGE_NAME-$VERSION.tar.gz
4. Install: bash /data/dbus-windy-station/install.sh
5. GUI (v1): bash /data/dbus-windy-station/install_gui.sh
GUI (v2): bash /data/dbus-windy-station/install_gui_v2.sh
6. Configure via Settings > Windy Station (v1) or Settings > Integrations (v2)
EOF
echo "8. Setting permissions..."
chmod +x "$PACKAGE_DIR/windy_station.py"
chmod +x "$PACKAGE_DIR/install.sh"
chmod +x "$PACKAGE_DIR/uninstall.sh"
chmod +x "$PACKAGE_DIR/install_gui.sh"
chmod +x "$PACKAGE_DIR/install_gui_v2.sh"
chmod +x "$PACKAGE_DIR/service/run"
chmod +x "$PACKAGE_DIR/service/log/run"
mkdir -p "$OUTPUT_DIR"
TARBALL_NAME="$PACKAGE_NAME-$VERSION.tar.gz"
OUTPUT_DIR_ABS="$(cd "$OUTPUT_DIR" && pwd)"
TARBALL_PATH="$OUTPUT_DIR_ABS/$TARBALL_NAME"
echo "9. Creating package archive..."
cd "$BUILD_DIR"
if [ "$(uname)" = "Darwin" ]; then
if command -v xattr >/dev/null 2>&1; then
xattr -cr "$PACKAGE_NAME"
fi
fi
tar --format=ustar -czf "$TARBALL_PATH" "$PACKAGE_NAME"
if command -v sha256sum >/dev/null 2>&1; then
CHECKSUM=$(sha256sum "$TARBALL_PATH" | cut -d' ' -f1)
else
CHECKSUM=$(shasum -a 256 "$TARBALL_PATH" | cut -d' ' -f1)
fi
echo "$CHECKSUM $TARBALL_NAME" > "$OUTPUT_DIR_ABS/$TARBALL_NAME.sha256"
echo "10. Cleaning up..."
rm -rf "$BUILD_DIR"
if [ "$(uname)" = "Darwin" ]; then
FILE_SIZE=$(du -h "$TARBALL_PATH" | cut -f1)
else
FILE_SIZE=$(du -h "$TARBALL_PATH" | cut -f1)
fi
echo ""
echo "=================================================="
echo "Build complete!"
echo "=================================================="
echo ""
echo "Package: $TARBALL_PATH"
echo "Size: $FILE_SIZE"
echo "SHA256: $CHECKSUM"
echo ""
echo "Installation on Venus OS:"
echo " scp $TARBALL_PATH root@<device-ip>:/data/"
echo " ssh root@<device-ip>"
echo " cd /data"
echo " tar -xzf $TARBALL_NAME"
echo " bash /data/dbus-windy-station/install.sh"
echo " bash /data/dbus-windy-station/install_gui.sh # v1 GUI (legacy)"
echo " bash /data/dbus-windy-station/install_gui_v2.sh # v2 GUI plugin (v3.70+)"
echo ""