Search code examples
debiandeb

Debian - how to overwrite a package's file


I have two Debian packages with different names: configA.deb, configB.deb. Both have the following lines in the control file:

Provides: my-config
Replaces: my-config

and both provide the same content - file: config

When I try to install configB.deb when configA.deb is already installed I get the following error:

dpkg: error processing archive configB.deb (--install):
trying to overwrite '/home/user/configs/config', which is also in package configA.deb

I would like the to install configB.deb without deleting/purging configA.deb first and without using option --force-overwrite. Is it possible?


Solution

  • Debian packages cannot overwrite each others' files. Use something like update-alternatives to symlink the file to one provided by one package or the other without wrecking the integrity of any package-installed files. Or use Conflicts: to force removal of package A when you try to install package B, and vice versa. As a third possible approach, a hacky workaround which I can't recommend would be to overwrite this file from each package's postinst with a copy from properly inside the package's protected resources.