aboutsummaryrefslogtreecommitdiffstats
path: root/rpm/rspamd.spec
blob: 663fa092913997eb083e1f075d3cb16c80aab190 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
%if 0%{getenv:ASAN}
Name:             rspamd-asan
Conflicts:        rspamd
%else
Name:             rspamd
Conflicts:        rspamd-asan
%endif
Provides:         rspamd
Version:          3.2
Release:          1
Summary:          Rapid spam filtering system
Group:            System Environment/Daemons
License:          Apache-2.0
URL:              https://rspamd.com
Source0:          https://github.com/rspamd/rspamd/archive/%{version}/rspamd-%{version}.tar.gz
Source1:          rspamd.logrotate
Source2:          80-rspamd.preset
BuildRoot:        %{_tmppath}/%{name}-%{version}-%{release}
%if 0%{?el7}
BuildRequires:    cmake3
BuildRequires:    devtoolset-10-gcc-c++
%else
BuildRequires:    cmake
%if 0%{?el8}
BuildRequires:    gcc-toolset-10-gcc-c++
%endif
%if 0%{?el9}
BuildRequires:    gcc-toolset-12-gcc-c++
%endif
%endif
BuildRequires:    file-devel
BuildRequires:    glib2-devel
BuildRequires:    lapack-devel
BuildRequires:    libicu-devel
BuildRequires:    libsodium-devel
BuildRequires:    libunwind-devel
%if 0%{getenv:ASAN}
%if 0%{?el7}
BuildRequires:    devtoolset-10-libasan-devel
%else
%if 0%{?el8}
BuildRequires:    gcc-toolset-10-libasan-devel
%endif
%if 0%{?el9}
BuildRequires:    gcc-toolset-12-libasan-devel
%endif
%endif
%endif

%ifarch x86_64 amd64
%if 0%{?el8} || 0%{?fedora} > 10
BuildRequires:    hyperscan-devel
%endif
BuildRequires:    jemalloc-devel
%endif

%if 0%{getenv:LUAJIT}
BuildRequires:    git
%else
BuildRequires:    lua-devel
%endif
BuildRequires:    openblas-devel
BuildRequires:    openssl-devel
BuildRequires:    pcre2-devel
BuildRequires:    ragel
BuildRequires:    sqlite-devel
BuildRequires:    systemd
BuildRequires:    binutils-devel
Requires(pre):    shadow-utils
Requires(post):   systemd
Requires(preun):  systemd
Requires(postun): systemd

%description
Rspamd is a rapid, modular and lightweight spam filter. It is designed to work
with big amount of mail and can be easily extended with own filters written in
lua.

%prep
%setup -q -n %{name}-%{version}
%if 0%{getenv:LUAJIT}
rm -fr %{_builddir}/luajit-src || true
rm -fr %{_builddir}/luajit-build || true
git clone -b v2.1 https://luajit.org/git/luajit-2.0.git %{_builddir}/luajit-src
%endif

%build
%if 0%{?el7}
source /opt/rh/devtoolset-10/enable
%else
%if 0%{?el8}
source /opt/rh/gcc-toolset-10/enable
%endif
%if 0%{?el9}
source /opt/rh/gcc-toolset-12/enable
%endif
%endif

%if 0%{getenv:LUAJIT}
pushd %{_builddir}/luajit-src && make clean && make %{?_smp_mflags} CC="gcc -fPIC" PREFIX=%{_builddir}/luajit-build && make install PREFIX=%{_builddir}/luajit-build ; popd
rm -f %{_builddir}/luajit-build/lib/*.so || true
%endif
%if 0%{?el7}
%{cmake3} \
%else
%{cmake} \
%endif
	-B . \
%if 0%{getenv:ASAN}
        -DCMAKE_BUILD_TYPE=Debug \
        -DSANITIZE=address \
%else
        -DCMAKE_BUILD_TYPE=RelWithDebInfo \
        -DENABLE_LTO=ON \
%endif
        -DCMAKE_C_FLAGS_RELEASE="%{optflags}" \
        -DCMAKE_CXX_FLAGS_RELEASE="%{optflags}" \
%if 0%{?fedora} >= 36
        -DLINKER_NAME=/usr/bin/ld.bfd \
%endif
%if 0%{?el8}
        -DLINKER_NAME=ld.bfd \
%endif
        -DCMAKE_INSTALL_PREFIX=%{_prefix} \
        -DCONFDIR=%{_sysconfdir}/rspamd \
        -DMANDIR=%{_mandir} \
        -DDBDIR=%{_localstatedir}/lib/rspamd \
        -DRUNDIR=%{_localstatedir}/run/rspamd \
        -DLOGDIR=%{_localstatedir}/log/rspamd \
        -DEXAMPLESDIR=%{_datadir}/examples/rspamd \
        -DSHAREDIR=%{_datadir}/rspamd \
        -DLIBDIR=%{_libdir}/rspamd/ \
        -DINCLUDEDIR=%{_includedir} \
        -DRSPAMD_GROUP=_rspamd \
        -DRSPAMD_USER=_rspamd \
        -DSYSTEMDDIR=%{_unitdir} \
        -DWANT_SYSTEMD_UNITS=ON \
        -DNO_SHARED=ON \
        -DNO_TARGET_VERSIONS=1 \
        -DRSPAMD_LEGACY_SSL_PROVIDER=1 \
%ifarch x86_64 amd64 arm64 aarch64
        -DENABLE_HYPERSCAN=ON \
%endif
%ifarch arm64 aarch64
        -DHYPERSCAN_ROOT_DIR=/vectorscan \
%endif
%ifarch x86_64 amd64
%if 0%{?el7}
        -DHYPERSCAN_ROOT_DIR=/vectorscan \
%endif
%endif
%ifarch x86_64 amd64
        -DENABLE_JEMALLOC=ON \
%endif
%if 0%{getenv:LUAJIT}
        -DENABLE_LUAJIT=ON \
	      -DLUA_ROOT=%{_builddir}/luajit-build \
%else
        -DENABLE_LUAJIT=OFF \
%endif
        -DENABLE_FASTTEXT=ON \
        -DFASTTEXT_ROOT_DIR=/fasttext \
        -DENABLE_BLAS=ON
make %{?_smp_mflags}

%install
%make_install
%{__install} -p -D -m 0644 %{SOURCE1} %{buildroot}%{_sysconfdir}/logrotate.d/rspamd
%{__install} -p -D -m 0644 %{SOURCE2} %{buildroot}%{_presetdir}/80-rspamd.preset
%{__install} -d -p -m 0755 %{buildroot}%{_localstatedir}/log/rspamd
%{__install} -d -p -m 0755 %{buildroot}%{_localstatedir}/lib/rspamd
%{__install} -p -D -d -m 0755 %{buildroot}%{_sysconfdir}/rspamd/local.d/
%{__install} -p -D -d -m 0755 %{buildroot}%{_sysconfdir}/rspamd/override.d/

%clean
rm -rf %{buildroot}

%pre
%{_sbindir}/groupadd -r _rspamd 2>/dev/null || :
%{_sbindir}/useradd -g _rspamd -c "Rspamd user" -s /bin/false -r -d %{_localstatedir}/lib/rspamd _rspamd 2>/dev/null || :

%post
%{__chown} -R _rspamd:_rspamd %{_localstatedir}/lib/rspamd
%{__chown} _rspamd:_rspamd %{_localstatedir}/log/rspamd
%if 0%{?el7}
# We need to clean old hyperscan files on upgrade: see https://github.com/rspamd/rspamd/issues/4441
rm -f %{_localstatedir}/lib/rspamd/*.hs*
%endif
systemctl --no-reload preset rspamd.service >/dev/null 2>&1 || :

%preun
%systemd_preun rspamd.service

%postun
%systemd_postun_with_restart rspamd.service

%files
%defattr(-,root,root,-)

%dir %{_sysconfdir}/rspamd
%config(noreplace) %{_sysconfdir}/rspamd/*

%{_bindir}/rspamd
%{_bindir}/rspamd_stats
%{_bindir}/rspamc
%{_bindir}/rspamadm

%{_unitdir}/rspamd.service
%{_presetdir}/80-rspamd.preset

%dir %{_libdir}/rspamd
%{_libdir}/rspamd/*

%{_mandir}/man8/rspamd.*
%{_mandir}/man1/rspamc.*
%{_mandir}/man1/rspamadm.*

%dir %{_datadir}/rspamd
%{_datadir}/rspamd/*

%config(noreplace) %{_sysconfdir}/logrotate.d/rspamd

%attr(-, _rspamd, _rspamd) %dir %{_localstatedir}/lib/rspamd
%dir %{_localstatedir}/log/rspamd