diff options
Diffstat (limited to 'packaging')
| -rwxr-xr-x | packaging/deb/meshbay-hub/DEBIAN/prerm | 24 | ||||
| -rwxr-xr-x | packaging/deb/meshbay-node/DEBIAN/prerm | 36 | ||||
| -rw-r--r-- | packaging/rpm/meshbay-hub.spec | 6 | ||||
| -rw-r--r-- | packaging/rpm/meshbay-node.spec | 19 |
4 files changed, 83 insertions, 2 deletions
diff --git a/packaging/deb/meshbay-hub/DEBIAN/prerm b/packaging/deb/meshbay-hub/DEBIAN/prerm new file mode 100755 index 0000000..359e0a5 --- /dev/null +++ b/packaging/deb/meshbay-hub/DEBIAN/prerm @@ -0,0 +1,24 @@ +#!/bin/sh +set -e + +# A hub left running once its package is gone serves from deleted code, and +# keeps writing bytecode into the shared venv. +case "$1" in + remove|deconfigure) + if [ -d /run/systemd/system ]; then + systemctl stop meshbay-hub.service 2>/dev/null || true + fi + ;; +esac + +# The hub's code lives in meshbay-common's venv, and meshbay-common's own +# cleanup runs only after this package is gone: the bytecode compiled next to +# it is removed here, or dpkg cannot remove the directories it sits in. +case "$1" in + remove|upgrade|deconfigure) + find /opt/meshbay-common/venv/lib/python3.*/site-packages/meshbay_hub \ + -depth -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true + ;; +esac + +#DEBHELPER# diff --git a/packaging/deb/meshbay-node/DEBIAN/prerm b/packaging/deb/meshbay-node/DEBIAN/prerm new file mode 100755 index 0000000..6ccdead --- /dev/null +++ b/packaging/deb/meshbay-node/DEBIAN/prerm @@ -0,0 +1,36 @@ +#!/bin/sh +set -e + +# A node left running once its package is gone serves from deleted code, and +# keeps writing bytecode into the shared venv. Every instance stops here: the +# system ones, and the user service in each running user manager. Not on +# upgrade: the postinst restarts the node onto new code. +stop_user_nodes() { + for bus in /run/user/*/systemd/private; do + [ -S "$bus" ] || continue + uid=$(basename "$(dirname "$(dirname "$bus")")") + user=$(id -nu "$uid" 2>/dev/null) || continue + systemctl --user -M "$user@" stop meshbay-node.service 2>/dev/null || true + done +} + +case "$1" in + remove|deconfigure) + if [ -d /run/systemd/system ]; then + systemctl stop 'meshbay-node@*.service' 2>/dev/null || true + stop_user_nodes + fi + ;; +esac + +# The node's code lives in meshbay-common's venv, and meshbay-common's own +# cleanup runs only after this package is gone: the bytecode compiled next to +# it is removed here, or dpkg cannot remove the directories it sits in. +case "$1" in + remove|upgrade|deconfigure) + find /opt/meshbay-common/venv/lib/python3.*/site-packages/meshbay_node \ + -depth -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true + ;; +esac + +#DEBHELPER# diff --git a/packaging/rpm/meshbay-hub.spec b/packaging/rpm/meshbay-hub.spec index 90a4f08..ffd991a 100644 --- a/packaging/rpm/meshbay-hub.spec +++ b/packaging/rpm/meshbay-hub.spec @@ -40,6 +40,12 @@ install -d -o root -g meshbay -m 750 /etc/meshbay %preun %systemd_preun meshbay-hub.service +# The hub's code lives in meshbay-common's venv, whose own cleanup runs only +# after this package is gone: the bytecode compiled next to it is removed here. +if [ "$1" -eq 0 ]; then + find /opt/meshbay-common/venv/lib/python3.*/site-packages/meshbay_hub \ + -depth -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true +fi %postun %systemd_postun_with_restart meshbay-hub.service diff --git a/packaging/rpm/meshbay-node.spec b/packaging/rpm/meshbay-node.spec index 9b9c6bf..89f3a0a 100644 --- a/packaging/rpm/meshbay-node.spec +++ b/packaging/rpm/meshbay-node.spec @@ -70,8 +70,23 @@ if [ -d /run/systemd/system ]; then fi %preun -if [ -d /run/systemd/system ]; then - systemctl daemon-reload || true +# A node left running once its package is gone serves from deleted code, and +# keeps writing bytecode into the shared venv. Every instance stops on erase +# ($1 = 0): the system ones, and the user service in each running user manager. +if [ "$1" -eq 0 ] && [ -d /run/systemd/system ]; then + systemctl stop 'meshbay-node@*.service' 2>/dev/null || true + for bus in /run/user/*/systemd/private; do + [ -S "$bus" ] || continue + uid=$(basename "$(dirname "$(dirname "$bus")")") + user=$(id -nu "$uid" 2>/dev/null) || continue + systemctl --user -M "$user@" stop meshbay-node.service 2>/dev/null || true + done +fi +# The node's code lives in meshbay-common's venv, whose own cleanup runs only +# after this package is gone: the bytecode compiled next to it is removed here. +if [ "$1" -eq 0 ]; then + find /opt/meshbay-common/venv/lib/python3.*/site-packages/meshbay_node \ + -depth -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true fi %files |