I have a Debian package that I've created that provides a certain file that I no longer want to include in the next version of this Debian package. However, I don't want to actually delete the file when the package is upgraded. The problem is that when the package is upgraded, the file is deleted when the previous version's files are removed. The file is not a conffile and is not in /etc (it's buried deep in /var).
What I'm thinking is that I can somehow have the new package copy this file to a temporary location before the previous version of the package is upgraded, then copy it back to its original location post-install.
However, I'm not sure how to add commands in the new package that run before the previous version's files are removed.
Does dpkg provide a hook at this point (run before previous version of package's files are removed)? All of the maintainer scripts are under my control I'm just not sure which one to use and which command line arguments to check for (assuming there is a hook).
If not, is there some other way to drop a file from a Debian package without deleting the file on upgrade?
I need to support Debian Buster, Bookworm, and Trixie, and Ubuntu 22.04 and 24.04.
