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?


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.
  • In the python sample that you comment, when you compile python (for example python3.6) it create a symlink called python3, so, if you creates a debian package from a python sources with the command that I posted above, you get a .deb that has a python3 file that conflict with the python3 that you have installed on your system. – RdlP Mar 20 '17 at 21:50
  • That's why packaging isn't just blindly shipping the result of compiling some software. Check out the Python 3.6 packages, you'll see there's no conflict. The python3 symlinks are handled elsewhere. – Stephen Kitt Mar 20 '17 at 22:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.