Build CentOS 5 generic RPM on CentOS 6

03 Aug 2015 in TIL

I've been trying to build a generic RPM (PHP code only, nothing linked) that installs on CentOS 5 and CentOS 6. We used to do this on CentOS 5, but when we moved our build box to CentOS6 we started to see errors that looked the the following:

bash
rpmlib(FileDigests) is needed by my-example-project-1.2.3-1.noarch
rpmlib(PayloadIsXz) is needed by my-example-project-1.2.3-1.noarch

This is because the RPM was built on CentOS 6, which uses a new compression algorithm that CentOS 5 doesn't know about.

To make your RPM CentOS 5 and CentOS 6 compatible, add the following to your spec file below the Requires section.

bash
%define _source_filedigest_algorithm md5
%define _binary_filedigest_algorithm md5
%define _source_payload w0.gzdio
%define _binary_payload w0.gzdio

This makes your RPM CentOS 5 compatible