File hanadb_exporter.spec of Package hanadb_exporter

# spec file for package hanadb_exporter
# Copyright (c) 2019 SUSE LLC
# 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

%if 0%{?suse_version} < 1500
%bcond_with test
%bcond_without test

%define _prefix /usr
%define oldsyscondir /etc
%define _sysconfdir %{_prefix}/etc

Name:           hanadb_exporter
Version:        0.6.1
Release:        0
Summary:        SAP HANA database metrics exporter
License:        Apache-2.0
Group:          Development/Languages/Python
Source:         hanadb_exporter-%{version}.tar.gz
%if %{with test}
BuildRequires:  python3-mock
BuildRequires:  python3-pytest
BuildRequires:  python3-setuptools
BuildRequires:  fdupes
BuildRequires:  systemd-rpm-macros
Requires:       python3-shaptools >= 0.3.2
Requires:       python3-prometheus_client >= 0.6.0
BuildArch:      noarch

SAP HANA database metrics exporter

%setup -q -n hanadb_exporter-%{version}

python3 build

python3 install --root %{buildroot} --prefix=%{_prefix}
%fdupes %{buildroot}%{python3_sitelib}
# do not install tests
rm -r %{buildroot}%{python3_sitelib}/tests

# Add daemon files
mkdir -p %{buildroot}%{oldsyscondir}/hanadb_exporter
mkdir -p %{buildroot}%{_sysconfdir}/hanadb_exporter
install -D -m 644 daemon/hanadb_exporter@.service %{buildroot}%{_unitdir}/hanadb_exporter@.service

install -D -m 0644 config.json.example %{buildroot}%{_docdir}/hanadb_exporter/config.json.example
install -D -m 0644 metrics.json %{buildroot}%{_docdir}/hanadb_exporter/metrics.json
install -D -m 0644 logging_config.ini %{buildroot}%{_docdir}/hanadb_exporter/logging_config.ini

%service_add_post hanadb_exporter@.service
rm -rf  %{_sysconfdir}/hanadb_exporter/*
ln -s %{_docdir}/hanadb_exporter/config.json.example %{_sysconfdir}/hanadb_exporter/config.json.example
ln -s %{_docdir}/hanadb_exporter/metrics.json  %{_sysconfdir}/hanadb_exporter/metrics.json
ln -s %{_docdir}/hanadb_exporter/logging_config.ini  %{_sysconfdir}/hanadb_exporter/logging_config.ini

%service_add_pre hanadb_exporter@.service

%service_del_preun -n hanadb_exporter@.service

%service_del_postun -n hanadb_exporter@.service

%if %{with test}
pytest tests

%if 0%{?sle_version:1} && 0%{?sle_version} < 120300
%doc docs/ LICENSE
%doc docs/
%license LICENSE

%dir %{_sysconfdir}
%dir %{oldsyscondir}/hanadb_exporter
%dir %{_sysconfdir}/hanadb_exporter

openSUSE Build Service is sponsored by