CentOS5/RHEL5 fix for ImageMagick “cpio: MD5 sum error” and “cpio: read”

Back on CentOS 5 for a customer I stumbled across a little problem while installing RMagick for Ruby. Said interface between Ruby and the Image Magick tools requires Image Magick in a version greater then 6.3.5 to be installed on one’s system. However, CentOS 5 and RHEL 5 only provide version 6.2.8. Even more unfortunate is that while there are RPMs to be found on ImageMagick.org, they’re all for Fedora. So when trying to install the binary .rpm file, all you’ll get is something like this:

[root@testsys rpms]# rpm -Uvh ImageMagick-6.5.5-6.i386.rpm 
error: Failed dependencies:
	libHalf.so.4 is needed by ImageMagick-6.5.5-6.i386
	libIex.so.4 is needed by ImageMagick-6.5.5-6.i386
	libIlmImf.so.4 is needed by ImageMagick-6.5.5-6.i386
	libImath.so.4 is needed by ImageMagick-6.5.5-6.i386
	libcdt.so.4 is needed by ImageMagick-6.5.5-6.i386
	libfftw3.so.3 is needed by ImageMagick-6.5.5-6.i386
	libgraph.so.4 is needed by ImageMagick-6.5.5-6.i386
	libgvc.so.5 is needed by ImageMagick-6.5.5-6.i386

No problem you might say. Just grab the source rpm and rebuild from there. Alas, this will lead to another problem:

[root@testsys srcrpm]# rpm -Uvh ImageMagick-6.5.5-6.src.rpm 
   1:ImageMagick
warning: user cristy does not exist - using root
warning: group cristy does not exist - using root
########################################### [100%]
error: unpacking of archive failed on file 
/usr/src/redhat/SOURCES/ImageMagick-6.5.5-6.tar.bz2;
4aa10a8f: cpio: read

With older archives you’ll get a similar message:

[root@testsys srcrpm]# rpm -Uvh ImageMagick-6.5.5-5.src.rpm 
   1:ImageMagick
warning: user cristy does not exist - using root
warning: group cristy does not exist - using root
########################################### [100%]
error: unpacking of archive failed on file 
/usr/src/redhat/SOURCES/ImageMagick-6.5.5-5.tar.bz2;
4aa10b19: cpio: MD5 sum mismatch

The reason is that Fedora uses newer RPM utilities than the ones found on CentOS 5 / RHEL 5. This is the reason for the broken MD5 sums. Also, they recently switched from providing .tar.bz2 packed archives to .lzma packed archives which RPM on CentOS 5 / RHEL 5 doen’t know anything about.

Google wasn’t of any help to solve this particular problem without installing everything from source.

But fear not, there’s an easy solution. Just read on.

{openx:6}

Instead of trying to install all the prerequisites for the Fedora binary package, it’s a lot easier to build the ImageMagick rpm packes from the original sources, using a modfied .spec file from Fedora. To be able to do just that, there’s one small additional step: you’ve got to build the rpm packages for JasPer, too. But first, we need a working build environment. This is easily prepared:

yum groupinstall "Development Tools"
for DIR in (BUILD RPMS SOURCES SPECS SRPMS); do mkdir -p /usr/src/redhat/${DIR}; done

Next, get the current version of JasPer and install it:

wget http://www.ece.uvic.ca/~mdadams/jasper/software/jasper-1.900.1.zip
unzip jasper-1.900.1.zip
tar czf /usr/src/redhat/SOURCES/jasper-1.900.1.tar.bz2 jasper-1.900.1
cd jasper-1.900.1
rpmbuild -ba jasper.spec

This set of commands will repack the Zip file with the JasPer sources into a .tar.bz2 archive which is already created in the right spot for

rpmbuild

to find it. After that’s done, the rpmbuild tool will create the JasPer packages. Those need to be installed:

rpm -Uvh /usr/src/redhat/RPMS/i386/jasper*

{openx:6}

Ok, we’re done with the prerequisites so we can go and install ImageMagick. Grab the latest source and copy to the location expected by the RPM tools:

wget http://ftp.nluug.nl/ImageMagick/ImageMagick-6.5.5-6.tar.bz2
mv ImageMagick-6.5.5-6.tar.bz2 /usr/src/redhat/SOURCES

You’ll also need the modified ImageMagick.spec file:

wget http://whocares.de/wp-content/uploads/2009/09/ImageMagick-whocares.spec
rpmbuild -ba ImageMagick-whocares.spec

This will most likely produce a list of missing dependencies on the first run. Just install what’s needed using

yum install <package name as given by rpmbuild>

and rerun the rpmbuild command. Finally install ImageMagick using

rpm -Uvh /usr/src/redhat/RPMS/i386/ImageMagick*

. You’re done.

As always: Works for me ymmv.

The Fast Track

If you’re lazy and you trust me, you may download my source rpm packages and install from there:

jasper-1.900.1-1.src.rpm
ImageMagick-6.5.5.6-3.src.rpm

{openx:6}