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.6
Release:        0
Summary:        C++ library to apply similarity measures and classifications analysis on audio
License:        AGPL-3.0-only
Group:          Development/Libraries/C and C++
Url:            https://github.com/MTG/gaia
Source:         https://github.com/MTG/gaia/archive/v%{version}.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
Source5:        waf
Patch0:         use-qt5.patch
Patch1:         use-system-libraries.patch
Patch2:         use-qthttp-addon.patch
Patch3:         use-python3.patch
Patch4:         remove-sse2-flags.patch
Patch5:         fix-ftbfs-with-swig-4.2.0.patch
#Patch6:         create-shared-library.patch
#BuildRequires:  pkgconfig(fftw3)
#BuildRequires:  pkgconfig(libavcodec)
#BuildRequires:  pkgconfig(libavformat)
#BuildRequires:  pkgconfig(samplerate)
#BuildRequires:  pkgconfig(taglib)
BuildRequires:  libyaml-devel
BuildRequires:  python3-devel
BuildRequires:  python3-setuptools
BuildRequires:  python-rpm-macros
BuildRequires:  libsvm-devel
BuildRequires:  pkgconfig(eigen3)
BuildRequires:  pkgconfig(Qt5Core)
BuildRequires:  pkgconfig(Qt5Widgets)
BuildRequires:  pkgconfig(Qt5Concurrent)
BuildRequires:  pkgconfig(Qt5Network)
BuildRequires:  swig
#BuildArch:      noarch


%description
Gaia is a C++ library with python bindings which implements similarity measures
and classifications 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 -n %{python_flavor}-gaia2
Summary: Gaia2 Python Bindings
Group: Development/Libraries/Python
#Requires: libgaia2 = %%{version}-%%{release}

%description -n %{python_flavor}-gaia2
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}
%patch -p1 -P 0
%patch -p1 -P 1
%patch -p1 -P 2
%patch -p1 -P 3
%ifarch aarch64 %{arm}
%patch -p1 -P 4
%endif
%if %{pkg_vcmp swig >= 4.2.0}
%patch -p1 -P 5
%endif

cp "%{SOURCE5}" .
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 %{python_flavor}-gaia2
%{python3_sitearch}/*

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

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

%files devel
%{_includedir}/gaia2
%{_libdir}/pkgconfig/gaia2.pc
%{_libdir}/libgaia2.a

#%%files -n libgaia2

%changelog
openSUSE Build Service is sponsored by