File gsa.spec of Package gsa

#
# spec file for package gsa
#
# Copyright (c) 2019-2021, Martin Hauke <mardnh@gmx.de>
#
# 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 https://bugs.opensuse.org/
#


Name:           gsa
Version:        21.4.2
Release:        0
Summary:        Greenbone Security Assistant
License:        AGPL-3.0-or-later
Group:          Productivity/Networking/Security
URL:            https://www.openvas.org
#Git-Clone:     https://github.com/greenbone/gsa.git
Source:         https://github.com/greenbone/%{name}/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1:        npm-packages-offline-cache.tar.gz
Source2:        gsad.sysconfig
Source3:        gsad.service
Source98:       https://github.com/greenbone/%{name}/releases/download/v%{version}/%{name}-%{version}.tar.gz.sig
Source99:       https://www.greenbone.net/GBCommunitySigningKey.asc#/%{name}.keyring
BuildRequires:  cmake
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  libgcrypt-devel
BuildRequires:  nodejs >= 10.0
BuildRequires:  pkgconfig
BuildRequires:  yarn >= 1.0
BuildRequires:  pkgconfig(glib-2.0)
BuildRequires:  pkgconfig(gnutls) >= 3.2.15
BuildRequires:  pkgconfig(libgvm_base) >= 10.0.0
BuildRequires:  pkgconfig(libgvm_gmp) >= 10.0.0
BuildRequires:  pkgconfig(libgvm_util) >= 10.0.0
BuildRequires:  pkgconfig(libmicrohttpd) >= 0.9.0
BuildRequires:  pkgconfig(libxml-2.0)
BuildRequires:  gvm-common >= 20.8.0
Requires:       gvm-common >= 20.8.0
Recommends:     logrotate
%{?systemd_ordering}

%description
The Greenbone Security Assistant is the web interface developed for the
Greenbone Security Manager appliances.
It connects to the Greenbone Vulnerability Manager GVM to provide a
full-featured user interface for vulnerability management.

Greenbone Security Assistant consists of:
 * GSA  - The webpage written in React
 * GSAD - The HTTP server talking to the GVM daemon

%prep
%setup -q
echo  '#define GSAD_GIT_REVISION "%{version}"' > gsad/src/gitrevision.h
# extract npm-packages-offline-cache
tar -xzvf %{SOURCE1}

%build
# set npm offline cache directory
yarn config set yarn-offline-mirror $(pwd)/npm-packages-offline-cache
%cmake \
    -DLOCALSTATEDIR=%{_localstatedir} \
    -DGVM_RUN_DIR=%{gvm_runtimedir} \
    -DGSAD_PID_DIR=%{gvm_runtimedir} \
    -DSYSCONFDIR=%{_sysconfdir} \
    -DDEFAULT_CONFIG_DIR=%{_sysconfdir}/default \
    -DLOGROTATE_DIR=%{_sysconfdir}/logrotate.d \
    -DSYSTEMD_SERVICE_DIR=%{_unitdir} \
    -DYARN_OFFLINE=1
%make_jobs

%install
%cmake_install
%fdupes %{buildroot}%{_datadir}/gvm/gsad/web
install -D -m 0644 %{SOURCE2} %{buildroot}%{_fillupdir}/sysconfig.gsad
# Use our own service file
install -D -m 0644 %{SOURCE3} %{buildroot}%{_unitdir}/gsad.service
install -d %{buildroot}/%{_sbindir}
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rcgsad

%pre
%service_add_pre gsad.service

%post
%fillup_only -n gsad
%service_add_post gsad.service

%preun
%service_del_preun gsad.service

%postun
%service_del_postun gsad.service

%files
%license LICENSE
%doc CHANGELOG.md README.md RELEASE.md
%config(noreplace) %{_sysconfdir}/gvm/gsad_log.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/gsad
%{_sbindir}/gsad
%{_sbindir}/rcgsad
%{_mandir}/man8/gsad.8%{?ext_man}
%{_datadir}/gvm/gsad/web
%{_unitdir}/gsad.service
%{_fillupdir}/sysconfig.gsad

%changelog
openSUSE Build Service is sponsored by