RHCE Series: Build a simple RPM that packages a single file.

Alright, so this is a little more in depth than creating a simple package, but I figured I could full-fill the Red Hat requirement and create a little bit of documentation on how to create the rpm for OpenNHRP in one swoop. :)

[[email protected] ~]# yum install rpmdevtools
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.mirror.lstn.net
 * extras: centos.mirror.lstn.net
 * updates: centos.mirror.lstn.net

...

Installed:
  rpmdevtools.noarch 0:7.5-1.el6                                                                                            
Complete!

[[email protected] ~]# adduser rpmuser
[[email protected] ~]# su - rpmuser
[[email protected] ~]$ rpmdev-setuptree 
[[email protected] ~]$ ls
rpmbuild
[[email protected] ~]$ ls rpmbuild/
BUILD  RPMS  SOURCES  SPECS  SRPMS
[[email protected] ~]$ cd rpmbuild/SOURCES/
[[email protected] SOURCES]$ ls
opennhrp-0.13.1.tar.bz2

[[email protected] ~]# yum -y install c-ares-devel
[[email protected] ~]# yum -y groupinstall "Development Tools"

[[email protected] rpmbuild]$ cd SPECS/
[[email protected] SPECS]$ 
[[email protected] SPECS]$ vim opennhrp.spec
[[email protected] SPECS]$ cat opennhrp.spec 
Name:  opennhrp
Version: 0.13.1
Release: 1%{?dist}
Summary: OpenNHRP implements NBMA Next Hop Resolution Protocol (as defined in RFC 2332). It makes it possible to create dynamic multipoint VPN Linux router using NHRP, GRE and IPsec. It aims to be Cisco DMVPN compatible.

#Group:  
License: GNU GPL
URL:  http://sourceforge.net/projects/opennhrp
Source0: ~/rpmbuild/SOURCES/opennhrp-0.13.1.tar.bz2 
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)

#BuildRequires: 
#Requires: 

%description


%prep
%setup -q
touch ~/rpmbuild/BUILD/%{name}-%{version}/configure && chmod +x ~/rpmbuild/BUILD/%{name}-%{version}/configure 

%build
%configure
make %{?_smp_mflags}

%install
rm -rf %{buildroot}
make install DESTDIR=%{buildroot}


%clean
rm -rf %{buildroot}


%files
%defattr(-,root,root,-)
%doc
%config(noreplace) /etc/opennhrp/*
/usr/sbin/opennhrp
/usr/sbin/opennhrpctl
/usr/share/doc/opennhrp/README
/usr/share/man/man5/*
/usr/share/man/man8/*

%changelog


[[email protected] SPECS]$ rpmbuild -bb opennhrp.spec

[[email protected] SPECS]$ cd ../RPMS/
[[email protected] RPMS]$ ls
x86_64
[[email protected] RPMS]$ cd x86_64/
[[email protected] x86_64]$ ls
opennhrp-0.13.1-1.el6.x86_64.rpm  opennhrp-debuginfo-0.13.1-1.el6.x86_64.rpm