24

Can I make the package manager resolve the conflict e.g. by renaming the binary (e.g. parallel → gparallel) or installing to a different place (e.g. /usr/ → /usr/local/ )?

clhy
  • 6,283
  • 8
  • 34
  • 66
Petr Skocik
  • 1,402
  • 3
  • 15
  • 30

4 Answers4

20

For Ubuntu v17.04 ("Zesty Zapus") and Debian v9 ("Stretch"), (2017 or newer), or distros based upon those versions, please read Bryan Larsen's answer first, which should be sufficient.

For versions from before 2017, read on...


Use dpkg to force the install; parallel gets along nicely with moreutils -- it renames moreutils' parallel util to parallel.moreutils. When the install is done both programs (GNU and moreutils) are available.

NB: if any user scripts call the old moreutils parallel, change those scripts to use the longer name.

Details: Fetch parallel package (without installing or removing anything). Then using compgen, (a bash internal command), find parallel package in archive. If there's more than one, use the latest. Force that package to install, despite conflicts.

apt-get --assume-yes --download-only install parallel &&
ls --sort=version $(compgen -f /var/cache/apt/archives/parallel) |
    tail -n 1 | xargs dpkg --force-conflicts -i

How to view the resulting diversions:

dpkg-divert --list 'par*'

Output:

diversion of /usr/share/man/man1/parallel.1.gz to  /usr/share/man/man1/parallel.moreutils.1.gz by parallel
diversion of /usr/bin/parallel to /usr/bin/parallel.moreutils by parallel

See how both binary executables are available:

compgen -c parallel | xargs which | xargs ls -l

Output:

-rwxr-xr-x 1 root root 240814 Oct 31  2014 /usr/bin/parallel
-rwxr-xr-x 1 root root  10592 Jul 21  2015 /usr/bin/parallel.moreutils
agc
  • 627
  • 5
  • 16
  • 1
    Maybe not! This _used_ to work OK, but on a Lubuntu box, everything installs, but _apt-get_ keeps wanting to get rid of one the parallels... probably needs another override. More later... – agc May 05 '16 at 14:00
  • ...except that `apt-get install` keeps complaining about the conflict, as you wrote earlier. – krlmlr Sep 08 '16 at 14:16
  • 1
    I edited `/var/lib/dpkg/status` to remove the conflict. Searched for "Conflicts: moreutils", deleted this line. Source: http://superuser.com/a/815371/99136. Seems to work now, but I fear an update of the "parallel" package will break things again. – krlmlr Sep 08 '16 at 14:26
  • 1
    Nope: `apt-get install` warns that `parallel` package won't be upgraded, but `apt-cache policy` doesn't show different versions, and even `apt-get dist-upgrade` won't touch the `parallel` package. So, upgrading `parallel` seems to be a process that has to be initiated consciously. Fine with me. – krlmlr Sep 08 '16 at 14:31
  • @krlmlr, that's a new one on me... BTW, if you'd be so kind as to post the above trick here [Set apt-get options to tolerate harmless 'dpkg --force-conflicts' kludge?](http://unix.stackexchange.com/questions/281302/set-apt-get-options-to-tolerate-harmless-dpkg-force-conflicts-kludge), I'd upvote it. – agc Sep 09 '16 at 00:30
10

This conflict is solved in Ubuntu 17.04 and Debian Stretch.

If you install parallel & moreutils you get the GNU parallel as /usr/bin/parallel and moreutil's parallel as /usr/bin/parallel.moreutils. If you only install moreutils, it provides /usr/bin/parallel.

If you're using an older version of Ubuntu or Debian, you could download and install the .deb's from a newer version: they install & work just fine.

Bryan Larsen
  • 213
  • 2
  • 6
1

GNU parallels is just a perl script, so you could just copy it somewhere useful (e.g. /usr/local/bin/gnu-parallel).

(Just check the perl dependencies).

David Goodwin
  • 271
  • 2
  • 5
1

I guess, the easiest route would be to install one of the packages normally (e.g. parallel) and just extract another one to the custom path:

$ sudo apt-get install libio-pty-perl libipc-run-perl
$ sudo apt-get download moreutils
$ dpkg -x moreutils_0.54-1_amd64.deb /tmp/moreutils
$ cd /tmp/moreutils/usr/bin/
agc
  • 627
  • 5
  • 16
barti_ddu
  • 1,401
  • 12
  • 11