%global appstream_version 0.14.0
%global flatpak_version 1.5.1
%global fwupd_version 1.3.3
%global glib2_version 2.61.1
%global gtk4_version 4.9.2
%global json_glib_version 1.2.0
%global libadwaita_version 1.3
%global libxmlb_version 0.1.7
%global packagekit_version 1.1.1

%define gs_plugin_version 20

%global __provides_exclude_from ^%{_libdir}/%{name}/plugins-%{gs_plugin_version}/.*\\.so.*$

Name:                gnome-software
Version:             44.5
Release:             1
Summary:             GNOME software Store
License:             GPLv2+
URL:                 https://wiki.gnome.org/Apps/Software
Source0:             https://download.gnome.org/sources/gnome-software/44/%{name}-%{version}.tar.xz

BuildRequires:       gettext libxslt docbook-style-xsl desktop-file-utils gtk-doc
BuildRequires:       gnome-desktop3-devel gspell-devel polkit-devel ostree-devel rpm-ostree-devel
BuildRequires:       gsettings-desktop-schemas-devel gnome-online-accounts-devel
BuildRequires:       libappstream-glib-devel >= 0.7.14-3 libdnf-devel libsoup-devel
BuildRequires:       libgudev1-devel valgrind-devel rpm-devel sysprof-devel
BuildRequires:       gcc gcc-c++ meson appstream-devel >= %{appstream_version}
BuildRequires:       pkgconfig(gtk4) >= %{gtk4_version}
BuildRequires:       fwupd-devel >= %{fwupd_version}
BuildRequires:       glib2-devel >= %{glib2_version}
BuildRequires:       json-glib-devel >= %{json_glib_version}
BuildRequires:       pkgconfig(libadwaita-1) >= %{libadwaita_version}
BuildRequires:       libxmlb-devel >= %{libxmlb_version}
BuildRequires:       PackageKit-glib-devel >= %{packagekit_version}
BuildRequires:       flatpak-devel >= %{flatpak_version}
BuildRequires:       chrpath
BuildRequires:       sysprof-devel
BuildRequires:       pkgconfig(malcontent-0)

Requires:            epiphany-runtime
Requires:            flatpak%{?_isa} >= %{flatpak_version}
Requires:            flatpak-libs >= %{flatpak_version}
Requires:            fwupd%{?_isa} >= %{fwupd_version}
Requires:            glib2%{?_isa} >= %{glib2_version}
Requires:            json-glib%{?_isa} >= %{json_glib_version}
Requires:            libxmlb%{?_isa} >= %{libxmlb_version}
Requires:            PackageKit%{?_isa} >= %{packagekit_version}
Requires:            gnome-desktop3 >= 3.18.0 gnome-menus gsettings-desktop-schemas
Requires:            gtk3 >= 3.22.4 iso-codes libappstream-glib >= 0.7.14-3
Requires:            librsvg2 snapd-login-service
Requires:            rpm-ostree%{?_isa}
Provides:            gnome-software-rpm-ostree = %{version}-%{release}
Provides:            gnome-software-snap = %{version}-%{release}
Provides:            gnome-software-editor = %{version}-%{release}
Obsoletes:           gnome-software-snap < %{version}-%{release}
Obsoletes:           gnome-software-editor < 3.35.1
Supplements:         (gnome-software%{?_isa} and rpm-ostree%{?_isa})

%description
AppStore like management of Application fir your GNOME Desktop.

%package             devel
Summary:             Development files for the GNOME software store
Requires:            gnome-software = %{version}-%{release}
%description devel
This subpackage contains the header files for developing GNOME software store plugins.

%package_help

%prep
%autosetup -n gnome-software-%{version} -p1

%build
%meson \
    -Dsnap=false \
    -Dgudev=true \
    -Dpackagekit=true \
    -Dpackagekit_autoremove=true \
    -Dexternal_appstream=false \
    -Drpm_ostree=true \
    -Dsoup2=true \
    -Dtests=false \
    -Dmalcontent=true \
    -Dwebapps=false \
    -Dhardcoded_foss_webapps=false \
    -Dhardcoded_proprietary_webapps=false
%meson_build

%install
%meson_install

rm %{buildroot}%{_libdir}/gnome-software/plugins-%{gs_plugin_version}/libgs_plugin_dpkg.so

desktop-file-edit %{buildroot}%{_datadir}/applications/org.gnome.Software.desktop \
    --set-key=X-AppInstall-Package --set-value=%{name}
install -d %{buildroot}%{_datadir}/gnome-software/backgrounds

%delete_la_and_a

%find_lang %name --with-gnome

chrpath -d %{buildroot}%{_libdir}/%{name}/plugins-%{gs_plugin_version}/libgs_plugin_rpm-ostree.so
chrpath -d %{buildroot}%{_libexecdir}/gnome-software-cmd
chrpath -d %{buildroot}%{_bindir}/%{name}

mkdir -p %{buildroot}/etc/ld.so.conf.d
echo "%{_libdir}/%{name}" > %{buildroot}/etc/ld.so.conf.d/%{name}-%{_arch}.conf
#echo "%{_libdir}/rpm-ostree" > %{buildroot}/etc/ld.so.conf.d/%{name}-%{_arch}.conf

%check
desktop-file-validate %{buildroot}%{_datadir}/applications/*.desktop

%post
/sbin/ldconfig

%postun
/sbin/ldconfig

%files -f gnome-software.lang
%license COPYING
%{_bindir}/gnome-software
%{_datadir}/applications/*.desktop
%{_datadir}/icons/hicolor/*/*/*.svg
%{_datadir}/gnome-software/backgrounds/
%{_datadir}/metainfo/*.xml
%{_libdir}/gnome-software/plugins-%{gs_plugin_version}/*.so
%{_libdir}/gnome-software/libgnomesoftware.so.%{gs_plugin_version}
%{_sysconfdir}/xdg/autostart/org.gnome.Software.desktop
%{_datadir}//swcatalog/xml/org.gnome.Software.Curated.xml
%{_datadir}/swcatalog/xml/org.gnome.Software.Featured.xml
%{_datadir}/dbus-1/services/org.freedesktop.PackageKit.service
%{_datadir}/dbus-1/services/org.gnome.Software.service
%{_datadir}/gnome-shell/search-providers/org.gnome.Software-search-provider.ini
%{_datadir}/glib-2.0/schemas/org.gnome.software.gschema.xml
%{_libexecdir}/{gnome-software-cmd,gnome-software-restarter}
%config(noreplace) /etc/ld.so.conf.d/*

%files devel
%{_libdir}/gnome-software/libgnomesoftware.so
%{_libdir}/pkgconfig/gnome-software.pc
%{_includedir}/gnome-software/*.h
%dir %{_datadir}/doc/gnome-software
%{_datadir}/gtk-doc/html/gnome-software

%files help
%doc AUTHORS README.md
%{_datadir}/doc/
%{_mandir}/man1/gnome-software.1.*

%changelog
* Mon Nov 27 2023 lwg <liweiganga@uniontech.com> - 44.5-1
- update to version 44.5

* Thu Mar 2 2023 zhuang li  <zhuang.li@turbolinux.com.cn> - 43.2-2
- Modified profile comments  43.2-2

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

* Wed Aug 24 2022 caodongxia <caodongxia@h-partners.com> -42.2-2
- Remove rpath

* Tue Jun 28 2022 weijin deng <weijin.deng@turbolinux.com.cn> - 42.2-1
- Update to 42.2

* Tue Mar 8 2022 weijin deng <weijin.deng@turbolinux.com.cn> - 3.38.2-2
- Remove requires "appstream-data" whose repository isn't completely open and free

* Fri Jun 18 2021 weijin deng <weijin.deng@turbolinux.com.cn> - 3.38.2-1
- Upgrade to 3.38.2
- Delete all two patches that existed in this version
- Add 0001-Revert-packagekit-Avoid-600000-allocations-when-comp.patch
- Temporarily disabled snap and rpm_ostree option

* Tue May 18 2021 lin.zhang <lin.zhang@turbolinux.com.cn> - 3.30.6-7
- add BuildRequires gcc gcc-c++

* Fri Apr 24 2020 wangyue<wangyue92@huawei.com> - 3.30.6-6
- package init
