Thursday, May 2, 2024
 Popular · Latest · Hot · Upcoming
5
rated 0 times [  5] [ 0]  / answers: 1 / hits: 1786  / 2 Years ago, tue, july 19, 2022, 11:23:21

I am maintaining a debian package, which includes some config files that are installed under /etc/. Is there a way I can somehow make the package to always automatically --purge itself whenever a user does a regular apt-get remove mypackage ?



The reason is that I have some config files in /etc that should really be removed when the binaries are removed, otherwise it can lead to weird behavior. However I still want to treat them as conf files, i.e. make sure apt does not just wipe them on every upgrade of the package. But they should be removed when the package is uninstalled.



Currently I am manually deleting the /etc conf files in my postrm script. However I just found out that this has a unfortunate side effect: if the user uninstalls and then later re-installs the package, the conf files won't be reinstalled, because apt thinks that they are still there. So is there a way I can manually trigger a full 'purge' in my postrm, such that apt knows that the conf files are gone?


More From » apt

 Answers
2

The debian policy forbids you from messing around with files that belong to other packages and/or system changes. (or at least I think it does)



Teach your users



You may instruct users to use purge instead of remove:



sudo apt-get purge mypackage


Automatic overwrite



If you need to overwrite configuration files, debian may prompt the user to install the maintainer configuration files: http://www.debian.org/doc/manuals/maint-guide/dother.en.html#conffiles




One of the most annoying things about software is when you spend a
great deal of time and effort customizing a program, only to have an
upgrade stomp all over your changes. Debian solves this problem by
marking such configuration files as conffiles. [55] When you upgrade a
package, you'll be asked whether you want to keep your old
configuration files or not.




Force new configuration files by default



You may do that automatically while upgrading:



apt-get -o Dpkg::Options::="--force-confnew" dist-upgrade


Sources: http://raphaelhertzog.com/2010/09/21/debian-conffile-configuration-file-managed-by-dpkg/ and https://askubuntu.com/a/104912/5538



Provides/Conflicts/Replaces



I'm not sure about this, but I think you may can fully purge and replace an old package version with a new package version.



Read here: http://www.debian.org/doc/debian-policy/ch-relationships.html#s-replaces


[#34905] Wednesday, July 20, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
oneeme

Total Points: 340
Total Questions: 110
Total Answers: 133

Location: Ghana
Member since Fri, Oct 21, 2022
2 Years ago
;