How to force to override files when creating deb package?
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 videos on Youtube
RdlP
Updated on September 18, 2022Comments
-
RdlP over 1 year
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?
-
RdlP about 7 yearsIn 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. -
Stephen Kitt about 7 yearsThat'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. -
Hi-Angel over 3 yearsAs someone who spent almost a day fiddling with
dpkg-divert
, I gotta say that making your users to provide--force-overwrite
is a solution way better both for end-users and maintainers. The reason is thatdpkg-divert
is not an utility that Just Works™, it has like a billion corner-cases, resulting in distinct errors on installation, upgrade, removal, or on installation-fail (yeah, don't forget to handle that one too!), etc. As a result, your user may stumble upon one of these that you didn't handle, and would be left in a broken state with no means to get your package installed. -
Stephen Kitt over 3 years@Hi-Angel yes,
dpkg-divert
is far from perfect. But making users provide--force-overwrite
is asking for trouble further down the line: whenever one of the packages containing the overwritten file needs to be upgraded, they’ll run into difficulties, and it won’t necessarily be obvious that the overwriting package is involved.