File openvas-manager.spec of Package openvas-manager

#
# spec file for package openvas-manager
#
# Copyright (c) 2013 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-manager
Version:        7.0.2
Release:        0
Url:            http://www.openvas.org
Source0:        %{name}-%{version}.tar.gz
Source1:        openvasmd.logrotate
Source2:        debian.openvas-manager.default
Source3:        openvasmd.init.suse
Source4:        openvasmd.init.fedora
Source5:        openvasmd.init.mandriva
Source6:        openvas-setup
Source7:        openvas-manager.service
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%if 0%{?fedora_version} || 0%{?scientificlinux_version}
BuildRequires:  sqlite-devel
%endif

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

%if 0%{?suse_version}
BuildRequires:  fdupes
BuildRequires:  sqlite3-devel
BuildRequires:  libgcrypt-devel
PreReq:         %insserv_prereq
PreReq:         %fillup_prereq
%if %{with systemd}
BuildRequires:  pkgconfig(systemd)
%systemd_requires
%endif
%endif

%if 0%{?suse_version} > 1210
BuildRequires:  cmake >= 2.8.0
%else
BuildRequires:  cmake >= 2.6.0
%endif
BuildRequires:  doxygen
BuildRequires:  glib2-devel
BuildRequires:  libopenvas-devel >= 9.0.0
BuildRequires:  pkgconfig
Requires:       logrotate
Summary:        Manager Module of OpenVAS
License:        GPL-2.0
Group:          Productivity/Networking/Security

%description
The OpenVAS-Manager is a layer between OpenVAS-Scanner and various client
applications such as OpenVAS-Client or Greenbone Security Assistant.  Among
other features, it adds server-side storage of scan results and it makes it
unnecessary for scan clients to keep connection until a scan finishes.


%prep
%setup -q

%build
%if 0%{?mandriva_version}
%serverbuild
%endif
%cmake -Wno-dev -DLOCALSTATEDIR=%{_localstatedir}
make VERBOSE=1

%install
%cmake_install

%__install -Dm 0644 doc/openvasmd.8 %{buildroot}%{_mandir}/man8/openvasmd.8
%__install -Dm 0644 %{_sourcedir}/openvasmd.logrotate %{buildroot}%{_sysconfdir}/logrotate.d/openvas-manager

%if 0%{?suse_version}
%__install -Dm 0755 %{_sourcedir}/openvas-setup %{buildroot}%{_sbindir}/
%if %{with systemd}
install -D -m 644 %{_sourcedir}/openvas-manager.service $RPM_BUILD_ROOT%{_unitdir}/openvas-manager.service
ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rcopenvas-manager
%else
%__install -Dm 0755 %{_sourcedir}/openvasmd.init.suse %{buildroot}%{_initrddir}/openvas-manager
%__ln_s %{_initrddir}/openvas-manager %{buildroot}%{_sbindir}/rcopenvas-manager
%endif
%__install -Dm 0644 %{_sourcedir}/debian.openvas-manager.default %{buildroot}%{_var}/adm/fillup-templates/sysconfig.openvas-manager
chmod -vR u=rwX,go=rX %{buildroot}/usr/share/openvas/openvasmd/
find %{buildroot}/usr/share/openvas/openvasmd/ -name \*.sh -print0 | xargs -r0 chmod -v a+rX
%__ln_s %{_mandir}/man8/openvasmd.8.gz %{buildroot}%{_mandir}/man8/greenbone-scapdata-sync.8.gz
%__ln_s %{_mandir}/man8/openvasmd.8.gz %{buildroot}%{_mandir}/man8/openvas-scapdata-sync.8.gz
%__ln_s %{_mandir}/man8/openvasmd.8.gz %{buildroot}%{_mandir}/man8/openvas-setup.8.gz
%__ln_s %{_mandir}/man8/openvasmd.8.gz %{buildroot}%{_mandir}/man8/greenbone-certdata-sync.8.gz
%__ln_s %{_mandir}/man8/openvasmd.8.gz %{buildroot}%{_mandir}/man8/openvas-certdata-sync.8.gz
%fdupes -s $RPM_BUILD_ROOT/%_mandir
%fdupes -s $RPM_BUILD_ROOT/%_docdir
%fdupes -s $RPM_BUILD_ROOT/%_datadir
%endif

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

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

%__mkdir_p %{buildroot}%{_localstatedir}/lib/openvas/mgr
%__mkdir_p %{buildroot}%{_localstatedir}/log/openvas
touch %{buildroot}%{_localstatedir}/log/openvas/openvasmd.log

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

%pre
%if %{with systemd}
%service_add_pre openvas-manager.service
%endif

%post
%if 0%{?suse_version}
%fillup_only openvas-manager
%if %{with systemd}
%service_add_post openvas-manager.service
%endif
%endif

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

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

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

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

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

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

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

%files
%defattr(-,root,root)
%doc CHANGES README
%config(noreplace) %{_sysconfdir}/logrotate.d/openvas-manager
%dir %{_sysconfdir}/openvas
%config(noreplace) %{_sysconfdir}/openvas/openvasmd_log.conf
%{_sbindir}/greenbone-scapdata-sync
%{_sbindir}/greenbone-certdata-sync
%{_sbindir}/openvasmd
#%{_sbindir}/openvas-scapdata-sync
#%{_sbindir}/openvas-certdata-sync
%{_sbindir}/openvas-setup
%{_sbindir}/openvasmd-sqlite
%{_sbindir}/database-statistics-sqlite
%{_bindir}/openvas-manage-certs
%{_mandir}/man1/openvas-manage-certs*
%{_mandir}/man8/database-statistics-sqlite*
%{_mandir}/man8/greenbone-scapdata-sync.8*
%{_mandir}/man8/greenbone-certdata-sync.8*
%{_mandir}/man8/openvas*
%{_datadir}/openvas/openvasmd
%{_datadir}/openvas/scap
%{_datadir}/openvas/cert
%{_datadir}/doc/openvas-manager
%{_datadir}/doc/openvas-manager/html/omp.html
%{_localstatedir}/lib/openvas
#{_localstatedir}/lib/openvas/mgr
#{_localstatedir}/lib/openvas/openvasmd
%dir %{_localstatedir}/log/openvas
%ghost %{_localstatedir}/log/openvas/openvasmd.log
%{_sbindir}/openvas-migrate-to-postgres
%{_datadir}/openvas/openvas-lsc-rpm-creator.sh
%if 0%{?suse_version}
%{_sbindir}/rcopenvas-manager
%{_var}/adm/fillup-templates/sysconfig.openvas-manager
%config(noreplace) %{_sysconfdir}/openvas/pwpolicy.conf
%{_sbindir}/openvas-portnames-update
%if %{with systemd}
%{_unitdir}/openvas-manager.service
%else
%{_initrddir}/openvas-manager
%endif
%else
%config(noreplace) %{_sysconfdir}/sysconfig/openvas-manager
%endif

%changelog