File greenbone-security-assistant.spec of Package greenbone-security-assistant

#
# spec file for package greenbone-security-assistant
#
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2013 Johann LUCE.
#
# 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/
#


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

Name:           greenbone-security-assistant
Version:        4.0.2
Release:        3.2
Url:            http://www.openvas.org
Source0:        %{name}-%{version}.tar.gz
Source1:        gsad.logrotate
Source2:        debian.greenbone-security-assistant.default
Source3:        gsad.init.suse
Source4:        gsad.init.fedora
Source5:        gsad.init.mandriva
Source6:        greenbone-security-assistant.service
Patch1:         greenbone-security-gcrypt_version.patch	
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%if 0%{?mandriva_version}
BuildRequires:  pinentry-gtk2
%if 0%{?mandriva_version} < 201000
BuildRequires:  libxslt-proc
%else
BuildRequires:  xsltproc
%endif
%endif

%if 0%{?suse_version}
BuildRequires:  fdupes
PreReq:         %insserv_prereq
PreReq:         %fillup_prereq
%if 0%{?suse_version} > 1220
BuildRequires:  systemd
%systemd_requires
%endif
%endif

BuildRequires:  cmake >= 2.6.0
BuildRequires:  doxygen
BuildRequires:  glib2-devel
BuildRequires:  libmicrohttpd-devel
BuildRequires:  libopenvas-devel
BuildRequires:  libxslt-devel
BuildRequires:  pkgconfig
Requires:       logrotate
Summary:        The Greenbone Security Assistant
License:        GPL-2.0
Group:          Productivity/Networking/Security

%description
The Greenbone Security Assistant is a web application that
connects to the OpenVAS Manager and OpenVAS Administrator
to provide for a full-featured user interface for
vulnerability management.


%prep
%setup -q
%if 0%{?suse_version}
%patch1 -p1
%endif

%build
%if 0%{?mandriva_version}
%serverbuild
%endif

export CFLAGS="%{optflags}"

cmake -DCMAKE_VERBOSE_MAKEFILE=ON \
        -DCMAKE_INSTALL_PREFIX=%{_prefix} \
        -DSYSCONFDIR=%{_sysconfdir} \
        -DLOCALSTATEDIR=%{_localstatedir} 

%__make %{?_smp_mflags} VERBOSE=1

%install
%__make install DESTDIR=%{buildroot}
%__install -D -m 644 %{_sourcedir}/gsad.logrotate %{buildroot}%{_sysconfdir}/logrotate.d/greenbone-security-assistant

%if 0%{?suse_version}
%__install -D -m 755 %{_sourcedir}/gsad.init.suse %{buildroot}%{_initrddir}/greenbone-security-assistant
%__ln_s %{_initrddir}/greenbone-security-assistant %{buildroot}%{_sbindir}/rcgreenbone-security-assistant
%__install -D -m 644 %{_sourcedir}/debian.greenbone-security-assistant.default %{buildroot}%{_var}/adm/fillup-templates/sysconfig.greenbone-security-assistant
%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/greenbone-security-assistant.service $RPM_BUILD_ROOT/usr/lib/systemd/system/greenbone-security-assistant.service
%endif
%fdupes %{buildroot}%{_datadir}/openvas/
%endif

%if 0%{?fedora_version} || 0%{?scientificlinux_version}
%__install -D -m 755 %{_sourcedir}/gsad.init.fedora %{buildroot}%{_initrddir}/greenbone-security-assistant
%__install -D -m 644 %{_sourcedir}/debian.greenbone-security-assistant.default %{buildroot}%{_sysconfdir}/sysconfig/greenbone-security-assistant
%endif

%if 0%{?mandriva_version}
%__install -D -m 755 %{_sourcedir}/gsad.init.mandriva %{buildroot}%{_initrddir}/greenbone-security-assistant
%__install -D -m 644 %{_sourcedir}/debian.greenbone-security-assistant.default %{buildroot}%{_sysconfdir}/sysconfig/greenbone-security-assistant
%endif

%__mkdir_p %{buildroot}%{_localstatedir}/log/openvas
touch %{buildroot}%{_localstatedir}/log/openvas/gsad.log

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

%pre
%if 0%{?suse_version} > 1220
%service_add_pre greenbone-security-assistant.service
%endif

%post
%if 0%{?suse_version}
%fillup_and_insserv greenbone-security-assistant
%if 0%{?suse_version} > 1220
%service_add_post greenbone-security-assistant.service
%endif
%endif

%if 0%{?mandriva_version}
%_post_service greenbone-security-assistant
%endif

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

%preun
%if 0%{?suse_version}
%stop_on_removal greenbone-security-assistant
%if 0%{?suse_version} > 1220
%service_del_preun greenbone-security-assistant.service
%endif
%endif

%if 0%{?mandriva_version}
%_preun_service greenbone-security-assistant
%endif

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

%postun
%if 0%{?suse_version}
%restart_on_update greenbone-security-assistant
%insserv_cleanup
%if 0%{?suse_version} > 1220
%service_del_postun greenbone-security-assistant.service
%endif
%endif

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

%files
%defattr(-,root,root)
%doc COPYING
%config(noreplace) %{_sysconfdir}/logrotate.d/greenbone-security-assistant
%dir %{_sysconfdir}/openvas
%config(noreplace) %{_sysconfdir}/openvas/gsad_log.conf
%{_initrddir}/greenbone-security-assistant
%{_sbindir}/gsad
%{_mandir}/man8/gsad.8*
%dir %{_datadir}/openvas
%{_datadir}/openvas/gsa
%dir %{_localstatedir}/log/openvas
%ghost %{_localstatedir}/log/openvas/gsad.log

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

%changelog