From 4000d0972e58435f452699b185bcd2f75a7fc8db Mon Sep 17 00:00:00 2001 From: Fredrik Wahlberg Date: Sun, 28 Dec 2025 00:42:05 +0100 Subject: [PATCH] Final polish for deploy --- debian/sensorpajen.debhelper.log | 2 +- debian/sensorpajen/DEBIAN/control | 2 +- debian/sensorpajen/DEBIAN/md5sums | 5 ++-- debian/sensorpajen/DEBIAN/postinst | 24 ++++++++++++------- .../opt/sensorpajen/pyproject.toml | 1 + .../opt/sensorpajen/requirements.txt | 3 +++ .../examples/sensorpajen.env.example | 2 +- 7 files changed, 26 insertions(+), 13 deletions(-) create mode 100644 debian/sensorpajen/opt/sensorpajen/requirements.txt diff --git a/debian/sensorpajen.debhelper.log b/debian/sensorpajen.debhelper.log index a37a5ef..b902d64 100644 --- a/debian/sensorpajen.debhelper.log +++ b/debian/sensorpajen.debhelper.log @@ -1 +1 @@ -dh_auto_install +dh_builddeb diff --git a/debian/sensorpajen/DEBIAN/control b/debian/sensorpajen/DEBIAN/control index 220916f..064631b 100644 --- a/debian/sensorpajen/DEBIAN/control +++ b/debian/sensorpajen/DEBIAN/control @@ -2,7 +2,7 @@ Package: sensorpajen Version: 2.0.0-dev Architecture: all Maintainer: Fredrik -Installed-Size: 109 +Installed-Size: 110 Depends: python3 (>= 3.9), python3-venv, python3-pip, bluetooth, bluez, libcap2-bin Recommends: mosquitto-clients Section: misc diff --git a/debian/sensorpajen/DEBIAN/md5sums b/debian/sensorpajen/DEBIAN/md5sums index a40a703..de05b28 100644 --- a/debian/sensorpajen/DEBIAN/md5sums +++ b/debian/sensorpajen/DEBIAN/md5sums @@ -1,4 +1,5 @@ -90ea43f1be78ca18b9210f2d370001c4 opt/sensorpajen/pyproject.toml +3b3c15c00bf48fc519b8fbe507a93a7e opt/sensorpajen/pyproject.toml +0894789523a53bb372980c0906a7d0b5 opt/sensorpajen/requirements.txt 940d73f24eb9f971ce27f9355e3072f3 opt/sensorpajen/scripts/approve-sensors.sh 20eb4f3839b990a530410768897402c0 opt/sensorpajen/src/sensorpajen/__init__.py 1f452c46e42f8dc3751dba6ca68256e9 opt/sensorpajen/src/sensorpajen/approve_sensors.py @@ -13,6 +14,6 @@ c9c22f9c1d65bfafd89fa45f16b7192b usr/lib/systemd/system/sensorpajen.service bd2f1371c60af415bc9d0dbc1111184d usr/share/doc/sensorpajen/ROADMAP.md.gz 380e8e6b01b757ceac05bc5805844ae4 usr/share/doc/sensorpajen/changelog.Debian.gz 14152a98d7cd7fe8daf280aacc4cbf3f usr/share/doc/sensorpajen/examples/discovered_sensors.json.example -b0249deee21ceb834bc2fe9947be82d3 usr/share/doc/sensorpajen/examples/sensorpajen.env.example +387cb9ee7f22570312604e2cc07ca7a0 usr/share/doc/sensorpajen/examples/sensorpajen.env.example 292efbddd951c39cb2c9546d5fac5e05 usr/share/doc/sensorpajen/examples/sensors.json.example 5f647c63bfc3b174611694779fd215e0 usr/share/doc/sensorpajen/readme.md.gz diff --git a/debian/sensorpajen/DEBIAN/postinst b/debian/sensorpajen/DEBIAN/postinst index bf90997..22f3432 100755 --- a/debian/sensorpajen/DEBIAN/postinst +++ b/debian/sensorpajen/DEBIAN/postinst @@ -42,13 +42,24 @@ case "$1" in venv/bin/pip install --upgrade pip setuptools wheel fi - # Install Python dependencies from pyproject.toml + # Install Python dependencies from requirements.txt echo "Installing Python dependencies..." - venv/bin/pip install -e . || { - echo "Warning: pip install failed. You may need to install dependencies manually." - } + if [ -f "/opt/sensorpajen/requirements.txt" ]; then + venv/bin/pip install -r /opt/sensorpajen/requirements.txt + else + echo "Warning: requirements.txt not found, installing bluepy and paho-mqtt directly" + venv/bin/pip install bluepy paho-mqtt + fi + + if [ $? -ne 0 ]; then + echo "Error: Failed to install dependencies" + exit 1 + fi - # Set Bluetooth capabilities on Python executable + # Set ownership of application directory BEFORE setting capabilities + chown -R sensorpajen:sensorpajen /opt/sensorpajen + + # Set Bluetooth capabilities on Python executable (after ownership change) PYTHON_PATH=$(readlink -f /opt/sensorpajen/venv/bin/python3) if command -v setcap >/dev/null 2>&1; then setcap cap_net_raw,cap_net_admin+eip "$PYTHON_PATH" || { @@ -59,9 +70,6 @@ case "$1" in echo "Warning: setcap not found (install libcap2-bin package)" fi - # Set ownership of application directory - chown -R sensorpajen:sensorpajen /opt/sensorpajen - # Install systemd service file if [ -f /opt/sensorpajen/debian/sensorpajen.service ]; then cp /opt/sensorpajen/debian/sensorpajen.service /etc/systemd/system/ diff --git a/debian/sensorpajen/opt/sensorpajen/pyproject.toml b/debian/sensorpajen/opt/sensorpajen/pyproject.toml index b7a1c45..9e77055 100644 --- a/debian/sensorpajen/opt/sensorpajen/pyproject.toml +++ b/debian/sensorpajen/opt/sensorpajen/pyproject.toml @@ -26,6 +26,7 @@ classifiers = [ ] dependencies = [ + "pybluez>=0.31", "bluepy>=1.3.0", "paho-mqtt>=1.6.0", ] diff --git a/debian/sensorpajen/opt/sensorpajen/requirements.txt b/debian/sensorpajen/opt/sensorpajen/requirements.txt new file mode 100644 index 0000000..696a541 --- /dev/null +++ b/debian/sensorpajen/opt/sensorpajen/requirements.txt @@ -0,0 +1,3 @@ +pybluez +bluepy +paho-mqtt diff --git a/debian/sensorpajen/usr/share/doc/sensorpajen/examples/sensorpajen.env.example b/debian/sensorpajen/usr/share/doc/sensorpajen/examples/sensorpajen.env.example index 8ac0200..d227e0a 100644 --- a/debian/sensorpajen/usr/share/doc/sensorpajen/examples/sensorpajen.env.example +++ b/debian/sensorpajen/usr/share/doc/sensorpajen/examples/sensorpajen.env.example @@ -13,7 +13,7 @@ DISCOVERED_SENSORS_FILE=config/discovered_sensors.json WATCHDOG_TIMEOUT=5 ENABLE_BATTERY=true LOG_LEVEL=INFO -CONFIG_RELOAD_INTERVAL=900 # 15 minutes in seconds +CONFIG_RELOAD_INTERVAL=900 # ntfy Notifications (optional) NTFY_ENABLED=false