%global real_name filter-spfgreylist
%global debug_package %{nil}

Summary:	OpenSMTPD SPF-aware greylisting filter
Name:		opensmtpd-%{real_name}
Version:	1.0.0
Release:	1%{?dist}

License:	ISC
URL:		https://github.com/poolpOrg/filter-spfgreylist

Source0:	https://github.com/poolpOrg/filter-spfgreylist/archive/refs/tags/v%{version}.tar.gz#/%{real_name}-%{version}.tar.gz



BuildRequires:	golang >= 1.17
Requires: opensmtpd >= 6.6
Provides: bundled(golang(blitiri.com.ar/go/spf)) = 1.5.1

%description
This filter implements greylisting, allowing OpenSMTPD to temporarily reject
sessions of clients it has not seen before. Unlike many implementations,
this one is SPF-aware so it will properly handle greylisting for domains
doing relaying through multiple MX, as long as they publish a valid SPF record.



%prep
%autosetup -p1 -n %{real_name}-%{version}

%build

export CGO_CPPFLAGS="${CPPFLAGS}"
export CGO_CFLAGS="${CFLAGS}"
export CGO_CXXFLAGS="${CXXFLAGS}"
export CGO_LDFLAGS="${LDFLAGS}"
export GOFLAGS="-buildmode=pie -trimpath -mod=readonly -modcacherw"
export GOPATH="`pwd`/.godeps"
#go env -w GO111MODULE=off
go build -o %{real_name}


%install
mkdir -p %{buildroot}/{%{_libexecdir}/opensmtpd,%{_mandir}/man8}
install -D %{real_name} -t %{buildroot}/%{_libexecdir}/opensmtpd


%files
%doc README.md
%if 0%{?rhel} >= 8
%license LICENSE
%else
%doc LICENSE
%endif
%{_libexecdir}/opensmtpd/%{real_name}


%changelog
* Wed Feb 28 2024 Raven <raven@sysadmins.ws> - 1.0.0-1
- Initial release
