Bug 7586 - Compiled Python files not removed on uninstall/upgrade on Debian/Ubuntu
Summary: Compiled Python files not removed on uninstall/upgrade on Debian/Ubuntu
Status: CLOSED DUPLICATE of bug 5071
Alias: None
Product: ThinLinc
Classification: Unclassified
Component: Other (show other bugs)
Version: trunk
Hardware: PC Unknown
: P2 Normal
Target Milestone: 4.13.0
Assignee: Bugzilla mail exporter
URL:
Keywords:
Depends on: 7587
Blocks:
  Show dependency treegraph
 
Reported: 2020-11-10 09:38 CET by Pierre Ossman
Modified: 2020-11-23 16:19 CET (History)
0 users

See Also:
Acceptance Criteria:


Attachments

Description Pierre Ossman cendio 2020-11-10 09:38:02 CET
Debian (and hence Ubuntu) doesn't have anything equivalent to RPM's %ghost, so we don't currently have a mechanism to make sure Python's compile cache files are removed when ThinLinc is removed (or upgraded and some files have been removed).

Normally this just means some crap left on disk. On upgrade however it might causes issues as Python will gladly still load .pyc files without a corresponding .py file. So if we rely on getting an ImportError, or Python trying another import directory, then things will break.

On Debian the tool dh-python is available to help packagers deal with Python cache files. Might be worth a look to see how it deals with this.
Comment 1 Pierre Ossman cendio 2020-11-10 09:41:30 CET
Handling uninstallation is probably easy as we have a list of expected .pyc files. Upgrade is a lot more difficult though as we need to figure out the difference before and after the upgrade and only remove the relevant files.
Comment 2 Pierre Ossman cendio 2020-11-23 16:12:55 CET
Here is the repo for dh-python:

https://salsa.debian.org/python-team/tools/dh-python

The stuff we are interested in are the postinst and prerm scripts:

https://salsa.debian.org/python-team/tools/dh-python/-/tree/master/autoscripts

In short, Debian will after installation list all the files included in the package (dpkg -L <pkg>) and compile each one (using the helper py3compile). And just before removal it will again list all the files included in the package, and remove any cache files it can compute based on the package file names.

On an upgrade the removal of the old package is run before the compilation of the new one. So everything gets cleaned out and then re-generated.
Comment 3 Pierre Ossman cendio 2020-11-23 16:19:00 CET

*** This bug has been marked as a duplicate of bug 5071 ***

Note You need to log in before you can comment on or make changes to this bug.