%bcond_with systemd

%global with_enca 1
%global with_libcue 1
%global with_rss 0

%global tracker_version 2.2.0

%global systemd_units tracker-extract.service tracker-miner-fs.service tracker-miner-rss.service tracker-writeback.service

# Exclude private libraries from autogenerated provides and requires
%global __provides_exclude_from ^%{_libdir}/tracker-miners-2.0/
%global __requires_exclude ^(libtracker-extract\.so|libtracker-miners-common\.so|libextract-.*\.so|libwriteback-.*\.so)

Name:           tracker-miners
Version:        2.3.3
Release:        1%{?_dist_release}
Summary:        Tracker miners and metadata extractors
Group:          Applications/Services

Vendor:         Project Vine
Distribution:   Vine Linux

# libtracker-extract is LGPLv2+; the miners are a mix of GPLv2+ and LGPLv2+ code
License:        GPLv2+ and LGPLv2+
URL:            https://wiki.gnome.org/Projects/Tracker

%define         shortver %(echo %{version} | sed -e 's/\\.[0-9]*$//')
Source0:        https://download.gnome.org/sources/%{name}/%{shortver}/%{name}-%{version}.tar.xz

BuildRequires:  gcc
BuildRequires:  giflib-devel
BuildRequires:  intltool
BuildRequires:  meson
%if %{with systemd}
BuildRequires:  systemd
%endif
BuildRequires:  pkgconfig(dbus-1)
%if 0%{?with_enca}
BuildRequires:  pkgconfig(enca)
%endif
BuildRequires:  pkgconfig(exempi-2.0)
BuildRequires:  flac-devel
BuildRequires:  pkgconfig(gexiv2)
BuildRequires:  pkgconfig(gstreamer-1.0)
BuildRequires:  pkgconfig(gstreamer-pbutils-1.0)
BuildRequires:  pkgconfig(gstreamer-tag-1.0)
BuildRequires:  pkgconfig(icu-i18n)
BuildRequires:  pkgconfig(icu-uc)
%if 0%{?with_libcue}
BuildRequires:  pkgconfig(libcue)
%endif
BuildRequires:  pkgconfig(libexif)
%if 0%{?with_rss}
BuildRequires:  pkgconfig(libgrss)
%endif
BuildRequires:  pkgconfig(libgsf-1)
BuildRequires:  pkgconfig(libgxps)
#BuildRequires:  pkgconfig(libiptcdata)
BuildRequires:  pkgconfig(libjpeg)
#BuildRequires:  pkgconfig(libosinfo-1.0)
BuildRequires:  pkgconfig(libpng)
BuildRequires:  pkgconfig(libseccomp)
BuildRequires:  pkgconfig(libtiff-4)
BuildRequires:  pkgconfig(libxml-2.0)
BuildRequires:  pkgconfig(poppler-glib)
BuildRequires:  pkgconfig(taglib_c)
BuildRequires:  pkgconfig(totem-plparser)
BuildRequires:  pkgconfig(tracker-sparql-2.0)
BuildRequires:  pkgconfig(upower-glib)
BuildRequires:  pkgconfig(vorbisfile)
BuildRequires:  pkgconfig(zlib)

%if %{with systemd}
%{?systemd_requires}
%endif
Requires(post,postun): desktop-file-utils
Requires:       tracker%{?_isa} >= %{tracker_version}
# tracker-miners was split out from tracker in 1.99.2
Obsoletes:      tracker < 1.99.2
Conflicts:      tracker < 1.99.2

%description
Tracker is a powerful desktop-neutral first class object database,
tag/metadata database and search tool.

This package contains various miners and metadata extractors for tracker.


%prep
%autosetup -p1


%build
# Disable the functional tests for now, they use python bytecodes.
%meson \
  -Dfunctional_tests=false \
  -Diptc=disabled \
  -Diso=disabled \
  -Dminer_rss=false \
%if %{with systemd}
  -Dsystemd_user_services=%{_userunitdir}
%endif
  %{nil}
%meson_build


%install
%meson_install

rm -rf %{buildroot}%{_datadir}/tracker-tests

%find_lang %{name}


%post
%if %{with systemd}
%systemd_user_post %{systemd_units}
%endif
if [ $1 -eq 1 ]; then
  glib-compile-schemas /usr/share/glib-2.0/schemas ||:
  update-desktop-database -q > /dev/null || :
fi

%if %{with systemd}
%preun
%systemd_user_preun %{systemd_units}
%endif

%postun
%if %{with systemd}
%systemd_user_postun_with_restart %{systemd_units}
%endif
if [ $1 -eq 0 ]; then
  glib-compile-schemas /usr/share/glib-2.0/schemas ||:
  update-desktop-database -q > /dev/null || :
fi


%files -f %{name}.lang
%license COPYING
%doc AUTHORS NEWS README.md
%{_libdir}/tracker-miners-2.0/
%{_libexecdir}/tracker*
%{_datadir}/dbus-1/services/org.freedesktop.Tracker*
%{_datadir}/glib-2.0/schemas/*
%{_datadir}/tracker/
%{_datadir}/tracker-miners/
%{_mandir}/man1/tracker-*.1*
%config(noreplace) %{_sysconfdir}/xdg/autostart/tracker*.desktop
%if %{with systemd}
%{_userunitdir}/tracker*.service
%endif

%changelog
* Fri Mar 20 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 2.3.3-1
- new upstream release.

* Tue Oct 22 2019 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 2.3.1
- initial build for Vine Linux.
- new upstream release.

* Mon Sep 09 2019 Kalev Lember <klember@redhat.com> - 2.3.0-1
- Update to 2.3.0

* Fri Sep 06 2019 Nikola Forró <nforro@redhat.com> - 2.2.99.1-2
- Rebuilt for exempi 2.5.1

* Fri Sep 06 2019 Kalev Lember <klember@redhat.com> - 2.2.99.1-1
- Update to 2.2.99.1

* Mon Aug 12 2019 Kalev Lember <klember@redhat.com> - 2.2.99.0-1
- Update to 2.2.99.0

* Sat Jul 27 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.2.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild

* Fri May 03 2019 David King <amigadave@amigadave.com> - 2.2.2-1
- Update to 2.2.2

* Fri Mar 08 2019 Kalev Lember <klember@redhat.com> - 2.2.1-1
- Update to 2.2.1

* Thu Feb 21 2019 Kalev Lember <klember@redhat.com> - 2.2.0-3
- Exclude private libraries from autogenerated provides and requires

* Thu Feb 21 2019 Kalev Lember <klember@redhat.com> - 2.2.0-2
- Fix the package to be installable again

* Wed Feb 20 2019 Kalev Lember <klember@redhat.com> - 2.2.0-1
- Update to 2.2.0
- Switch to the meson build system

* Sun Feb 03 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.1.5-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

* Wed Jan 23 2019 Pete Walter <pwalter@fedoraproject.org> - 2.1.5-3
- Rebuild for ICU 63

* Mon Jan 21 2019 Kevin Fenzi <kevin@scrye.com> - 2.1.5-2
- Rebuild to drop libiptcdata deps

* Fri Sep 28 2018 Kalev Lember <klember@redhat.com> - 2.1.5-1
- Update to 2.1.5

* Wed Sep 05 2018 Kalev Lember <klember@redhat.com> - 2.1.4-2
- Rebuilt with fixed vala

* Tue Sep 04 2018 Kalev Lember <klember@redhat.com> - 2.1.4-1
- Update to 2.1.4

* Mon Sep 03 2018 Kalev Lember <klember@redhat.com> - 2.1.3-1
- Update to 2.1.3

* Sun Aug 19 2018 Kalev Lember <klember@redhat.com> - 2.1.1-1
- Update to 2.1.1

* Wed Jul 25 2018 Kalev Lember <klember@redhat.com> - 2.1.0-1
- Update to 2.1.0

* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.5-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

* Tue Jul 10 2018 Pete Walter <pwalter@fedoraproject.org> - 2.0.5-2
- Rebuild for ICU 62

* Tue Jun 26 2018 Kalev Lember <klember@redhat.com> - 2.0.5-1
- Update to 2.0.5

* Mon Apr 30 2018 Pete Walter <pwalter@fedoraproject.org> - 2.0.4-4
- Rebuild for ICU 61.1

* Sun Feb 11 2018 Sandro Mani <manisandro@gmail.com> - 2.0.4-3
- Rebuild (giflib)

* Thu Feb 08 2018 Kalev Lember <klember@redhat.com> - 2.0.4-2
- Rebuild to really enable the RAW extractor

* Wed Feb 07 2018 Kalev Lember <klember@redhat.com> - 2.0.4-1
- Update to 2.0.4
- Enable new gexiv2 based RAW extractor

* Thu Nov 30 2017 Pete Walter <pwalter@fedoraproject.org> - 2.0.3-2
- Rebuild for ICU 60.1

* Tue Nov 21 2017 Kalev Lember <klember@redhat.com> - 2.0.3-1
- Update to 2.0.3

* Fri Oct 06 2017 Kalev Lember <klember@redhat.com> - 2.0.2-1
- Update to 2.0.2

* Tue Sep 19 2017 Kalev Lember <klember@redhat.com> - 2.0.0-3
- Backport a fix for a crash when processing virtual elements (#1488707)

* Fri Sep 15 2017 Kalev Lember <klember@redhat.com> - 2.0.0-2
- Package review fixes (#1491725):
- Pass --disable-mp3 to use the generic gstreamer extractor
- Disable libstemmer support to match the previous behaviour
- Fix removing .so symlinks for private libraries
- Remove ldconfig rpm scripts as we don't install any shared libraries
- Correct license tag and add comment explaining mixed source licensing

* Thu Sep 14 2017 Kalev Lember <klember@redhat.com> - 2.0.0-1
- Initial Fedora packaging
