File openvas-scanner.spec of Package openvas-scanner

#
# spec file for package openvas-scanner
#
# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

%if 0%{?suse_version} > 1230
%bcond_without systemd
%else
%bcond_with    systemd
%endif

Name:           openvas-scanner
Version:        5.0.9
Release:        0
License:        GPL-2.0
Group:          Productivity/Networking/Security
URL:            http://www.openvas.org
Source0:        %{name}-%{version}.tar.gz
Source1:        openvassd.logrotate
Source2:        debian.openvas-scanner.default
Source3:        openvassd.init.suse
Source4:        openvassd.init.fedora
Source5:        openvassd.init.mandriva
Source6:        openvas-scanner.service
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%if 0%{?mandriva_version}
BuildRequires:  pinentry-gtk2
%endif

%if 0%{?suse_version}
PreReq:         %insserv_prereq
PreReq:         %fillup_prereq
%if 0%{?suse_version} > 1220
BuildRequires:  doxygen
%endif
%endif
%if %{with systemd}
BuildRequires:  pkgconfig(systemd)
%systemd_requires
%endif

BuildRequires:  cmake
BuildRequires:  glib2-devel
BuildRequires:  libopenvas-devel >= 8.0
BuildRequires:  libgcrypt-devel
BuildRequires:  pkgconfig
Requires:       logrotate
Requires:       openssl
Requires:       rsync
Summary:        The Scanner Module for OpenVAS

%description
This is the scanner module for the Open Vulnerability Assessment System (OpenVAS).

%prep
%setup -q

%build
%if 0%{?mandriva_version}
%serverbuild
%endif
%cmake -DLOCALSTATEDIR=%{_localstatedir}
%__make %{?_smp_mflags}

%install
%cmake_install

%__install -Dm 0644 %{_sourcedir}/openvassd.logrotate %{buildroot}%{_sysconfdir}/logrotate.d/openvas-scanner

%if 0%{?suse_version}
%if %{with systemd}
install -D -m 644 %{S:6}  %{buildroot}%{_unitdir}/openvas-scanner.service
ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rcopenvas-scanner 
%else
install -Dm 0755 %{_sourcedir}/openvassd.init.suse %{buildroot}%{_initrddir}/openvas-scanner
ln -sf %{_initrddir}/openvas-scanner %{buildroot}%{_sbindir}/rcopenvas-scanner
%endif
install -Dm 0644 %{_sourcedir}/debian.openvas-scanner.default %{buildroot}%{_var}/adm/fillup-templates/sysconfig.openvas-scanner
ln -sf %{_mandir}/man8/openvas-mkcert.8.gz %{buildroot}%{_mandir}/man8/openvas-mkcert-client.8.gz
%endif

%if 0%{?fedora_version} || 0%{?scientificlinux_version} || 0%{?centos_version}
%__install -Dm 0755 %{_sourcedir}/openvassd.init.fedora %{buildroot}%{_initrddir}/openvas-scanner
%__install -Dm 0644 %{_sourcedir}/debian.openvas-scanner.default %{buildroot}%{_sysconfdir}/sysconfig/openvas-scanner
%endif

%if 0%{?mandriva_version}
%__install -Dm 0755 %{_sourcedir}/openvassd.init.mandriva %{buildroot}%{_initrddir}/openvas-scanner
%__install -Dm 0644 %{_sourcedir}/debian.openvas-scanner.default %{buildroot}%{_sysconfdir}/sysconfig/openvas-scanner
%endif

%__mkdir_p %{buildroot}%{_localstatedir}/cache/openvas
%__mkdir_p %{buildroot}%{_localstatedir}/lib/openvas
%__mkdir_p %{buildroot}%{_localstatedir}/log/openvas
touch %{buildroot}%{_localstatedir}/log/openvas/greenbone-nvt-sync.log
touch %{buildroot}%{_localstatedir}/log/openvas/openvassd.dump
touch %{buildroot}%{_localstatedir}/log/openvas/openvassd.messages

rm %{buildroot}%{_datadir}/doc/%{name}/*

%clean
test "%{buildroot}" != "/" && %__rm -rf %{buildroot}

%pre
%if 0%{?suse_version} > 1220
%service_add_pre openvas-scanner.service
%endif

%post
# Generate cert
%if 0%{?suse_version} < 1321
if [ ! -f  %{_localstatedir}/lib/openvas/CA/servercert.pem ] ; then
  %{_sbindir}/openvas-mkcert -q > /dev/null 2>&1
fi
%endif

%if 0%{?suse_version}
%fillup_only openvas-scanner
%if 0%{?suse_version} > 1220
%service_add_post openvas-scanner.service
%endif
%endif

%if 0%{?mandriva_version}
%_post_service openvas-scanner
%endif

%if 0%{?fedora_version} || 0%{?scientificlinux_version} || 0%{?centos_version}
# only rpm -i (not rpm {-U|-F})
if [ $1 = 1 ]; then
	/sbin/chkconfig --add openvas-scanner
fi
%endif

%preun
%if 0%{?suse_version}
%if %{with systemd}
%service_del_preun openvas-scanner.service
%else
%stop_on_removal openvas-scanner
%endif
%endif

%if 0%{?mandriva_version}
%_preun_service openvas-scanner
%endif

%if 0%{?fedora_version} || 0%{?scientificlinux_version} || 0%{?centos_version}
# only rpm -e (not rpm {-U|-F})
if [ $1 = 0 ]; then
    /sbin/service openvas-scanner stop > /dev/null 2>&1 || :
    /sbin/chkconfig --del openvas-scanner
fi
%endif

%postun
%if 0%{?suse_version}
%if %{with systemd}
%service_del_postun openvas-scanner.service
%else
%restart_on_update openvas-scanner
%insserv_cleanup
%endif
%endif

%if 0%{?fedora_version} || 0%{?scientificlinux_version} || 0%{?centos_version}
# only rpm {-U|-F} (not rpm -e)
if [ $1 = 1 ]; then
    /sbin/service openvas-scanner condrestart
fi
%endif

%files
%defattr(-,root,root)
%config(noreplace) %{_sysconfdir}/logrotate.d/openvas-scanner
%{_sbindir}/greenbone-nvt-sync
%{_sbindir}/openvas-mkcert
%{_bindir}/openvas-mkcert-client
%{_sbindir}/openvas-nvt-sync
%{_sbindir}/openvassd
%ghost %{_localstatedir}/cache/openvas
%dir %{_localstatedir}/lib/openvas
%dir %{_localstatedir}/log/openvas
%ghost %{_localstatedir}/log/openvas/greenbone-nvt-sync.log
%ghost %{_localstatedir}/log/openvas/openvassd.dump
%ghost %{_localstatedir}/log/openvas/openvassd.messages
%{_mandir}/man8/greenbone-nvt-sync.8*
%{_mandir}/man8/openvas-mkcert.8*
%{_mandir}/man8/openvas-nvt-sync.8*
%{_mandir}/man8/openvassd.8*
%{_mandir}/man8/openvas-mkcert-client.8*
%{_mandir}/man1/openvas-mkcert-client.1*
%if 0%{?suse_version}
%{_sbindir}/rcopenvas-scanner
%{_var}/adm/fillup-templates/sysconfig.openvas-scanner
%else
%config(noreplace) %{_sysconfdir}/sysconfig/openvas-scanner
%endif
%if %{with systemd}
%{_unitdir}/openvas-scanner.service
%else
%{_initrddir}/openvas-scanner
%endif
%doc CHANGES COPYING* README build/doc/example*.conf

%changelog
openSUSE Build Service is sponsored by