Files
venus/dbus-no-foreign-land/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

223 lines
6.9 KiB
Bash
Executable File

#!/bin/bash
#
# Build script for NFL Tracking 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
#
# Output: dbus-no-foreign-land-<version>.tar.gz
#
# Installation on Venus OS:
# scp dbus-no-foreign-land-*.tar.gz root@<device-ip>:/data/
# ssh root@<device-ip>
# cd /data && tar -xzf dbus-no-foreign-land-*.tar.gz
# mv dbus-no-foreign-land /data/dbus-no-foreign-land
# bash /data/dbus-no-foreign-land/install.sh
# bash /data/dbus-no-foreign-land/install_gui.sh
# Configure via Settings > GPS > NFL Tracking
#
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-no-foreign-land"
# 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 (aligned with dbus-generator-ramp)
echo "1. Creating package structure..."
mkdir -p "$PACKAGE_DIR"
mkdir -p "$PACKAGE_DIR/service/log"
mkdir -p "$PACKAGE_DIR/qml"
# On macOS, prevent cp from copying extended attributes (avoids ._* and com.apple.provenance)
[ "$(uname)" = "Darwin" ] && export COPYFILE_DISABLE=1
# Copy application files
echo "2. Copying application files..."
cp "$SCRIPT_DIR/nfl_tracking.py" "$PACKAGE_DIR/"
cp "$SCRIPT_DIR/config.py" "$PACKAGE_DIR/"
cp "$SCRIPT_DIR/config.sample.ini" "$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
# 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/"
# Copy QML files
echo "4. Copying GUI files..."
if [ -f "$SCRIPT_DIR/qml/PageSettingsNflTracking.qml" ]; then
cp "$SCRIPT_DIR/qml/PageSettingsNflTracking.qml" "$PACKAGE_DIR/qml/"
fi
# 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/"
cp "$SCRIPT_DIR/restart.sh" "$PACKAGE_DIR/"
cp "$SCRIPT_DIR/download.sh" "$PACKAGE_DIR/"
# Copy DbusSettingsList (for SetupHelper integration)
if [ -f "$SCRIPT_DIR/DbusSettingsList" ]; then
cp "$SCRIPT_DIR/DbusSettingsList" "$PACKAGE_DIR/"
fi
# 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 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. Move: mv $PACKAGE_NAME /data/dbus-no-foreign-land
5. Install: bash /data/dbus-no-foreign-land/install.sh
6. GUI: bash /data/dbus-no-foreign-land/install_gui.sh
7. Configure via Settings > GPS > NFL Tracking
For more information, see README.md
EOF
# Set executable permissions
echo "8. Setting permissions..."
chmod +x "$PACKAGE_DIR/nfl_tracking.py"
chmod +x "$PACKAGE_DIR/install.sh"
chmod +x "$PACKAGE_DIR/uninstall.sh"
chmod +x "$PACKAGE_DIR/install_gui.sh"
chmod +x "$PACKAGE_DIR/restart.sh"
chmod +x "$PACKAGE_DIR/download.sh"
chmod +x "$PACKAGE_DIR/service/run"
chmod +x "$PACKAGE_DIR/service/log/run"
# Create output directory if needed
mkdir -p "$OUTPUT_DIR"
# Create the tar.gz package
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
# Strip macOS extended attributes (com.apple.provenance, etc.) before tarring
# to avoid "Ignoring unknown extended header keyword" warnings on Linux
if command -v xattr >/dev/null 2>&1; then
xattr -cr "$PACKAGE_NAME"
fi
fi
# Use POSIX ustar format - does not store extended attributes, avoids Linux extraction warnings
tar --format=ustar -czf "$TARBALL_PATH" "$PACKAGE_NAME"
# Calculate checksum (sha256sum on Linux, shasum on macOS)
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
# Create checksum file
echo "$CHECKSUM $TARBALL_NAME" > "$OUTPUT_DIR_ABS/$TARBALL_NAME.sha256"
# Clean up
echo "10. Cleaning up..."
rm -rf "$BUILD_DIR"
# Get file size
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 " mv $PACKAGE_NAME /data/dbus-no-foreign-land"
echo " bash /data/dbus-no-foreign-land/install.sh"
echo " bash /data/dbus-no-foreign-land/install_gui.sh"
echo " Configure via Settings > GPS > NFL Tracking"
echo ""