Quickly building an rpm package in CentOS with Checkinstall
To build an RPM package from an application’s source code you need Checkinstall.
It’s the simplest and fastest way to build RPM packages. The resulting package can be installed on other servers without recompiling it every time.
Install the rpm package handlers:
yum install -y rpm-build rpmdevtools
After installing, run the following command. It creates the rpm package dependencies:
rpmdev-setuptree
Unfortunately Checkinstall isn’t available in the CentOS repos. A full list of rpm packages is available on the following page:
http://rpm.pbone.net/index.php3?stat=3&search=checkinstall&srodzaj=3
You need to download and install it:
wget -no-check-certificate https://filebox.ece.vt.edu/~mclint/puppet/files/checkinstall-1.6.2-3.el6.1.x86_64.rpm
rpm -i checkinstall-1.6.2-3.el6.1.x86_64.rpm
I used to use a different link, and when it stopped working I nearly panicked. Anyway, found another one, downloaded it and hosted it on my own server:
wget /wp-content/uploads/2016/04/01/checkinstall-1.6.2-3.el6.1.x86_64.rpm
After that checkinstall is ready to use. Use it instead of make install when building packages.
The following command won’t install the application, it’ll just prepare a package ready for install and show you where it ended up:
checkinstall -install=no
For example:
**********************************************************************
Done. The new package has been saved to
/root/rpmbuild/RPMS/x86_64/httpd-2.2.31-1.x86_64.rpm
You can install it in your system anytime using:
rpm -i httpd-2.2.31-1.x86_64.rpm
**********************************************************************
You can install the resulting package with:
rpm -i /root/rpmbuild/RPMS/x86_64/httpd-2.2.31-1.x86_64.rpm
If you built the package to update one already installed on the system, use:
rpm -U /root/rpmbuild/RPMS/x86_64/httpd-2.2.31-1.x86_64.rpm