File gaia2.spec of Package gaia2

# spec file for package gaia2
# Copyright (c) 2018 SUSE LINUX 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

Name:           gaia2
Version:        2.4.5
Release:        0
Summary:        C++ library to apply similarity measures and classifications analysis on audio
License:        AGPL-3.0-only + BSD-3-Clause + LGPL-2.1 + (LGPL-3.0-only or GPL-2-or-later)
Group:          Development/Libraries/C and C++
Source1:        qthttp-20141028.tar.xz
Source2:        start-cyclops-slaves
Source3:        cyclops-slaves.service
Source4:        cyclops-master.service
Patch0:         use-qt5.patch
Patch1:         use-system-libraries.patch
Patch2:         use-qthttp-addon.patch
#BuildRequires:  pkgconfig(fftw3)
#BuildRequires:  pkgconfig(libavcodec)
#BuildRequires:  pkgconfig(libavformat)
#BuildRequires:  pkgconfig(samplerate)
#BuildRequires:  pkgconfig(taglib)
BuildRequires:  libyaml-devel
BuildRequires:  python2-devel
BuildRequires:  libsvm-devel
BuildRequires:  pkgconfig(Qt5Core)
BuildRequires:  pkgconfig(Qt5Concurrent)
BuildRequires:  pkgconfig(Qt5Network)
BuildRequires:  swig

Gaia is a C++ library with python bindings which implements similarity measures
and classiļ¬cations on the results of audio analysis, and generates classification
models that Essentia can use to compute high-level description of music.

%package -n libgaia2
Summary: Gaia2 library
Group: Development/Libraries/C and C++

%description -n libgaia2
The gaia2 static library

%package python
Summary: Gaia2 Python Bindings
Group: Development/Libraries/Python
Requires: libgaia2 = %{version}-%{release}

%description python
Python bindings for libgaia2

%package tools
Summary: Gaia2 Utilities
Group: Productivity/Multimedia/Sound/Utilities
Requires: libgaia2 = %{version}-%{release}

%description tools
Utilities for libgaia2

%package cyclops
Summary: Gaia2 Cyclops
Group: Productivity/Multimedia/Sound/Utilities
Requires: libgaia2 = %{version}-%{release}
Requires: python3-PyYAML

%description cyclops
Cyclops for libgaia2

%package devel
Summary: Gaia2 Utilities
Group: Development/Libraries/C and C++
Requires: libgaia2 = %{version}-%{release}
Requires: pkgconfig(Qt5Core)
Requires: pkgconfig(Qt5Concurrent)
Requires: pkgconfig(Qt5Network)

%description devel
Header files for libgaia2

%setup -q -n gaia-%{version}
%patch0 -p1
%patch1 -p1
%patch2 -p1

cp src/3rdparty/libsvm/gaiasvmutils.* src/
rm -Rf src/3rdparty/libsvm
tar xvfJ %{SOURCE1} -C src/3rdparty
find src/bindings/pygaia/scripts -name -prune -o -iname "*.py" -exec chmod +x "{}" \;
find src/bindings/pygaia/ -name *.py ! -executable -exec sed -i -e '1{\,^#!%{_bindir}/env python,d}' "{}" \;
find src/bindings/pygaia/ -name *.py -executable -exec sed -i -e "s,#!/usr/bin/env python,#!/usr/bin/python," "{}" \;
sed -i -e "s,#!/usr/bin/env python,#!/usr/bin/python," src/tools/

chmod +x  src/bindings/pygaia/scripts/*

./waf configure --with-python-bindings --prefix=/usr/ --libdir=%{_libdir} -v --with-cyclops
./waf build -v

./waf install --destdir=%{buildroot}
# copy redhat-specific init scripts
#cp packaging/centos5/init.d/cyclopsmaster %{buildroot}/etc/init.d/
#cp packaging/centos5/init.d/cyclopsslaves %{buildroot}/etc/init.d/

rm %{buildroot}/etc/init.d/cyclops*
install %{SOURCE2} %{buildroot}/usr/bin
install -d %{buildroot}%{_userunitdir}/
install -m 0644 %{S:3} %{S:4} %{buildroot}%{_userunitdir}/


%pre cyclops
/usr/sbin/useradd -c "Cyclops" -K UID_MAX=499 \
	-s /bin/false -r -d /var/run/cyclops -m cyclops 2>/dev/null || :

%post cyclops
#/sbin/chkconfig --add cyclopsmaster
#/sbin/chkconfig --add cyclopsslaves

%preun cyclops
if [ $1 = 0 ]; then
   /usr/sbin/userdel cyclops 2>/dev/null || :
   /usr/sbin/groupdel cyclops 2>/dev/null || :
#   /sbin/chkconfig --del cyclopsmaster
#   /sbin/chkconfig --del cyclopsslaves
exit 0

#%postun cyclops
#if [ "$1" -ge 1 ]; then
#	/etc/rc.d/init.d/cyclopsmaster stop >/dev/null 2>&1 || :

%doc ChangeLog
%license COPYING.txt

%files -n libgaia2

%files python

%files tools

%files cyclops
%dir /etc/cyclops
%config(noreplace) /etc/cyclops/master.yaml

%files devel