%define _prefix /usr


Summary: The Open Vulnerability Assessment (OpenVAS) Server
Name:    openvas-server
Version: 2.0.3
Release: 1
Source0: %{name}-%{version}.tar.gz
Source1: openvasd.init
License: GNU GPLv2
URL: http://www.openvas.org
Group: System Environment/Libraries
Vendor: OpenVAS Development Team, http://www.openvas.org
Packager: Scott R. Shinn <scott@atomicrocketturtle.com>
BuildRoot: %{_builddir}/%{name}-root
Prefix: %{_prefix}
BuildRequires: openvas-libnasl-devel
AutoReqProv: no
AutoReq: 0

#ART
BuildRequires: openvas-libnasl >= 2.0.2, openvas-libnasl-devel >= 2.0.2
BuildRequires: openvas-libraries  >= 2.0.4, openvas-libraries-devel >= 2.0.4
BuildRequires: flex 
BuildRequires: automake  libtool 

%if 0%{?el4}
BuildRequires:  evolution28-glib2-devel evolution28-glib2
Requires: evolution28-glib2
%else
BuildRequires: glib2 >= 2.6.0, glib2-devel >= 2.6.0
%endif


Requires: openvas-libnasl  openvas-libraries  >= %{version}
Requires: openvas-plugins
Requires: gpgme 
Requires: strobe nmap pnscan openldap-clients ovaldi amap net-snmp-utils
Requires: hydra ike-scan nikto
# TODO- PortBunny is a kernel module port scanner. Lots of work.
# Requires: PortBunny


BuildRequires: %{_includedir}/pcap.h
BuildRequires: libgcrypt-devel gnutls-devel gpgme gpgme-devel
 

%package devel
Summary: Development files for openvas-server
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}

%description
openvas-server is the acutal server component
of the Network Vulnerabilty Scanner suite OpenVAS.

%description devel
This package contains the development files (mainly C header files)
for openvas-server.

%prep
%setup -b 0

%build

%if 0%{?el4}
  %ifarch x86_64
    export GLIB_LIBS=/usr/evolution28/lib64/libglib-2.0.so
    export PKG_CONFIG_PATH=/usr/evolution28/lib64/pkgconfig:/usr/lib64/pkgconfig/
  %else
    export GLIB_LIBS=/usr/evolution28/lib/libglib-2.0.so
    export PKG_CONFIG_PATH=/usr/evolution28/lib/pkgconfig:/usr/lib/pkgconfig/
  %endif
%endif


%{__aclocal}
%{__libtoolize} --force
#sh ./ltmain.sh
%configure \
	--prefix=%{_prefix} \
	--enable-release 
# need deps for this
#	--enable-tcpwrappers

%{__make}  %{?_smp_mflags}


%install
%makeinstall

%{__mkdir_p} %{buildroot}/%{_sysconfdir}/init.d/
%{__install} -m0755 %{SOURCE1}  %{buildroot}/%{_sysconfdir}/init.d/openvasd

%post 

/sbin/ldconfig >/dev/null 2>&1

/sbin/chkconfig --add openvasd
/sbin/chkconfig openvasd on

# Generate cert
if [ ! -f  /var/lib/openvas/CA/servercert.pem ] ; then
  /usr/sbin/openvas-mkcert -q >/dev/null 2>&1
fi


%preun
service openvasd stop > /dev/null 2>&1

%postun 
/sbin/ldconfig >/dev/null 2>&1


%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root,-)
%doc CHANGES COPYING
%{_mandir}/man?/*
%{_bindir}/openvas-mkrand
%{_bindir}/openvas-mkcert-client
%{_sbindir}/*
%{_localstatedir}/lib/openvas/*
%{_localstatedir}/log/openvas
# Huh?
#%{_sharedstatedir}/openvas/*
%{_sysconfdir}/openvas/gnupg
%{_sysconfdir}/init.d/openvasd

%files devel
%defattr(-,root,root,-)
%{_includedir}/openvas/*
%{_bindir}/openvasd-config

%changelog
* Wed Aug 19 2009 Scott R. Shinn <scott@atomicrocketturtle.com> - 2.0.3-1
- update to 2.0.3

* Wed Jun 3 2009 Scott R. Shinn <scott@atomicrocketturtle.com> - 2.0.2-1
- update to 2.0.2

* Thu Feb 26 2009 Scott R. Shinn <scott@atomicrocketturtle.com> - 2.0.1-1
- update to 2.0.1 

* Tue Dec 30 2008 Scott R. Shinn <scott@atomicrocketturtle.com> - 2.0.0-2
- Added init scripts and post install routine
- Bugfix #xxx, resolved libopenvas.2 linking issue

* Mon Dec 22 2008 Scott R. Shinn <scott@atomicrocketturtle.com>
- Update to 2.0.0 Final

* Fri Dec 12 2008 Scott R. Shinn <scott@atomicrocketturtle.com>
- Update to 2.0.0.rc1

* Mon Nov 17 2008 Scott R. Shinn <scott@atomicrocketturtle.com>
- Added Requires for port scanners, ovaldi, and ldapclient
- Added Requires for hydra
- Update to beta2

* Fri Nov 7 2008 Scott R. Shinn <scott@atomicrocketturtle.com>
- Update to 2.0.0.beta1
- Import into ART

* Fri Apr 18 2008 Jan-Oliver Wagner <jan-oliver.wagner@intevation.de>
  - Adapated for Fedora 8 (naming)
  - %post and %postrun changed to apply ldconfig directly instead of using
    a (SUSE specific?) scriplet.
* Wed Apr 16 2008 Jan-Oliver Wagner <jan-oliver.wagner@intevation.de>
  Initial OpenSUSE 10.2 spec file, tested for i586