DEV Community

Maxime Soulé
Maxime Soulé

Posted on

Install ImageMagick6 *and* ImageMagick7 on FreeBSD

On FreeBSD, ImageMagick6 and ImageMagick7 packages cannot be installed at the same time as they have several files in common.

It becomes a problem when some packages depend on ImageMagick6 (as inkscape for example) and some others on ImageMagick7 (as emacs for example).

To circumvent this problem, we can "patch" the ImageMagick6 package to delete the files installed by ImageMagick7.

So ImageMagick7 is installed:

$ pkg info ImageMagick\*                              
ImageMagick7-7.0.10.6

First download the ImageMagick6 package:

$ pkg=$(pkg rquery %q/%n-%v ImageMagick6)
$ fetch https://pkg.freebsd.org/${pkg%%/*}/latest/All/${pkg#*/}.txz

Then download the "package-patcher" script:

$ fetch https://gist.githubusercontent.com/maxatome/dcd48de511f087c10f02a59405f134b6/raw/9e9843d87dace00e506ea848c69cf29ad09dbf6a/patch-ImageMagick6.pl

Do not forget to look at its content before executing it!

  • L27 it creates a temporary directory that it automatically cleaned up at end;
  • L29-31 it extracts the package it it
  • L33-34 it reads the +MANIFEST to get the list of package files;
  • L36-57 it deletes unneeded files from +MANIFEST and from disk
  • L59-63 it rewrites the +MANIFEST
  • L65-75 it creates a new package adding -libonly to the original package name.

Then (no need to be root at this step), patch the package:

$ perl patch-ImageMagick6.pl ${pkg#*/}.txz
Extracting /usr/home/max/tmp/ImageMagick6-6.9.11.6,1.txz
tar: Removing leading '/' from member names
Patching
Creating new /usr/home/max/tmp/ImageMagick6-libonly-6.9.11.6,1.txz
/usr/home/max/tmp/ImageMagick6-libonly-6.9.11.6,1.txz produced.

Just install the produced package using pkg install as root:

# pkg install ImageMagick6-libonly-6.9.11.6,1.txz
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
Checking integrity... done (0 conflicting)
The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
    ImageMagick6: 6.9.11.6,1

Number of packages to be installed: 1

The process will require 27 MiB more space.

Proceed with this action? [y/N]: y
[1/1] Installing ImageMagick6-6.9.11.6,1...
Extracting ImageMagick6-6.9.11.6,1: 100%

inkscape package can now be installed without any conflict with emacs, as both versions of ImageMagick are installed:

> pkg info ImageMagick\*                          
ImageMagick6-6.9.11.6,1
ImageMagick7-7.0.10.6

It is a good idea to lock the ImageMagick6 package to avoid that the next pkg upgrade raise a conflict:

# pkg lock ImageMagick6-6.9.11.6,1 
ImageMagick6-6.9.11.6,1: lock this package? [y/N]: y
Locking ImageMagick6-6.9.11.6,1

Top comments (0)