Set apt-get options to tolerate harmless 'dpkg --force-conflicts' kludge?

7,834

Solution 1

Since OP asked for a list of commands (with which to change the relevant metadata of the package) in the comments to Gilles' answer, here it is:

# download .deb
apt download parallel
# alternatively: aptitude download parallel

# unpack
dpkg-deb -R parallel_*.deb tmp/

# make changes to the package metadata
sed -i \
  -e '/^Version:/s/$/~nomoreutconfl/' \
  -e '/^Conflicts: moreutils/d' \
  tmp/DEBIAN/control

# pack anew
dpkg-deb -b tmp parallel_custom.deb

# install
dpkg -i parallel_custom.deb

This is under the assumptions that the conflicts line only has moreutils as an entry (and without version restrictions) as was the case in my installation. Otherwise, use '/^Conflicts:/s/\(, \)\?moreutils\( [^,]\+\)\?//' as the second sed script to only remove the relevant part of the line and support version restrictions.

Your installed package won't be overwritten by newer versions from the repository and you have to manually repeat this procedure for every update to the GNU parallel package if you want to keep this package up-to-date.

Solution 2

A conflict between packages is harmful in and of itself. When you force dpkg to install the conflicting packages, this may not cause any other harm if the conflict was declared for no good reason, but the packages are still conflicting. APT works hard to resolve conflicts when installing packages and it doesn't have a list of conflicts to ignore. You can't solve this by making it pass different options to dpkg: the problem is that the conflicts make APT's own job impossible.

Never install conflicting packages unless it's a temporary state to get out of a situation where APT breaks down. Don't run APT until you've worked with dpkg to get out of the conflicting situation.

If you want to install conflicting packages, modify them first to remove the Conflict: declaration, in addition to resolving whatever problems motivated the conflict declaration.

Share:
7,834

Related videos on Youtube

agc
Author by

agc

Decades long amateur interest in lazy programming, cheap hardware, miscellaneous data, free software, online lurking, and other manifestations of human error and the madness of systems. Etc.

Updated on September 18, 2022

Comments

  • agc
    agc over 1 year

    A trivially conflicting package foo can be made to work with bar, by running dpkg --force-conflicts -i foo. But eventually it's time to upgrade, and 'apt-get' objects:

    % apt-get upgrade
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    You might want to run 'apt-get -f install' to correct these.
    The following packages have unmet dependencies:
     foo : Conflicts: bar but 0.2-1 is installed
    E: Unmet dependencies. Try using -f.
    

    Can apt-get be tweaked/forced to tolerate the (pretty much fixed) conflict, then upgrade?

    (Quickie existence proof: uninstall foo, then upgrade, then reinstall foo as before. Therefore it is possible, the question is finding the least cumbersome mechanism.)


    An example, but this question is not about any two particular packages.

    For several years GNU parallel has had a trivial conflict with moretutils; each provides /usr/bin/parallel. dpkg can force co-existence:

    # assume 'moreutils' is already installed, and 'parallel' is in
    # apt's cache directory.
    dpkg --force-conflicts -i /var/cache/apt/archives/parallel_20141022+ds1-1_all.deb
    

    This creates a diversion, renames the moreutils version to /usr/bin/parallel.moreutils. Both programs work, until the user upgrades.

    I tried an -o option, but that didn't bring on peace:

    apt-get -o Dpkg::Options::="--force-conflicts" install parallel moreutils
    

    Possible -o options number in the hundreds, however...

    • Alen Milakovic
      Alen Milakovic about 8 years
      "Can apt-get be forced to tolerate the (pretty much fixed) conflict, then upgrade?" Sorry, it's not fixed. You need to fix it before doing anything else.And no, conflicting packages cannot be made to work with each other. And --forcing things is generally a bad idea unless you know what you are doing.
    • agc
      agc about 8 years
      @FaheemMitha, "it's not fixed" refers to what specifically? The dpkg level, the apt level or what?
    • Alen Milakovic
      Alen Milakovic about 8 years
      PS: I was informed (by @derobert) that this is a manifestion of Debian bug 749355. You should have mentioned that in the question. But you should still not try to make these packages co-exist.
    • Alen Milakovic
      Alen Milakovic about 8 years
      Both dpkg and apt are clearly unhappy with the current situation. And the only way to fix things is not have both of the packages installed. Thers is no good way to placate them, and trying to do so will not lead anywhere.
    • agc
      agc about 8 years
      @FaheemMitha, "this question is not about any two particular packages."
    • Alen Milakovic
      Alen Milakovic about 8 years
      Ok. In that case, the answer is, no, you don't want to do that.
    • agc
      agc about 8 years
      @FaheemMitha, so by "it's not fixed" you meant apt specifically?
  • agc
    agc about 8 years
    could you briefly elaborate on how you'd "modify them first to remove the Conflict: declaration"?
  • Gilles 'SO- stop being evil'
    Gilles 'SO- stop being evil' about 8 years
    @agc Either rebuild the package, or modify the binary package by opening it in an editor such as Emacs and editing the control file, or modify the binary package by unpacking it, editing the control file and repacking it.
  • agc
    agc over 7 years
    thanks, but please be more specific, preferably using sed (or something like it) instead of a GUI editor. The goal is a relatively foolproof one-liner, as far as might be possible.
  • agc
    agc over 7 years
    Well, that works but apt upgrade complains that parallel (the same version as the just tweaked .deb) has been kept back. Still, that is an improvement on the dpkg --force-conflicts method, where every upgrade breaks one of the programs -- the phk method allows every other upgrade.