Many times we encounter situations where we want to replicate one package installation on a different machine but the actual RPM file no longer available. This happens mainly when you use yum to install packages. When you try to install same package on a different machine after few months, you might not get the same version of the software from yum repos. In this article we will explain how to recreate/rebuild an RPM from installed files using rpmrebuild
Recreate/rebuild a RPM from installed files using RPMREBUILD
Rpmrebuild is a 3rd party script you can use to do a re-packaging of an already installed RPM.
excerpts from the official page
“rpmrebuild is a tool to build an RPM file from a package that has already been installed in a basic use, rpmrebuild use does not require any rpm building knowledge. (On debian, the equivalent product is dpkg-repack).”
How to install rpmrebuild on centos ?
On a Centos machine you can install rpmrebuild using yum
yum install rpmrebuild
Package Arch Version Repository Size
rpmrebuild noarch 2.11–3.el6 epel 76 k
Install 1 Package(s)
Total download size: 76 k
Installed size: 181 k
Is this ok [y/N]: y
rpmrebuild–2.11–3.el6.noarch.rpm | 76 kB 00:00
Running Transaction Test
Transaction Test Succeeded
Installing : rpmrebuild–2.11–3.el6.noarch 1/1
Verifying : rpmrebuild–2.11–3.el6.noarch 1/1
We have installed rpmrebuild package successfully
Creating first RPM file using rpmrebuild
First find the rpm package which we need to rebuild
[firstname.lastname@example.org ~]# rpm -qa |grep nginx
[email@example.com ~]# rpmrebuild nginx-1.10.2-1.el6.x86_64
/usr/lib/rpmrebuild/rpmrebuild.sh: WARNING: some files have been modified:
S.5….T. c /etc/nginx/conf.d/default.conf
S.5….T. c /etc/nginx/nginx.conf
Do you want to continue ? (y/N) y
Do you want to change release number ? (y/N) N
From the above example, you can see that rpmrebuild created a new rpm file and stored at “/root/rpmbuild/RPMS/x86_64/nginx-1.10.2-1.el6.x86_64.rpm” .
We can copy this to any other machine and use it to install same package on that machine.
You can find more details on their official page