%global __provides_exclude_from ^%{_libdir}/gnome-connections/
%global __requires_exclude ^(%%(find %{buildroot}%{_libdir}/gnome-connections/ -name '*.so' | xargs -n1 basename | sort -u | paste -s -d '|' -))

%global url_ver %%(echo %{version} | cut -d. -f1)

Name:       gnome-connections
Version:    43.0
Release:    3
Summary:    A remote desktop client for the GNOME desktop environment
License:    GPLv3+
URL:        https://gitlab.gnome.org/gnome/connections/-/wikis/home
Source0:    https://download.gnome.org/sources/gnome-connections/%{url_ver}/%{name}-%{version}.tar.xz

BuildRequires:  desktop-file-utils
BuildRequires:  gcc
BuildRequires:  gettext
BuildRequires:  libappstream-glib
BuildRequires:  meson
BuildRequires:  vala
BuildRequires:  yelp-tools
BuildRequires:  pkgconfig(freerdp2)
BuildRequires:  pkgconfig(glib-2.0)
BuildRequires:  pkgconfig(gtk+-3.0)
BuildRequires:  pkgconfig(gtk-vnc-2.0)
BuildRequires:  pkgconfig(gvncpulse-1.0)
BuildRequires:  pkgconfig(libhandy-1)
BuildRequires:  pkgconfig(libsecret-1)
BuildRequires:  chrpath

Requires:       hicolor-icon-theme
Obsoletes:      connections < 40.0-2
Provides:       connections = %{version}-%{release}
Provides:       bundled(gtk-frdp)
Obsoletes:      remotely < 1.0-6

%description
Connections is a remote desktop client for the GNOME desktop environment.

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

%build
%meson
%meson_build

%install
%meson_install
chrpath -d %{buildroot}%{_bindir}/gnome-connections
mkdir -p %{buildroot}/etc/ld.so.conf.d
echo "%{_libdir}/gnome-connections" > %{buildroot}/etc/ld.so.conf.d/%{name}-%{_arch}.conf

%find_lang gnome-connections --with-gnome

rm -rf %{buildroot}%{_includedir}/gnome-connections/
rm -rf %{buildroot}%{_libdir}/gnome-connections/girepository-1.0/
rm -rf %{buildroot}%{_libdir}/gnome-connections/pkgconfig/
rm -rf %{buildroot}%{_datadir}/gnome-connections/gir-1.0/
rm -rf %{buildroot}%{_datadir}/gnome-connections/vapi/

%check
appstream-util validate-relax --nonet %{buildroot}%{_datadir}/metainfo/org.gnome.Connections.appdata.xml
desktop-file-validate %{buildroot}%{_datadir}/applications/org.gnome.Connections.desktop

%post
/sbin/ldconfig

%postun
/sbin/ldconfig

%files -f gnome-connections.lang
%license COPYING
%doc README.md NEWS
%{_bindir}/gnome-connections
%{_libdir}/gnome-connections/
%{_datadir}/applications/org.gnome.Connections.desktop
%{_datadir}/dbus-1/services/org.gnome.Connections.service
%{_datadir}/glib-2.0/schemas/org.gnome.Connections.gschema.xml
%{_datadir}/icons/hicolor/scalable/apps/org.gnome.Connections.svg
%{_datadir}/icons/hicolor/symbolic/apps/org.gnome.Connections-symbolic.svg
%{_datadir}/metainfo/org.gnome.Connections.appdata.xml
%{_datadir}/mime/packages/org.gnome.Connections.xml
%config(noreplace) /etc/ld.so.conf.d/*

%changelog
* Fri Mar 24 2023 lin zhang <lin.zhang@turbolinux.com.cn> - 43.0-3
- add library path file to /etc/ld.so.conf.d

* Mon Mar 13 2023 lin zhang <lin.zhang@turbolinux.com.cn> - 43.0-2
- remove rpath

* Mon Jan 02 2023 lin zhang <lin.zhang@turbolinux.com.cn> - 43.0-1
- Update to 43.0

* Mon Jun 6 2022 lin zhang <lin.zhang@turbolinux.com.cn> - 42.1.2-1
- Upgrade to 42.1.2

* Mon Mar 28 2022 lin zhang <lin.zhang@turbolinux.com.cn> - 42.0-1
- Initial packaging
