diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-10-01 16:58:47 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-10-01 16:58:47 +0200 |
| commit | 03f560bb4aaeda0e06c95684c187a394593c88e3 (patch) | |
| tree | 0d4732c101d1bdbe942a82171aaf3ba786457847 /packaging | |
| parent | d0feb2619bf95ba729cf44513ab7370add10f5f8 (diff) | |
| download | meshbay-03f560bb4aaeda0e06c95684c187a394593c88e3.tar.gz | |
fix(packaging): meshbay-common clears its compiled bytecode before an upgrade
The postinst compiles __pycache__ directories the package does not own; on
the next upgrade they kept dpkg from removing directories the new version no
longer ships, and it warned. preinst/prerm (deb) and %pre/%preun (rpm)
remove them first.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'packaging')
| -rwxr-xr-x | packaging/deb/meshbay-common/DEBIAN/preinst | 14 | ||||
| -rwxr-xr-x | packaging/deb/meshbay-common/DEBIAN/prerm | 13 | ||||
| -rw-r--r-- | packaging/rpm/meshbay-common.spec | 14 |
3 files changed, 41 insertions, 0 deletions
diff --git a/packaging/deb/meshbay-common/DEBIAN/preinst b/packaging/deb/meshbay-common/DEBIAN/preinst new file mode 100755 index 0000000..16af2f8 --- /dev/null +++ b/packaging/deb/meshbay-common/DEBIAN/preinst @@ -0,0 +1,14 @@ +#!/bin/sh +set -e + +# The postinst compiles bytecode next to every module, into __pycache__ +# directories the package does not own. Left in place, they keep dpkg from +# removing a directory the new version no longer ships, and it warns. +case "$1" in + upgrade) + find /opt/meshbay-common/venv -depth -type d -name __pycache__ \ + -exec rm -rf {} + 2>/dev/null || true + ;; +esac + +#DEBHELPER# diff --git a/packaging/deb/meshbay-common/DEBIAN/prerm b/packaging/deb/meshbay-common/DEBIAN/prerm new file mode 100755 index 0000000..e7b665b --- /dev/null +++ b/packaging/deb/meshbay-common/DEBIAN/prerm @@ -0,0 +1,13 @@ +#!/bin/sh +set -e + +# Bytecode the postinst compiled is not the package's: removed here, so that +# dpkg can remove the directories it was written into. +case "$1" in + remove|upgrade|deconfigure) + find /opt/meshbay-common/venv -depth -type d -name __pycache__ \ + -exec rm -rf {} + 2>/dev/null || true + ;; +esac + +#DEBHELPER# diff --git a/packaging/rpm/meshbay-common.spec b/packaging/rpm/meshbay-common.spec index 948de9a..147dc17 100644 --- a/packaging/rpm/meshbay-common.spec +++ b/packaging/rpm/meshbay-common.spec @@ -17,6 +17,20 @@ Installs to /opt/meshbay-common/venv/. %install cp -a %{_staging_root}/* %{buildroot}/ +# Bytecode written at run time into __pycache__ is not the package's, and would +# keep rpm from removing a directory the new version no longer ships. +%pre +if [ "$1" -ge 2 ]; then + find /opt/meshbay-common/venv -depth -type d -name __pycache__ \ + -exec rm -rf {} + 2>/dev/null || true +fi + +%preun +if [ "$1" -eq 0 ]; then + find /opt/meshbay-common/venv -depth -type d -name __pycache__ \ + -exec rm -rf {} + 2>/dev/null || true +fi + %files /opt/meshbay-common |