%global extdir          %{_datadir}/gnome-shell/extensions/rclone-manager@germanztz.com
%global gschemadir      %{_datadir}/glib-2.0/schemas

%global giturl          https://github.com/germanztz/gnome-shell-extension-rclone-manager
#%%global commit          2e8501fc0a144357353c42a84d74756f2831d488
#%%global commit_short    %%(c=%%{commit}; echo ${c:0:7})
#%%global commit_date     20221001

Name:           gnome-shell-extension-rclone-manager
%if 0%{?commit:1}
Version:        43.0^20230219g0e53bd3
%else
Version:        43.0
%endif
Release:        1%{?dist}
Summary:        Adds an rclone indicator to the top panel

License:        GPLv2
URL:            https://github.com/germanztz/gnome-shell-extension-rclone-manager
%if 0%{?commit:1}
Source0:        %{giturl}/archive/%{commit}.tar.gz
%else
Source0:        %{giturl}/arcive/v%{version}.tar.gz
%endif
Patch0:         metadata-shell-version-patch.patch

BuildArch:      noarch

BuildRequires:  gettext
BuildRequires:  make
BuildRequires:  %{_bindir}/glib-compile-schemas

Requires:       rclone
Requires:       gnome-shell-extension-common
%if 0%{?fedora}
Requires:       libdbusmenu-gtk3
%endif

%description
Is like Dropbox sync client but for more than 30 services, adds an indicator to
the top panel so you can manage the rclone profiles configured in your system,
perform operations such as mount as remote, watch for file modifications,
sync with remote storage, navigate it's main folder. Also, it shows the status
of each profile so you can supervise the operations, and provides an easy access
log of events. Backup and restore the rclone configuration file, so you won't
have to configure all your devices one by one

%prep
%if 0%{?commit:1}
%autosetup -n gnome-shell-extension-rclone-manager-%{commit} -p 0
%else
%autosetup -n gnome-shell-extension-rclone-manager-%{version} -p 0
%endif

%build
%make_build

%install
%make_install
mkdir -p %{buildroot}%{extdir} %{buildroot}%{gschemadir} %{buildroot}%{_datadir}/locale
cp -fr ./* %{buildroot}%{extdir}
install -m 644 %{buildroot}%{extdir}/schemas/*gschema.xml %{buildroot}%{gschemadir}
mv -f %{buildroot}%{extdir}/locale %{buildroot}%{_datadir}/
%{__rm} -fr %{buildroot}%{extdir}/{DEVELOP*,LICENSE*,Makefile,README*,Vagrantfile,docs,locale,package*,schemas}

%if 0%{?rhel} && 0%{?rhel} <= 7
%postun
if [ $1 -eq 0 ] ; then
  %{_bindir}/glib-compile-schemas %{gschemadir} &> /dev/null || :
fi

%posttrans
%{_bindir}/glib-compile-schemas %{gschemadir} &> /dev/null || :
%endif

%files
%license LICENSE.rst
%doc README.md docs
%{extdir}
%{gschemadir}/*gschema.xml
%{_datadir}/locale

%changelog
* Wed Apr 19 2023 Astrawan Wayan <astrawan@icloud.com> - 43.0-1
- Bump version 43.0-1
* Sun Nov 13 2022 Astrawan Wayan <astrawan@icloud.com> - 42.2-1
- Initial import