#
# FIXME: we should probably rewrite this spec file looking at https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/
#

Name:           cmonitor-tools
Version:        2.6.1
Release:        0%{?dist}
Summary:        A Docker/LXC, database-free, lightweight container performance monitoring solution
License:        GPL
URL:            https://github.com/f18m/cmonitor
Source0:        cmonitor-tools-2.6.1.tar.gz

# these are the requirements that we need on COPR builds:
# IMPORTANT: python3-devel provide macros like %{python3_sitelib}
BuildRequires:  gcc-c++, make, python3-devel

# cmonitor_filter uses dateutil library to parse dates.. of course to make our life easier the same python library
# RPM has different names on different distro versions...
%if 0%{?rhel} == 7
Requires: python-dateutil
%endif
%if 0%{?rhel} >= 8
Requires: python3-dateutil
%endif

# Disable automatic debug package creation: it fails within Fedora 28, 29 and 30 for the lack
# of debug info files apparently:
%global debug_package %{nil}

%description
Tools to post-process data collected via cmonitor_collector utility.
Cmonitor collector is  a Docker/LXC, database-free, lightweight container performance monitoring solution, perfect for ephemeral containers
(e.g. containers used for DevOps automatic testing). Can also be used with InfluxDB and Grafana to monitor long-lived 
containers in real-time.

%prep
%setup

%build

%install
rm -rf %{buildroot}
# this command invokes the root Makefile of cmonitor repo, from inside the source tarball
# produced by COPR that will pass all the options listed here to tools/Makefile
%make_install -C tools BINDIR=%{_bindir} PYTHON3_SITELIB=%{python3_sitelib} CMONITOR_LAST_COMMIT_HASH=719d7bf85c3f80d3cd7fa9628fd406b7a2976378

%files
%{_bindir}/cmonitor_*
%{python3_sitelib}/cmonitor_*.py
%{python3_sitelib}//__pycache__/cmonitor_*.*.pyc