%if 0%{!?_userunitdir:1}
%define _userunitdir /usr/lib/systemd/user/
%endif
%if 0%{!?mkrel:1}
%define mkrel(c) %{1}%{?dist}
%endif

Name: goimapnotify
Version: 2.4
Release: %mkrel 1
URL: https://gitlab.com/shackra/goimapnotify
Group: Applications/Internet
License: GPLv3+
Summary: Execute scripts on IMAP mailbox changes (new/deleted/updated messages) using IDLE, golang version

Source0: https://gitlab.com/shackra/goimapnotify/-/archive/%{version}/%{name}-%{version}.tar.bz2
Source1: %{name}-%{version}-vendor.tar.xz

BuildRequires: golang >= 1.20
BuildRequires: elfutils

%description
%summary.

Please read the CHANGELOG file to know what's new.

This application is mostly compatible with the configuration of imapnotify made with Python (be sure to change password_eval to passwordCMD).

%prep
%autosetup -p1 -a1

%build
go build -buildmode=pie -ldflags -linkmode=external -mod=vendor
eu-elfcompress --type=none %{name}

%install
install -Dpm755 -t %{buildroot}%{_bindir} %{name}
install -Dpm644 -t %{buildroot}%{_userunitdir} %{name}@.service

%files
%doc CHANGELOG.md README.md
%license LICENSE
%{_bindir}/%{name}
%{_userunitdir}/%{name}@.service