http://fedoraproject.org/wiki/How_to_create_an_RPM_package
# rpm --showrc|grep _topdir
-14: _builddir %{_topdir}/BUILD
-14: _buildrootdir %{_topdir}/BUILDROOT
-14: _rpmdir %{_topdir}/RPMS
-14: _sourcedir %{_topdir}/SOURCES
-14: _specdir %{_topdir}/SPECS
-14: _srcrpmdir %{_topdir}/SRPMS
-14: _topdir %{getenv:HOME}/rpmbuild
# echo %_topdir $HOME/rpmbuild > ~/.rpmmacros
# cat ~/.rpmmacros
%_topdir /root/rpmbuild
# mkdir -p ~/rpmbuild/{BUILD,RPMS/x86_64,S{OURCE,PEC,RPM}S}
# tree /root/rpmbuild/
/root/rpmbuild/
├── BUILD
│ └── monitor-agent-1.0
├── BUILDROOT
├── RPMS
│ └── x86_64
├── SOURCES
│ ├── monitor-agent-1.0
│ └── monitor-agent-1.0.tar.gz
├── SPECS
│ └── monitor-agent.spec
└── SRPMS
# monitor-agent.spec
Name: monitor-agent
Version: 1.0
Release: 1%{?dist}
Summary: monitor-agent
Group: Applications/System
License: GPL
Source0: %{name}-%{version}.tar.gz
BuildRoot: %{_builddir}/%{name}-%{version}
Requires: nagios-plugins,nrpe,net-snmp-perl,perl-XML-LibXML,perl-JSON,perl-libwww-perl,perl-XML-XPath,perl-Net-Telnet,perl-Net-DNS,perl-DBI,perl-DBD-MySQL,perl-DBD-Pg,perl-Email-Send,
%description
%prep
%setup -q
%build
%install
rm -rf %{buildroot}
mkdir -p %{buildroot}/usr/lib64/nagios/plugins
mkdir -p %{buildroot}/etc/nagios
mkdir -p %{buildroot}/etc/nrpe.d
cp -rfp centreon-plugins %{buildroot}/usr/lib64/nagios/plugins
install -m 0755 check_live_status.py %{buildroot}/usr/lib64/nagios/plugins
install -m 0755 check_live_transfer.py %{buildroot}/usr/lib64/nagios/plugins
install -m 0755 check_nfsmounts.pl %{buildroot}/usr/lib64/nagios/plugins
install -m 0644 cfg/base.cfg %{buildroot}/etc/nrpe.d
install -m 0644 cfg/app.cfg %{buildroot}/etc/nrpe.d
install -m 0644 cfg/nrpe.cfg %{buildroot}/etc/nagios
%clean
rm -rf %{buildroot}
%files
%defattr(-,root,root)
/usr/lib64/nagios/plugins/centreon-plugins
/usr/lib64/nagios/plugins/check_live_status.py
/usr/lib64/nagios/plugins/check_live_transfer.py
/usr/lib64/nagios/plugins/check_nfsmounts.pl
/etc/nagios/nrpe.cfg
/etc/nrpe.d/base.cfg
/etc/nrpe.d/app.cfg
%pre
[ -e '/etc/yum.repos.d/rpmforge.repo' ] && mv -f /etc/yum.repos.d/rpmforge.repo /etc/yum.repos.d/rpmforge.repo.rpmsave
yum clean all
%post
%preun
%postun
rm -rf /usr/lib64/nagios/plugins/centreon-plugins
rm -rf /usr/lib64/nagios/plugins/{check_live_status.py,check_live_transfer.py,check_nfsmounts.pl}
rm -rf /etc/nrpe.d/{base.cfg,app.cfg}
/etc/init.d/nrpe restart
%changelog
rpmbulid -bb monitor-agent.spec