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 http://bugs.opensuse.org/
#


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++
Url:            https://github.com/MTG/gaia
Source:         https://github.com/MTG/gaia/archive/v2.4.5.tar.gz
# http://code.qt.io/cgit/qt/qthttp.git/
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


%description
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

%prep
%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 __init__.py -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/gaiafusion.py

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

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

%install
./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}/

%post
%postun

%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
fi
exit 0

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

%files
%defattr(-,root,root)
%doc README.md ChangeLog
%license COPYING.txt

%files -n libgaia2
%{_libdir}/libgaia2.a

%files python
%{python_sitelib}/*

%files tools
/usr/bin/gaiainfo
/usr/bin/gaiamerge
#/usr/bin/gaia22to23fl
/usr/bin/gaiafusion
/usr/bin/gaiafreeze

%files cyclops
/usr/bin/cyclops
/usr/bin/cyclopsmaster
/usr/bin/start-cyclops-slaves
%dir /etc/cyclops
%config(noreplace) /etc/cyclops/master.yaml
%{_userunitdir}/cyclops-master.service
%{_userunitdir}/cyclops-slaves.service

%files devel
/usr/include/*
%{_libdir}/pkgconfig/gaia2.pc

%changelog