The default nginx package creates a symlink named default
in the sites-enabled
dir, which points to a default config file in sites-available
. I'm currently creating a package for an app that sits on top of Nginx, and I want to remove or move away the default
symlink, and replace it with the config file from my package. Ideally, in the event that my package is removed, the original default
symlink will be restored.
I've been reading the manpage and examples of dpkg-divert
, but I don't quite see that it can do this. Is this achievable with dpkg-divert
, or do I have to think of another way?
If you want to divert a file owned by another package:
In your preinst, divert the file away.
In your postrm, divert the file back.
This won't work for the symlink
/etc/nginx/sites-enabled/default
, because it's created by thenginx
package's postinst rather than being part of the package. Since the symlink is part of the package, you can just rename it withmv
. I don't know if this is compliant with the Debian packaging policy; if this matters to you, as this is a rather specialized question, I recommend searching or asking on debian-devel.