I've created a Debian package with a file that is deeply nested under /etc. (I'm using a local repo for this custom package.)
This package is to be deployed on embedded systems with no front end. It is more important to make sure that files match the package than that user modifications are preserved. There should be no user modifications of the package's files under /etc, but I want to make sure that any accidental user modifications (corruptions) are correct on upgrade.
I noticed that when I had manually modified /etc/.../my_file and upgraded the package to the latest version, /etc/.../my_file still contained my modification and didn't match the file in the package. I don't remember even being asked whether I wanted to keep the local or package version (as I often am with "real" Debian packages).
I understand why keeping local modifications is right for normal packages, but I need to override it.
How can I make my Debian package's files, under /etc, always overwrite local changes? Ideally without prompting.
You cannot and mustn't do that. What you are describing would be a stark violation of Debian policy.
What perhaps you meant to ask was "how can I upgrade a configuration-like file from a previous version of this package to a new version if it hasn't been modified by a local administrator?" The ucf
package provides logic for this.
Perhaps see also https://www.debian.org/doc/debian-policy/ap-pkg-conffiles.html