Name:           rancid
Version:        2.3.1
Release:        3
Summary:        Really Awesome (more than) Cisco Differ

Group:          Monitoring
License:        non-free
URL:            http://www.shrubbery.net/rancid/
Source0:        ftp://ftp.shrubbery.net/pub/rancid/rancid-%{version}.tar.gz
Patch0:         rancid-2.3.1-nolg.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

Requires:       cvs expect >= 5.40

%description
Rancid is a "Really Awesome New Cisco confIg Differ" developed to
maintain CVS controlled copies of router configs. Rancid is not limited
to Cisco devices. It currently supports Cisco routers, Juniper routers,
Catalyst switches, Foundry switches, Redback NASs, ADC EZT3 muxes, MRTd
(and thus likely IRRd), Alteon switches, and HP procurve switches and a
host of others.

%prep 
%setup -q
# Do not install the looking glas stuff as it introduces a lot of dependencies.
# FIXME: a rancid-lg rpm would be a better solution.
%patch0 -p0 -b .nolg

%build
%configure --localstatedir=%{_localstatedir}/rancid \
    --disable-mk-localstatedir \
    --disable-conf-install
make


%install
rm -rf $RPM_BUILD_ROOT
make install-exec DESTDIR=$RPM_BUILD_ROOT
pushd man
make install DESTDIR=$RPM_BUILD_ROOT
popd
# Workaround for the stupid rpmbuild to NOT search for dependencies in the
# documentation. We need to do it here as %doc ignores %attr.
find share -type f -print0 | xargs -0 chmod a-x
mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/rancid


%pre
if [ $1 -eq 1 ]; then
    useradd -M -r -d %{_localstatedir}/rancid -c "RANCID user" rancid
fi


%postun
if [ $1 -eq 0 ]; then
    # It's a matter of taste if we should remove the user on uninstall or not
    userdel rancid
fi


%clean
rm -rf $RPM_BUILD_ROOT


%files
%defattr(-,root,root,-)
%doc BUGS CHANGES COPYING FAQ README UPGRADING cloginrc.sample
%doc etc/rancid.conf.sample share/cisco-load.exp share/cisco-reload.exp
%doc share/downreport share/getipacctg share/rtrfilter
%{_bindir}
%{_mandir}/man1
%{_mandir}/man5
%dir %attr(770,rancid,rancid) %{_localstatedir}/rancid


%changelog
* Wed Nov 16 2005 Michael Stefaniuc <mstefani@redhat.com> 2.3.1-3
- Use /var/rancid as localstatedir
- Create the rancid user on install and remove it on uninstall
- Use %doc correctly

* Wed Nov 02 2005 Michael Stefaniuc <mstefani@redhat.com> 2.3.1-2
- Original spec file by Dan Pfleger.
- Add a changelog.
- Make the formating of the spec file adhere to the Fedora Extras Packaging
  guidelines.
- New %description based on the README and the website.
- Add cvs Requires.
- Changed Group
- Use macros in the files section. Simplify it.
- Do not install the looking glass cgi's. Those make rpm pull in more perl
  module dependencies.