%global debug_package %{nil}
%global tarball_version %%(echo %{version} | tr '~' '-')

Name: himalaya
Version: 1.0.0
Release: 1%{?dist}
Summary: CLI to manage your emails

License: ISC
URL: https://github.com/soywod/himalaya
Source0: %{url}/archive/v%{tarball_version}/%{name}-%{tarball_version}.tar.gz

BuildRequires: desktop-file-utils
BuildRequires: gcc
%if 0%{?el8} || 0%{?el9}
%else
BuildRequires: rust >= 1.67
BuildRequires: cargo >= 1.67
%endif

%description
CLI to manage your emails, based on the pimalaya-email library.


%prep
%autosetup -n %{name}-%{tarball_version}
%if 0%{?el8} || 0%{?el9}
curl https://sh.rustup.rs -sSf | sh -s -- --profile minimal -y
%endif


%install
export CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_OPT_LEVEL=3
%if 0%{?el8} || 0%{?el9}
source "$HOME/.cargo/env"
%endif
RUSTFLAGS='-C strip=symbols' cargo install --root=%{buildroot}%{_prefix} --path=.
rm -f %{buildroot}%{_prefix}/.crates.toml \
    %{buildroot}%{_prefix}/.crates2.json

# Desktop file
install -D -p -m 0755 assets/%{name}.desktop %{buildroot}%{_datadir}/applications/%{name}.desktop


%check
# warning: value "Application;Network" for key "Categories" in group "Desktop Entry" contains a deprecated value "Application"
# desktop-file-validate %{buildroot}%{_datadir}/applications/*.desktop


%files
%license LICENSE
%doc README.md CONTRIBUTING.md CHANGELOG.md
%{_bindir}/%{name}
%{_datadir}/applications/*.desktop


%changelog
* Mon Dec 09 2024 Artem Polishchuk <ego.cordatus@gmail.com> - 1.0.0-1
- chore: Update to latest release

* Sun Apr 21 2024 Artem Polishchuk <ego.cordatus@gmail.com> - 1.0.0~beta.4-1
- chore: Update to latest release

* Sun Feb 25 2024 Artem Polishchuk <ego.cordatus@gmail.com> - 1.0.0~beta.3-1
- chore: Update to latest release

* Thu Feb 08 2024 Artem Polishchuk <ego.cordatus@gmail.com> - 1.0.0~beta.2-1
- chore: Update to latest release

* Mon Aug 28 2023 Artem Polishchuk <ego.cordatus@gmail.com> - 0.9.0-1
- chore: Update to 0.9.0

* Tue Aug 08 2023 Artem Polishchuk <ego.cordatus@gmail.com> - 0.8.4-1
- Initial package