%define glib2_version 2.46
%define gtk3_version 3.16
%define gcr_version 3.4
%define gtk_doc_version 1.9
%define goa_version 3.8
%define libsecret_version 0.5
%define libgdata_version 0.15.1
%define libgweather_version 4.0.0
%define libical_version 3.0.7
%define libsoup_version 3.0.6
%define nss_version 3.14
%define sqlite_version 3.7.17
%define webkit2gtk_version 2.28.0
%define json_glib_version 1.0.4

%define credential_modules_dir %{_libdir}/evolution-data-server/credential-modules
%define camel_provider_dir %{_libdir}/evolution-data-server/camel-providers
%define ebook_backends_dir %{_libdir}/evolution-data-server/addressbook-backends
%define ecal_backends_dir %{_libdir}/evolution-data-server/calendar-backends
%define modules_dir %{_libdir}/evolution-data-server/registry-modules
%define uimodules_dir %{_libdir}/evolution-data-server/ui-modules

%global dbus_service_name_address_book	org.gnome.evolution.dataserver.AddressBook10
%global dbus_service_name_calendar	org.gnome.evolution.dataserver.Calendar8
%global dbus_service_name_sources	org.gnome.evolution.dataserver.Sources5
%global dbus_service_name_user_prompter	org.gnome.evolution.dataserver.UserPrompter0

%if "%{?_eds_dbus_services_prefix}" != ""
%global dbus_service_name_address_book	%{?_eds_dbus_services_prefix}.%{dbus_service_name_address_book}
%global dbus_service_name_calendar	%{?_eds_dbus_services_prefix}.%{dbus_service_name_calendar}
%global dbus_service_name_sources	%{?_eds_dbus_services_prefix}.%{dbus_service_name_sources}
%global dbus_service_name_user_prompter	%{?_eds_dbus_services_prefix}.%{dbus_service_name_user_prompter}
%endif

%{!?with_docs: %global with_docs 1}

Name:           evolution-data-server
Version:        3.44.3
Release:        1
Summary:        Backend data server for Evolution
License:        LGPLv2+
URL:            https://wiki.gnome.org/Apps/Evolution
Source:         http://download.gnome.org/sources/%{name}/3.44/%{name}-%{version}.tar.xz

Provides:       evolution-webcal = %{version}
Obsoletes:      evolution-webcal < 2.24.0 compat-evolution-data-server310-libcamel < 3.12

Recommends:     pinentry-gtk
Requires:       dconf
Requires:       %{name}-langpacks = %{version}-%{release}

BuildRequires:  make cmake gcc gcc-c++ gettext gperf libicu-devel sendmail systemd vala vala-devel nspr-devel
BuildRequires:  libcanberra-devel libicu-devel openldap-devel >= 2.0.11  krb5-devel >= 1.11
BuildRequires:  gtk-doc >= %{gtk_doc_version} intltool >= 0.35.5 
BuildRequires:  libdb-devel perl-generators gcr-devel >= %{gcr_version} glib2-devel >= %{glib2_version}
BuildRequires:  libgweather-devel >= %{libgweather_version} gtk3-devel >= %{gtk3_version}
BuildRequires:  libgdata-devel >= %{libgdata_version} libical-devel >= %{libical_version} libsecret-devel >= %{libsecret_version}
BuildRequires:  libsoup3-devel >= %{libsoup_version}  nss-devel >= %{nss_version}
BuildRequires:  libxml2-devel sqlite-devel >= %{sqlite_version}  json-glib-devel >= %{json_glib_version}
BuildRequires:  pkgconfig(webkit2gtk-4.0) >= %{webkit2gtk_version} pkgconfig(goa-1.0) >= %{goa_version}

%description
The evolution-data-server package provides a personal information management application that provides integrated
mail, calendaring and address book functionality. The evolution-data-server package provides a single database for
common, desktop-wide information, such as a user's address book or calendar events.

%package        devel
Summary:        Tests case and libraries for evolution-data-server development
Requires:       %{name} = %{version}-%{release}

Requires:       libgdata-devel >= %{libgdata_version} libgweather-devel >= %{libgweather_version}
Requires:       libical-devel >= %{libical_version} libsecret-devel >= %{libsecret_version} libsoup3-devel >= %{libsoup_version}
Requires:       sqlite-devel >= %{sqlite_version} json-glib-devel >= %{json_glib_version}
Requires:       pkgconfig(webkit2gtk-4.0) >= %{webkit2gtk_version} pkgconfig(goa-1.0) >= %{goa_version}

Provides:       evolution-data-server-tests
Obsoletes:      evolution-data-server-tests < %{version}-%{release}

%description    devel
This package contains the tests case and libraries needed for the evolution-data-server library.

%package        langpacks
Summary:        Translations for evolution-data-server
BuildArch:      noarch
Requires:       %{name} = %{version}-%{release}

%description    langpacks
This package contains translations for evolution-data-server.

%package        doc
Summary:        Documentation files for evolution-data-server
BuildArch:      noarch

%description    doc
This package contains developer documentation for evolution-data-server..

%package        perl
Summary:        Supplemental utilities that require Perl
Requires:       %{name} = %{version}-%{release}
Requires:       perl-interpreter

%description    perl
This package contains supplemental utilities for evolution-data-server that require Perl.

%prep
%autosetup -p1

%build
if ! pkg-config --exists nss; then
  echo "Unable to find suitable version of nss to use!"
  exit 1
fi

export CPPFLAGS="-I%{_includedir}/et"
export CFLAGS="$RPM_OPT_FLAGS -DLDAP_DEPRECATED -fPIC -I%{_includedir}/et -Wno-deprecated-declarations"

%cmake -G "Unix Makefiles" -DENABLE_MAINTAINER_MODE=OFF -DWITH_LIBDB=OFF \
        -DENABLE_FILE_LOCKING=fcntl -DENABLE_DOT_LOCKING=OFF -DENABLE_INTROSPECTION=ON \
        -DWITH_SYSTEMDUSERUNITDIR=%{_userunitdir} \
        %if "%{?_eds_dbus_services_prefix}" != ""
        -DDBUS_SERVICES_PREFIX=%{?_eds_dbus_services_prefix} \
        %endif
        -DENABLE_VALA_BINDINGS=ON -DENABLE_INSTALLED_TESTS=OFF -DWITH_OPENLDAP=ON -DWITH_KRB5=ON \
        -DENABLE_SMIME=ON -DENABLE_LARGEFILE=ON -DENABLE_SMIME=ON -DENABLE_GTK_DOC=ON -DWITH_GWEATHER4=ON


sed -i "300 d" docs/reference/evolution-data-server/evolution-data-server-docs.sgml.in
%make_build

%install
%make_install

mkdir %{buildroot}%{_libdir}/evolution-data-server/ui-modules || :

find %{buildroot} -name '*.so.*' -exec chmod +x {} \;

%find_lang %{name}

%post -p /sbin/ldconfig

%postun
/sbin/ldconfig
if [ $1 -eq 0 ] ; then
    glib-compile-schemas %{_datadir}/glib-2.0/schemas &>/dev/null || :
fi

%posttrans
glib-compile-schemas %{_datadir}/glib-2.0/schemas &>/dev/null || :

%find_lang %{name}

%files
%license COPYING
%doc README ChangeLog NEWS
%{_libdir}/libcamel-1.2.so.63
%{_libdir}/libcamel-1.2.so.63.0.0
%{_libdir}/libebackend-1.2.so.10
%{_libdir}/libebackend-1.2.so.10.0.0
%{_libdir}/libebook-1.2.so.20
%{_libdir}/libebook-1.2.so.20.1.3
%{_libdir}/libebook-contacts-1.2.so.3
%{_libdir}/libebook-contacts-1.2.so.3.0.0
%{_libdir}/libecal-2.0.so.1
%{_libdir}/libecal-2.0.so.1.0.0
%{_libdir}/libedata-book-1.2.so.26
%{_libdir}/libedata-book-1.2.so.26.0.0
%{_libdir}/libedata-cal-2.0.so.1
%{_libdir}/libedata-cal-2.0.so.1.0.0
%{_libdir}/libedataserver-1.2.so.26
%{_libdir}/libedataserver-1.2.so.26.0.0
%{_libdir}/libedataserverui-1.2.so.3
%{_libdir}/libedataserverui-1.2.so.3.0.0

%{_libdir}/girepository-1.0/Camel-1.2.typelib
%{_libdir}/girepository-1.0/EBackend-1.2.typelib
%{_libdir}/girepository-1.0/EBook-1.2.typelib
%{_libdir}/girepository-1.0/EBookContacts-1.2.typelib
%{_libdir}/girepository-1.0/ECal-2.0.typelib
%{_libdir}/girepository-1.0/EDataBook-1.2.typelib
%{_libdir}/girepository-1.0/EDataCal-2.0.typelib
%{_libdir}/girepository-1.0/EDataServer-1.2.typelib
%{_libdir}/girepository-1.0/EDataServerUI-1.2.typelib

%{_libexecdir}/camel-gpg-photo-saver
%{_libexecdir}/camel-index-control-1.2
%{_libexecdir}/camel-lock-helper-1.2
%{_libexecdir}/evolution-addressbook-factory
%{_libexecdir}/evolution-addressbook-factory-subprocess
%{_libexecdir}/evolution-calendar-factory
%{_libexecdir}/evolution-calendar-factory-subprocess
%{_libexecdir}/evolution-scan-gconf-tree-xml
%{_libexecdir}/evolution-source-registry
%{_libexecdir}/evolution-user-prompter

%dir %{_libexecdir}/evolution-data-server
%{_libexecdir}/evolution-data-server/addressbook-export
%{_libexecdir}/evolution-data-server/evolution-alarm-notify
%{_libexecdir}/evolution-data-server/list-sources

%{_sysconfdir}/xdg/autostart/org.gnome.Evolution-alarm-notify.desktop
%{_datadir}/applications/org.gnome.Evolution-alarm-notify.desktop

# GSettings schemas:
%{_datadir}/GConf/gsettings/evolution-data-server.convert
%{_datadir}/glib-2.0/schemas/org.gnome.Evolution.DefaultSources.gschema.xml
%{_datadir}/glib-2.0/schemas/org.gnome.evolution-data-server.gschema.xml
%{_datadir}/glib-2.0/schemas/org.gnome.evolution-data-server.addressbook.gschema.xml
%{_datadir}/glib-2.0/schemas/org.gnome.evolution-data-server.calendar.gschema.xml
%{_datadir}/glib-2.0/schemas/org.gnome.evolution.eds-shell.gschema.xml
%{_datadir}/glib-2.0/schemas/org.gnome.evolution.shell.network-config.gschema.xml

%{_datadir}/evolution-data-server
%{_datadir}/dbus-1/services/%{dbus_service_name_address_book}.service
%{_datadir}/dbus-1/services/%{dbus_service_name_calendar}.service
%{_datadir}/dbus-1/services/%{dbus_service_name_sources}.service
%{_datadir}/dbus-1/services/%{dbus_service_name_user_prompter}.service
%{_datadir}/pixmaps/evolution-data-server

%{_userunitdir}/evolution-addressbook-factory.service
%{_userunitdir}/evolution-calendar-factory.service
%{_userunitdir}/evolution-source-registry.service
%{_userunitdir}/evolution-user-prompter.service

%dir %{_libdir}/evolution-data-server
%dir %{credential_modules_dir}
%dir %{camel_provider_dir}
%dir %{ebook_backends_dir}
%dir %{ecal_backends_dir}
%dir %{modules_dir}
%dir %{uimodules_dir}

%{_libdir}/evolution-data-server/libedbus-private.so

# Camel providers:
%{camel_provider_dir}/libcamelimapx.so
%{camel_provider_dir}/libcamelimapx.urls

%{camel_provider_dir}/libcamellocal.so
%{camel_provider_dir}/libcamellocal.urls

%{camel_provider_dir}/libcamelnntp.so
%{camel_provider_dir}/libcamelnntp.urls

%{camel_provider_dir}/libcamelpop3.so
%{camel_provider_dir}/libcamelpop3.urls

%{camel_provider_dir}/libcamelsendmail.so
%{camel_provider_dir}/libcamelsendmail.urls

%{camel_provider_dir}/libcamelsmtp.so
%{camel_provider_dir}/libcamelsmtp.urls

# e-d-s extensions:
%{credential_modules_dir}/module-credentials-goa.so
%{ebook_backends_dir}/libebookbackendcarddav.so
%{ebook_backends_dir}/libebookbackendfile.so
%{ebook_backends_dir}/libebookbackendldap.so
%{ecal_backends_dir}/libecalbackendcaldav.so
%{ecal_backends_dir}/libecalbackendcontacts.so
%{ecal_backends_dir}/libecalbackendfile.so
%{ecal_backends_dir}/libecalbackendgtasks.so
%{ecal_backends_dir}/libecalbackendhttp.so
%{ecal_backends_dir}/libecalbackendweather.so
%{ecal_backends_dir}/libecalbackendwebdavnotes.so
%{modules_dir}/module-cache-reaper.so
%{modules_dir}/module-google-backend.so
%{modules_dir}/module-gnome-online-accounts.so
%{modules_dir}/module-oauth2-services.so
%{modules_dir}/module-outlook-backend.so
%{modules_dir}/module-secret-monitor.so
%{modules_dir}/module-trust-prompt.so
%{modules_dir}/module-webdav-backend.so
%{modules_dir}/module-yahoo-backend.so

%files devel
%{_includedir}/evolution-data-server
%{_libdir}/libcamel-1.2.so
%{_libdir}/libebackend-1.2.so
%{_libdir}/libebook-1.2.so
%{_libdir}/libebook-contacts-1.2.so
%{_libdir}/libecal-2.0.so
%{_libdir}/libedata-book-1.2.so
%{_libdir}/libedata-cal-2.0.so
%{_libdir}/libedataserver-1.2.so
%{_libdir}/libedataserverui-1.2.so
%{_libdir}/pkgconfig/camel-1.2.pc
%{_libdir}/pkgconfig/evolution-data-server-1.2.pc
%{_libdir}/pkgconfig/libebackend-1.2.pc
%{_libdir}/pkgconfig/libebook-1.2.pc
%{_libdir}/pkgconfig/libebook-contacts-1.2.pc
%{_libdir}/pkgconfig/libecal-2.0.pc
%{_libdir}/pkgconfig/libedata-book-1.2.pc
%{_libdir}/pkgconfig/libedata-cal-2.0.pc
%{_libdir}/pkgconfig/libedataserver-1.2.pc
%{_libdir}/pkgconfig/libedataserverui-1.2.pc
%{_datadir}/gir-1.0/Camel-1.2.gir
%{_datadir}/gir-1.0/EBackend-1.2.gir
%{_datadir}/gir-1.0/EBook-1.2.gir
%{_datadir}/gir-1.0/EBookContacts-1.2.gir
%{_datadir}/gir-1.0/ECal-2.0.gir
%{_datadir}/gir-1.0/EDataBook-1.2.gir
%{_datadir}/gir-1.0/EDataCal-2.0.gir
%{_datadir}/gir-1.0/EDataServer-1.2.gir
%{_datadir}/gir-1.0/EDataServerUI-1.2.gir
%{_datadir}/vala/vapi/camel-1.2.deps
%{_datadir}/vala/vapi/camel-1.2.vapi
%{_datadir}/vala/vapi/libebackend-1.2.deps
%{_datadir}/vala/vapi/libebackend-1.2.vapi
%{_datadir}/vala/vapi/libebook-1.2.deps
%{_datadir}/vala/vapi/libebook-1.2.vapi
%{_datadir}/vala/vapi/libebook-contacts-1.2.deps
%{_datadir}/vala/vapi/libebook-contacts-1.2.vapi
%{_datadir}/vala/vapi/libecal-2.0.deps
%{_datadir}/vala/vapi/libecal-2.0.vapi
%{_datadir}/vala/vapi/libedata-book-1.2.deps
%{_datadir}/vala/vapi/libedata-book-1.2.vapi
%{_datadir}/vala/vapi/libedata-cal-2.0.deps
%{_datadir}/vala/vapi/libedata-cal-2.0.vapi
%{_datadir}/vala/vapi/libedataserver-1.2.deps
%{_datadir}/vala/vapi/libedataserver-1.2.vapi
%{_datadir}/vala/vapi/libedataserverui-1.2.deps
%{_datadir}/vala/vapi/libedataserverui-1.2.vapi

%files langpacks -f %{name}.lang

%if %{with_docs}
%files doc
%{_datadir}/gtk-doc/html/*
%endif

%files perl
%{_libexecdir}/evolution-data-server/csv2vcard

%changelog
* Mon Jul 18 2022 lin zhang <lin.zhang@turbolinux.com.cn> - 3.44.3-1
- Update to 3.44.3

* Thu Jun 16 2022 lin zhang <lin.zhang@turbolinux.com.cn> - 3.44.2-3
- replace to libsoup3-devel

* Wed Jun 15 2022 wenlong ding <wenlong.ding@turbolinux.com.cn> 3.44.2-2
- Change libgweather version to 4.0.0

* Mon Jun 13 2022 lin zhang <lin.zhang@turbolinux.com.cn> - 3.44.2-1
- Update to 3.44.2

* Mon Jun 7 2021 weijin deng <weijin.deng@turbolinux.com.cn> - 3.38.4-2
- Update Release, Requires, to solve this rmp package depends on itsself when install

* Mon May 31 2021 weijin deng <weijin.deng@turbolinux.com.cn> - 3.38.4-1
- Upgrade to 3.38.4
- Update Version, Release, Source, BuildRequires, Requires, Obsoletes
- Update stage 'install', use sed delete one line that will cause fault

* Tue Dec 24 2019 openEuler Buildteam <buildteam@openeuler.org> - 3.30.1-3
- delete redundant files

* Sat Sep 21 2019 dongjian <dongjian13@huawei.com> - 3.30.1-2
- Package init
