===== Build a RPM package without compiling =====
This is an example with NMON binary file the will be package into an RPM
==== Prepare compilation structure ====
If you still have a binary file and just want to packaged it into a RPM package
[root@lrpmproxy ~]# for i in BUILD BUILDROOT RPMS SOURCES SPECS SRPMS
do
mkdir -p rpmbuild/$i
done
[root@lrpmproxy rpmbuild]# ls -l /root/rpmbuild/
total 24
drwxr-xr-x 3 root root 4096 Oct 28 11:11 BUILD
drwxr-xr-x 3 root root 4096 Oct 28 11:33 BUILDROOT
drwxr-xr-x 3 root root 4096 Oct 28 11:15 RPMS
drwxr-xr-x 2 root root 4096 Oct 28 11:08 SOURCES
drwxr-xr-x 2 root root 4096 Oct 28 11:32 SPECS
drwxr-xr-x 2 root root 4096 Oct 28 11:33 SRPMS
==== Prepare your spec file ====
Prepare your .spec file
[root@lrpmproxy rpmbuild]# cat SPECS/nmon.spec
Summary: Performance analysis tool
Name: nmon
Version: 14g
#Release: 1%{?dist}
Release: noarch
License: GPLv3
Group: Applications/System
URL: http://nmon.sourceforge.net/
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
ExclusiveArch: %{ix86} x86_64 ppc ppc64
BuildRequires: /usr/include/linux/version.h
%description
nmon is designed for performance specialists to use for monitoring and analyzing performance data.
%files
/usr/bin/nmon_x86_64_centos6
%post
if [ -e /usr/bin/nmon ]
then
rm -f /usr/bin/nmon
fi
ln -s /usr/bin/nmon_x86_64_centos6 /usr/bin/nmon
%preun
if [ -e /usr/bin/nmon ]
then
rm -f /usr/bin/nmon
fi
%changelog
* Mon Oct 17 2011 Dag Wieers - 14g-1
- Updated to release 14g.
* Wed Apr 13 2011 Dag Wieers - 14f-1
- Updated to release 14f. (Simon Matter)
* Thu Nov 05 2009 Dag Wieers - 12d-1
- Updated to release 12d.
* Sat Aug 18 2007 Dag Wieers - 11f-1
- Updated to release 11f.
* Tue Feb 06 2007 Dag Wieers - 11d-2
- Added nmon-script cronjob to do data collection.
* Wed Jan 31 2007 Dag Wieers - 11d-1
- Initial package. (using DAR)
Source0: http://dl.sf.net/sourceforge/nmon/lmon%{version}.c
Source1: http://dl.sf.net/sourceforge/nmon/makefile
Source2: http://dl.sf.net/sourceforge/nmon/Documentation.txt
==== Copy the binary package to the right place ====
Download the binary file from http://nmon.sourceforge.net/
Copy the binary package to the related path starting /root/rpmbuild/BUILDROOT/nmon-14g-noarch.x86_64/
If you don't know where to put your package, just start the package creation, and it will ask you for the missing package:
[root@lrpmproxy rpmbuild]# rpmbuild -ba SPECS/nmon.spec
Processing files: nmon-14g-noarch.x86_64
error: File not found: /root/rpmbuild/BUILDROOT/nmon-14g-noarch.x86_64/usr/bin/nmon_x86_64_centos6
Then Just copy the file nmon_x86_64_centos6 to /root/rpmbuild/BUILDROOT/nmon-14g-noarch.x86_64/usr/bin/nmon_x86_64_centos6
[root@lrpmproxy rpmbuild]# mkdir -p /root/rpmbuild/BUILDROOT/nmon-14g-noarch.x86_64/usr/bin
[root@lrpmproxy rpmbuild]# cp ~/nmon_x86_64_centos6 /root/rpmbuild/BUILDROOT/nmon-14g-noarch.x86_64/usr/bin/
==== Build RPM package ====
Now build the package:
[root@lrpmproxy rpmbuild]# rpmbuild -ba SPECS/nmon.spec
Processing files: nmon-14g-noarch.x86_64
Provides: nmon = 14g-noarch nmon(x86-64) = 14g-noarch
Requires(interp): /bin/sh /bin/sh
Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Requires(post): /bin/sh
Requires(preun): /bin/sh
Requires: libc.so.6()(64bit) libc.so.6(GLIBC_2.2.5)(64bit) libc.so.6(GLIBC_2.3)(64bit) libc.so.6(GLIBC_2.7)(64bit) libncursesw.so.5()(64bit) libtinfo.so.5()(64bit) rtld(GNU_HASH)
Checking for unpackaged file(s): /usr/lib/rpm/check-files /root/rpmbuild/BUILDROOT/nmon-14g-noarch.x86_64
Wrote: /root/rpmbuild/SRPMS/nmon-14g-noarch.src.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/nmon-14g-noarch.x86_64.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.fp0x2S
+ umask 022
+ cd /root/rpmbuild/BUILD
+ /usr/bin/rm -rf /root/rpmbuild/BUILDROOT/nmon-14g-noarch.x86_64
+ exit 0
The RPM package is located in /root/rpmbuild/RPMS/x86_64/nmon-14g-noarch.x86_64.rpm
==== Check the package ====
Information about the RPM package:
[root@lrpmproxy rpmbuild]# rpm -qpi /root/rpmbuild/RPMS/x86_64/nmon-14g-noarch.x86_64.rpm
Name : nmon
Version : 14g
Release : noarch
Architecture: x86_64
Install Date: (not installed)
Group : Applications/System
Size : 222460
License : GPLv3
Signature : (none)
Source RPM : nmon-14g-noarch.src.rpm
Build Date : Tue 28 Oct 2014 12:54:14 PM CET
Build Host : lrpmproxy
Relocations : (not relocatable)
URL : http://nmon.sourceforge.net/
Summary : Performance analysis tool
Description :
nmon is designed for performance specialists to use for monitoring and analyzing performance data.
RPM package content:
[root@lrpmproxy rpmbuild]# rpm -qpl /root/rpmbuild/RPMS/x86_64/nmon-14g-noarch.x86_64.rpm
/usr/bin/nmon_x86_64_centos6
RPM package scripts:
[root@lrpmproxy rpmbuild]# rpm --scripts -qp /root/rpmbuild/RPMS/x86_64/nmon-14g-noarch.x86_64.rpm
postinstall scriptlet (using /bin/sh):
if [ -e /usr/bin/nmon ]
then
rm -f /usr/bin/nmon
fi
ln -s /usr/bin/nmon_x86_64_centos6 /usr/bin/nmon
preuninstall scriptlet (using /bin/sh):
if [ -e /usr/bin/nmon ]
then
rm -f /usr/bin/nmon
fi
==== Deploy the rpm package ====
RPM installation:
[root@lrpmproxy rpmbuild]# rpm -Uhv /root/rpmbuild/RPMS/x86_64/nmon-14g-noarch.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:nmon-14g-noarch ################################# [100%]
==== To extract RPM files from a package ====
[root@lnx01]/export/softs/zabbix/zabbix_agent_5.0.17-1# rpm2cpio zabbix-agent-5.0.17-1.aix7.2.ppc.rpm | cpio -idmv
./etc/rc.d/init.d/zabbix-agent
./etc/rc.d/rc2.d/Kzabbix-agent
./etc/rc.d/rc2.d/Szabbix-agent
./etc/zabbix/zabbix_agentd.conf
./etc/zabbix/zabbix_agentd.d
...