aboutsummaryrefslogtreecommitdiffstats
path: root/community/rspamd/APKBUILD
blob: be2faa5dee7a6a7497a2562f58dd37561b8b4327 (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
# Maintainer: Valery Kartel <valery.kartel@gmail.com>
# Contributor: Valery Kartel <valery.kartel@gmail.com>
# Contributor: Nathan Angelacos <nangel@alpinelinux.org>
# Contributor: TBK <alpine@jjtc.eu>
pkgname=rspamd
pkgver=1.7.3
pkgrel=0
pkgdesc="Fast, free and open-source spam filtering system"
url="https://rspamd.com"
arch="x86_64 x86 armhf ppc64le"
license="Apache-2.0"
options="!check"
pkgusers=$pkgname
pkggroups=$pkgname
makedepends="cmake ragel perl luajit-dev glib-dev pcre-dev icu-dev
	libevent-dev sqlite-dev libressl-dev file-dev curl-dev
	gd-dev fann-dev"
install="$pkgname.pre-install"
subpackages="$pkgname-doc $pkgname-client $pkgname-utils::noarch
	$pkgname-controller::noarch $pkgname-fuzzy::noarch
	$pkgname-proxy::noarch
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/vstakhov/$pkgname/archive/$pkgver.tar.gz
	$pkgname.logrotated
	$pkgname.initd
	$pkgname.confd
	cmakelists.patch
	worker.conf.in
	"
builddir="$srcdir/$pkgname-$pkgver"

prepare() {
	local worker
	default_prepare

	cd "$builddir"
	for worker in proxy:2 normal:3 controller:4 fuzzy:5; do
		sed -e "s/@name@/${worker%:*}/g" -e "s/@port@/${worker#*:}/g" \
			"$srcdir"/worker.conf.in > conf/worker-${worker%:*}.conf
	done
	sed -ri -e 's/worker /&"rspamd_proxy" /' \
		conf/worker-proxy.conf
	sed "$(grep -n -m1 'worker {' conf/rspamd.conf|cut -d: -f1),\$d" \
		 -i conf/rspamd.conf && \
		 echo '.include(glob=true) "$CONFDIR/worker-*.conf"' >> \
		conf/rspamd.conf
	sed -ri -e 's~DBDIR(/rspamd.sock)~RUNDIR\1~' \
		-e 's~rspamd_dynamic~dynamic~' \
		conf/options.inc
}

build() {
	cd "$builddir"
	cmake CMakeLists.txt \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCONFDIR=/etc/$pkgname \
		-DRUNDIR=/run/$pkgname \
		-DRSPAMD_USER=$pkgusers \
		-DRSPAMD_GROUP=$pkggroups \
		-DENABLE_DB=ON \
		-DENABLE_SQLITE=ON \
		-DENABLE_HIREDIS=ON \
		-DENABLE_REDIRECTOR=ON \
		-DENABLE_URL_INCLUDE=ON \
		-DINSTALL_EXAMPLES=ON
	make
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir" install

	mkdir -p "$pkgdir"/etc/$pkgname/local.d \
		"$pkgdir"/etc/$pkgname/override.d

	install -Dm644 "$srcdir"/$pkgname.logrotated \
		"$pkgdir"/etc/logrotate.d/$pkgname
	install -Dm755 "$srcdir"/$pkgname.initd \
		"$pkgdir"/etc/init.d/$pkgname
	install -Dm644 "$srcdir"/$pkgname.confd \
		"$pkgdir"/etc/conf.d/$pkgname

	install -dm750 -o $pkgname -g $pkgname \
		"$pkgdir"/var/lib/$pkgname/dynamic
	install -dm750 -g $pkgname \
		"$pkgdir"/var/log/$pkgname
	chown $pkgname:$pkgname "$pkgdir"/var/lib/$pkgname

	mkdir "$pkgdir"/usr/sbin
	find "$pkgdir"/usr/bin -type l -delete
	mv "$pkgdir"/usr/bin/rspamd-$pkgver \
		"$pkgdir"/usr/sbin/rspamd
	mv "$pkgdir"/usr/bin/rspamadm-$pkgver \
		"$pkgdir"/usr/bin/rspamadm

	mv "$pkgdir"/usr/share/examples \
		"$pkgdir"/usr/share/doc
	mv "$pkgdir"/usr/share/$pkgname/www/README.md \
		"$pkgdir"/usr/share/$pkgname/www/plugins.txt \
		"$pkgdir"/usr/share/doc/$pkgname
}

client() {
	pkgdesc="$pkgdesc (console client)"
	mkdir -p "$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/bin/rspamc-$pkgver \
		"$subpkgdir"/usr/bin/rspamc
}

utils() {
	depends="perl"
	pkgdesc="$pkgdesc (utilities)"
	mkdir -p "$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/bin/${pkgname}_stats \
		"$subpkgdir"/usr/bin/${pkgname}-stats
	mv "$pkgdir"/usr/bin/${pkgname}-redirector "$subpkgdir"/usr/bin
}

fuzzy() {
	depends="$pkgname"
	pkgdesc="$pkgdesc (local fuzzy storage)"
	mkdir -p "$subpkgdir"/etc/$pkgname/modules.d
	mv "$pkgdir"/etc/$pkgname/worker-fuzzy.* \
		"$subpkgdir"/etc/$pkgname
	mv "$pkgdir"/etc/$pkgname/modules.d/fuzzy_* \
		"$subpkgdir"/etc/$pkgname/modules.d
}

controller() {
	license="MIT"
	depends="$pkgname"
	pkgdesc="$pkgdesc (controller web interface)"
	mkdir -p "$subpkgdir"/usr/share/$pkgname \
		"$subpkgdir"/etc/$pkgname
	mv "$pkgdir"/usr/share/$pkgname/www \
		"$subpkgdir"/usr/share/$pkgname
	mv "$pkgdir"/etc/$pkgname/worker-controller.* \
		"$subpkgdir"/etc/$pkgname
}

proxy() {
	depends="$pkgname"
	pkgdesc="$pkgdesc (milter support)"
	mkdir -p "$subpkgdir"/etc/$pkgname
	mv "$pkgdir"/etc/$pkgname/worker-proxy.* \
		"$subpkgdir"/etc/$pkgname
}

sha512sums="9e94a0001ac5360ef61177ebd82002329777cec5fbf5b9969f1317509e39e0c239773b82ebee21e1262ebec35f6bbf098dd23f51e2cd46996a8c8a1a1fb25a68  rspamd-1.7.3.tar.gz
2efe28575c40d1fba84b189bb872860e744400db80dce2f6330be6c6287fb3f46e6511284729b957488bf40bcb9b0952e26df9934f5f138334bd2766075c45cb  rspamd.logrotated
df37726d03e676b16d707854d95bafc9162da65c27bb150edbfc0cb00f1842188a1f2a8f1b82be5ae2a253b4f4db4d93dfe804a89feb988b5af858eb3f3458be  rspamd.initd
e417dd825d1b4d03d115db037b2fdf2f48a35420ee7a9010d97167b6c31e88d6c0a15dd33b21d7d76856db0fdc5097c922fcdf1d8164d1e92ae377f7c5303947  rspamd.confd
fa0e14d507cd7421a20916506c03e6e6c95fb2f38736e69540ee3e066da883c2ee4cb779ee8787756e4a1831ff8f04150ce592d4d6df08d8a18d55f3c6de4646  cmakelists.patch
2169a8c4b4af6df9f3bbf4addeac564c9485a9d6a30fd15cf167093488362791c003a0d03360049c43d827e7fa767c1ad3522de6699b0247b75aa049c0b51214  worker.conf.in"