A debian package I made overwrote files belonging to other packages (using –force-overwrite option). I realized this was bad, but after deleting these files from the package, building and reinstalling, it’ll delete those files since it think’s my package owns those files and no longer needs them.
I need dpkg to forget my package ever knew about those files, such that I can remove/purge/install and without it ever thinking about those files again.
Note that this package is only meant to be deployed on systems I control, not distributed to clients, so tinkering with already installed packages is acceptable, so long as I can get this back to a non-messed up state.
Couldn’t find an answer on stackoverflow or here, appreciate any help or links to similar questions I missed.
2
Answers
Found that dpkg stores a list of each installed package's files here:
Appears to be a list of every directory and file installed by the package, eg
Fix:
sudo vim /var/lib/dpkg/info/mydpkg.list
and delete lines of files I want my package to forget about, therefore not trying to delete when uninstalling (or when installing a new version of the package that doesn't have those files anymore.) Unclear on if it's necessary to delete the lines referencing parent directories (eg /etc/udev and /etc/udev/rules.d above).Bonus: I found this by using strace on the command that lists these files, finding out where it gets its info from:
Taken from here: https://unix.stackexchange.com/questions/200171/where-does-dpkg-l-gather-its-information
We can use some commands that help us to keep the package dependency and remove the package.
Remove the package without removing the dependency.
sudo dpkg -r –force-depends <package_name>
Remove the package including the configuration file and without removing the dependency.
sudo dpkg -P –force-depends <package_name>
I highly don’t recommend this thing because sometimes dependency may create an issue in the future.
I always prefer to uninstall all the dependency when I uninstall the package.
If your package is broken then you can use the following command to resolve an issue.
To fix the broken packages
I have answered this question based on this article.