%global systemd_units tracker-xdg-portal-3

Name:           tracker3
Version:        3.3.0
Release:        2
Summary:        Desktop-neutral metadata database and search tool
License:        GPLv2+
URL:            https://gnome.pages.gitlab.gnome.org/tracker/
Source0:        https://download.gnome.org/sources/tracker/3.3/tracker-%{version}.tar.xz

BuildRequires:  asciidoc gettext gtk-doc libstemmer-devel meson systemd vala
BuildRequires:  pkgconfig(dbus-1) dbus-daemon pkgconfig(icu-i18n)
BuildRequires:  pkgconfig(gobject-introspection-1.0)
BuildRequires:  pkgconfig(icu-uc) pkgconfig(json-glib-1.0)
BuildRequires:  pkgconfig(libsoup-2.4) pkgconfig(libxml-2.0)
BuildRequires:  pkgconfig(sqlite3) chrpath
BuildRequires:  python3-gobject

Obsoletes:      tracker3 < %{version}
Conflicts:      tracker3 < %{version}
Provides:       tracker3 = %{version}-%{release}
Provides:       tracker3%{?_isa} = %{version}-%{release}
Requires: libtracker-sparql3%{?_isa} = %{version}-%{release}

Recommends: tracker-miners3%{?_isa}

%{?systemd_requires}

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

It consists of a common object database that allows entities to have an
almost infinite number of properties, metadata (both embedded/harvested as
well as user definable), a comprehensive database of keywords/tags and
links to other entities.

It provides additional features for file based objects including context
linking and audit trails for a file object.

Metadata indexers are provided by the tracker-miners3 package.

%package -n     libtracker-sparql3
Summary:        Tracker SPARQL library
License:        LGPLv2+
Recommends:     %{name}%{?_isa} = %{version}-%{release}
Obsoletes:      libtracker-sparql3 < %{version}
Conflicts:      libtracker-sparql3 < %{version}
Provides:       libtracker-sparql3 = %{version}-%{release}
Provides:       libtracker-sparql3%{?_isa} = %{version}-%{release}
Obsoletes:      libtracker-control < 2.3.6-10
Obsoletes:      libtracker-miner < 2.3.6-10

%description -n libtracker-sparql3
This package contains the libtracker-sparql library.

%package        devel
Summary:        Development files for %{name}
Requires:       libtracker-sparql3%{?_isa} = %{version}-%{release}
Obsoletes:      tracker3-devel < %{version}
Conflicts:      tracker3-devel < %{version}
Provides:       tracker3-devel = %{version}-%{release}
Provides:       tracker3-devel%{?_isa} = %{version}-%{release}

%description devel
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.

%package        doc
Summary:        Documentation for %{name}
BuildArch:      noarch
Obsoletes:      tracker3-doc < %{version}
Conflicts:      tracker3-doc < %{version}
Provides:       tracker3-doc = %{version}-%{release}

%description doc
The %{name}-devel package contains the documentation for %{name}.

%prep
%autosetup -n tracker-%{version} -p1

%build
%meson \
  -Dunicode_support=icu \
  -Dsystemd_user_services_dir=%{_userunitdir} \
  %{nil}

%meson_build

%install
%meson_install

%find_lang tracker3

chrpath -d %{buildroot}%{_libdir}/libtracker-sparql-3.0.so.0.300.0
chrpath -d %{buildroot}%{_libexecdir}/tracker-xdg-portal-3
chrpath -d %{buildroot}%{_bindir}/tracker3
mkdir -p %{buildroot}/etc/ld.so.conf.d
echo "%{_libdir}/tracker-3.0" > %{buildroot}/etc/ld.so.conf.d/%{name}-%{_arch}.conf

%post
/sbin/ldconfig
%systemd_user_post %{systemd_units}

%preun
%systemd_user_preun %{systemd_units}

%postun
/sbin/ldconfig
%systemd_user_postun_with_restart %{systemd_units}

%files -f tracker3.lang
%license COPYING COPYING.GPL
%doc AUTHORS NEWS README.md
%{_bindir}/tracker3
%{_libexecdir}/tracker3/
%{_libexecdir}/tracker-xdg-portal-3
%dir %{_datadir}/bash-completion
%dir %{_datadir}/bash-completion/completions
%{_datadir}/bash-completion/completions/tracker3
%{_datadir}/dbus-1/services/org.freedesktop.portal.Tracker.service
%{_mandir}/man1/tracker*.1*
%{_userunitdir}/tracker-xdg-portal-3.service
%config(noreplace) /etc/ld.so.conf.d/*

%files -n libtracker-sparql3
%license COPYING COPYING.LGPL
%dir %{_libdir}/girepository-1.0
%{_libdir}/girepository-1.0/Tracker-3.0.typelib
%{_libdir}/libtracker-sparql-3.0.so.0*
%{_libdir}/tracker-3.0/
%{_datadir}/tracker3/
%config(noreplace) /etc/ld.so.conf.d/*

%files devel
%{_includedir}/tracker-3.0/
%{_libdir}/libtracker-sparql-3.0.so
%{_libdir}/pkgconfig/*.pc
%dir %{_libdir}/tracker-3.0
%{_libdir}/tracker-3.0/trackertestutils/
%dir %{_datadir}/vala
%dir %{_datadir}/vala/vapi
%{_datadir}/vala/vapi/tracker-sparql-3.0.*
%dir %{_datadir}/gir-1.0
%{_datadir}/gir-1.0/Tracker-3.0.gir

%files doc
%license docs/reference/COPYING
%dir %{_datadir}/devhelp
%dir %{_datadir}/devhelp/books
%{_datadir}/devhelp/books/Tracker/

%changelog
* Mon Apr 11 2022 lin zhang <lin.zhang@turbolinux.com.cn> - 3.3.0-2
- Add tracker3.yaml

* Mon Mar 28 2022 lin zhang <lin.zhang@turbolinux.com.cn> - 3.3.0-1
- Update to 3.3.0

* Thu Sep 09 2021 wangyue <wangyue92@huawei.com> - 3.0.4-2
- fix rpath error

* Mon Jun 7 2021 weijin deng <weijin.deng@turbolinux.com.cn> - 3.0.4-1
- Package tracker3 init with version 3.0.4
