Debian – How to force to override files when creating deb package

debdebiandebian-installerdpkg

I am trying to create a deb package of programX.Y, it is possible that in the destine system exist the same program but other version (programX.Z) if I generate a deb pacakge with:

dpkg-buildpackage -us -uc --source-option=--include-binaries --source-option=-isession

When I try to install the pacakge in a system that has other version of program (programX.Z) I get:

dpkg: error processing programX.Y.deb (--install):
    trying to overwrite `/usr/lib/XXX', which is also in package programX.Z

I know if I pass –force-overwrite I solve the problem, but I don't want that solution.

The question is how can I create a deb package of a program version that could be install in the system and force overwriting automatically. An example could be python. Python3 has many versions (3.1, 3.2, 3.3, 3.4, 3.5…). I want install my custom python package version 3.6 in system that has installed python3.4.

It is possible?

Best Answer

You can’t create a package which does the equivalent of --force-overwrite, but there are other solutions.

  • A package can move a conflicting file out of the way; this is known as a diversion and is handled using dpkg-divert.
  • Files which are common to two packages (making them conflict) are typically shipped in a third (assuming they’re identical). This might be the appropriate solution for your /usr/lib/XXX problem.
  • Multiple versions of a package can be made co-installable, and if necessary, a default chosen either using alternatives, or a “defaults” package. This is the approach taken for Python interpreter packages, the GCC compiler... Currently in Debian unstable, Python 3.5 and 3.6 are available and can be installed side-by-side; the default Python 3 (3.5) is determined using symlinks in the python3 set of packages.
Related Question