%global commit 136bf1e5aa1746af356f8c369ba39b27981925f3
%global shortcommit %(c=%{commit}; echo ${c:0:7})
%global commitdate 20220722

Name:           fdm
Version:        2.2
Release:        1%{?dist}
Summary:        Simple, lightweight tool of fetching, filtering and delivering emails
License:        ISC
URL:            https://github.com/nicm/fdm/
Source0:        https://github.com/nicm/fdm/archive/%{version}/fdm-%{version}.tar.gz
BuildRequires:  byacc, automake, gcc, make
BuildRequires:  libtdb-devel, openssl-devel, zlib-devel, pcre-devel
Requires(pre):	shadow-utils
Requires(postun): shadow-utils

%description
fdm is a program to fetch mail and deliver it in various ways depending on a
user-supplied ruleset. Mail may be fetched from stdin, IMAP or POP3 servers, or
from local maildirs, and filtered based on whether it matches a regexp, its
size or age, or the output of a shell command. It can be rewritten by an
external process, dropped, left on the server or delivered into maildirs,
mboxes, to a file or pipe, or any combination.

fdm is designed to be lightweight but powerful, with a compact but clear
configuration syntax. It is primarily designed for single-user uses but may
also be configured to deliver mail in a multi-user setup. In this case, it uses
privilege separation to minimise the amount of code running as the root user.

%prep
%setup -q -n fdm-%{version}

%build
./autogen.sh
%configure --enable-debug
exit
#After courier-authlib is packaged I'll enable COURIER=1
%make_build DEBUG=1 PCRE=1

%install
%make_install PREFIX=%{_prefix}

%pre
getent group _fdm >/dev/null || groupadd -r _fdm
getent passwd _fdm >/dev/null || \
    useradd -r -g _fdm -d /var/empty -s /sbin/nologin \
    -c "fdm mail fetching program" _fdm
exit 0

%postun
getent group _fdm >/dev/null && groupdel _fdm
getent passwd _fdm >/dev/null && userdel _fdm
exit 0

%files
%doc CHANGES README MANUAL examples/*
%{_bindir}/%{name}
%{_mandir}/man1/%{name}.1*
%{_mandir}/man5/%{name}.conf.5*

%changelog
* Mon Jan 09 2023 Charles Lee <lchh@fedoraproject.org> - 2.2
- Update to 2.2.

* Fri Jun 24 2022 Charles Lee <lchh@fedoraproject.org> - 2.1
- Update to latest upstream commit.

* Wed Feb 03 2016 Fedora Release Engineering <releng@fedoraproject.org> - 1.9-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Wed Sep 23 2015 Christopher Meng <rpm@cicku.me> - 1.9-1
- Update to 1.9

* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.8-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Wed Jan 28 2015 Christopher Meng <rpm@cicku.me> - 1.8-1
- Update to 1.8

* Sat Aug 16 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.7-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild

* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.7-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Wed Jul 31 2013 Christopher Meng <rpm@cicku.me> - 1.7-3
- Correct the license.
- Fix description.

* Tue Jul 30 2013 Christopher Meng <rpm@cicku.me> - 1.7-2
- Add missing BR.

* Sat Feb 16 2013 Christopher Meng <rpm@cicku.me> - 1.7-1
- Update to new version.
- Cleanup old stuffs.

* Mon Dec 29 2008 Christopher Meng <cickumqt-NOSPAM@gmail.com> - 1.6-1
- Initial Package.