File openvas-manager.spec of Package openvas-manager

#
# spec file for package openvas-manager
#
# Copyright (c) 2014 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/
#


Name:           openvas-manager
Version:        4.0.4
Release:        5.1
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
PreReq:         %insserv_prereq
PreReq:         %fillup_prereq
%if 0%{?suse_version} > 1220
BuildRequires:  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
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

export CFLAGS="$RPM_OPT_FLAGS"

%__mkdir build
cd build
cmake .. -Wno-dev \
         -DCMAKE_VERBOSE_MAKEFILE=ON \
         -DCMAKE_INSTALL_PREFIX=%{_prefix} \
         -DSYSCONFDIR=%{_sysconfdir} \
         -DLOCALSTATEDIR=%{_localstatedir} \
         #-DCMAKE_BUILD_TYPE=release

#__make %{?_smp_mflags} VERBOSE=1
make VERBOSE=1

%install
pushd build
%__make install DESTDIR=%{buildroot}
popd
%__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}/
%__install -Dm 0755 %{_sourcedir}/openvasmd.init.suse %{buildroot}%{_initrddir}/openvas-manager
%__ln_s %{_initrddir}/openvas-manager %{buildroot}%{_sbindir}/rcopenvas-manager
%__install -Dm 0644 %{_sourcedir}/debian.openvas-manager.default %{buildroot}%{_var}/adm/fillup-templates/sysconfig.openvas-manager
chmod -R 755 %{buildroot}/usr/share/openvas/openvasmd/global_report_formats
chmod -R 644 %{buildroot}/usr/share/openvas/openvasmd/global_report_formats/*/*.xsl
chmod -R 755 %{buildroot}/usr/share/openvas/openvasmd/global_schema_formats
chmod -R 644 %{buildroot}/usr/share/openvas/openvasmd/global_schema_formats/*/*.xsl
chmod -R 644 %{buildroot}/usr/share/openvas/openvasmd/global_schema_formats/*/*.xml
chmod -R 755 %{buildroot}/usr/share/openvas/openvasmd/global_alert_methods
%__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
%if 0%{?suse_version} > 1220
mkdir -p $RPM_BUILD_ROOT/usr/lib/systemd/
mkdir -p $RPM_BUILD_ROOT/usr/lib/systemd/system
install -m 644 $RPM_SOURCE_DIR/openvas-manager.service $RPM_BUILD_ROOT/usr/lib/systemd/system/openvas-manager.service
%endif
%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 0%{?suse_version} > 1220
%service_add_pre openvas-manager.service
%endif

%post
%if 0%{?suse_version}
%fillup_and_insserv openvas-manager
%if 0%{?suse_version} > 1220
%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}
%stop_on_removal openvas-manager
%if 0%{?suse_version} > 1220
%service_del_preun openvas-manager.service
%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}
%restart_on_update openvas-manager
%insserv_cleanup
%if 0%{?suse_version} > 1220
%service_del_postun openvas-manager.service
%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 COPYING
%config(noreplace) %{_sysconfdir}/logrotate.d/openvas-manager
%dir %{_sysconfdir}/openvas
%config(noreplace) %{_sysconfdir}/openvas/openvasmd_log.conf
%{_initrddir}/openvas-manager
%{_sbindir}/greenbone-scapdata-sync
%{_sbindir}/greenbone-certdata-sync
%{_sbindir}/openvasmd
%{_sbindir}/openvas-scapdata-sync
%{_sbindir}/openvas-certdata-sync
%{_sbindir}/openvas-setup
%{_mandir}/man8/openvasmd.8*
%{_mandir}/man8/greenbone-scapdata-sync.8*
%{_mandir}/man8/greenbone-certdata-sync.8*
%{_mandir}/man8/openvas-scapdata-sync.8*
%{_mandir}/man8/openvas-certdata-sync.8*
%{_mandir}/man8//openvas-setup.8*
%{_datadir}/openvas/openvasmd
%{_datadir}/openvas/scap
%{_datadir}/openvas/cert
%{_datadir}/doc/openvas-manager
%{_datadir}/doc/openvas-manager/html/omp.html
%dir %{_localstatedir}/lib/openvas
%{_localstatedir}/lib/openvas/mgr
%{_localstatedir}/lib/openvas/openvasmd
%dir %{_localstatedir}/log/openvas
%ghost %{_localstatedir}/log/openvas/openvasmd.log

%if 0%{?suse_version}
%{_sbindir}/rcopenvas-manager
%{_var}/adm/fillup-templates/sysconfig.openvas-manager
%if 0%{?suse_version} > 1220
   /usr/lib/systemd/system/openvas-manager.service
%endif
%else
%config(noreplace) %{_sysconfdir}/sysconfig/openvas-manager
%endif

%changelog