An Impatient Developer’s Guide to Debian Maintenance (Installation) Scripts and Package Diverts
The people involved in coming up with the dpkg scheme for installing / upgrading / downgrading / removing packages are very clever. While unintuitive to the uninitiated, the scheme is mostly logical and reasonable, though there are some points where I feel a little more effort and consideration could have made a world of difference.
“The evil that men do lives on and on” — Iron Maiden
In addition to regular installation behaviour, I needed to wrap my head around “package diverts”, which is a very clever system for enabling packages to handle file conflicts. Except that it doesn’t handle what I would consider to be a very basic use case:
- Install an initial version of our package.
- Discover that our package needs to overwrite a file that’s installed by an upstream dependency.
- Create a new version of our package that includes the file and configures a “package divert” to safely stow the dependency’s version.
- Remove the “package divert” on the file if the newer version of the package is uninstalled or downgraded to the previous version that doesn’t include it.