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
|
{ stdenv, lib, fetchurl, makeWrapper
, gawk, gnused, gnugrep, coreutils, which
, perlPackages
, withMySQL ? false, zlib, mysql57
, withPgSQL ? false, postgresql
, withSQLite ? false, sqlite
, withDB ? false, db
}:
let
drivers = lib.concatStringsSep ","
([ "hash_drv" ]
++ lib.optional withMySQL "mysql_drv"
++ lib.optional withPgSQL "pgsql_drv"
++ lib.optional withSQLite "sqlite3_drv"
++ lib.optional withDB "libdb4_drv"
);
maintenancePath = lib.makeBinPath [ gawk gnused gnugrep coreutils which ];
in stdenv.mkDerivation rec {
name = "dspam-3.10.2";
src = fetchurl {
url = "mirror://sourceforge/dspam/dspam/${name}/${name}.tar.gz";
sha256 = "1acklnxn1wvc7abn31l3qdj8q6k13s51k5gv86vka7q20jb5cxmf";
};
buildInputs = [ perlPackages.perl ]
++ lib.optionals withMySQL [ zlib mysql57.connector-c ]
++ lib.optional withPgSQL postgresql
++ lib.optional withSQLite sqlite
++ lib.optional withDB db;
nativeBuildInputs = [ makeWrapper ];
configureFlags = [
"--with-storage-driver=${drivers}"
"--sysconfdir=/etc/dspam"
"--localstatedir=/var"
"--with-dspam-home=/var/lib/dspam"
"--with-logdir=/var/log/dspam"
"--with-logfile=/var/log/dspam/dspam.log"
"--enable-daemon"
"--enable-clamav"
"--enable-syslog"
"--enable-large-scale"
"--enable-virtual-users"
"--enable-split-configuration"
"--enable-preferences-extension"
"--enable-long-usernames"
"--enable-external-lookup"
] ++ lib.optional withMySQL "--with-mysql-includes=${mysql57.connector-c}/include/mysql"
++ lib.optional withPgSQL "--with-pgsql-libraries=${postgresql.lib}/lib";
# Lots of things are hardwired to paths like sysconfdir. That's why we install with both "prefix" and "DESTDIR"
# and fix directory structure manually after that.
installFlags = [ "DESTDIR=$(out)" ];
postInstall = ''
cp -r $out/$out/* $out
rm -rf $out/$(echo "$out" | cut -d "/" -f2)
rm -rf $out/var
wrapProgram $out/bin/dspam_notify \
--set PERL5LIB "${perlPackages.makePerlPath [ perlPackages.libnet ]}"
# Install SQL scripts
mkdir -p $out/share/dspam/sql
# MySQL
cp src/tools.mysql_drv/mysql_*.sql $out/share/dspam/sql
for i in src/tools.mysql_drv/{purge*.sql,virtual*.sql}; do
cp "$i" $out/share/dspam/sql/mysql_$(basename "$i")
done
# PostgreSQL
cp src/tools.pgsql_drv/pgsql_*.sql $out/share/dspam/sql
for i in src/tools.pgsql_drv/{purge*.sql,virtual*.sql}; do
cp "$i" $out/share/dspam/sql/pgsql_$(basename "$i")
done
# SQLite
for i in src/tools.sqlite_drv/purge*.sql; do
cp "$i" $out/share/dspam/sql/sqlite_$(basename "$i")
done
# Install maintenance script
install -Dm755 contrib/dspam_maintenance/dspam_maintenance.sh $out/bin/dspam_maintenance
sed -i \
-e "2iexport PATH=$out/bin:${maintenancePath}:\$PATH" \
-e 's,/usr/[a-z0-9/]*,,g' \
-e 's,^DSPAM_CONFIGDIR=.*,DSPAM_CONFIGDIR=/etc/dspam,' \
-e "s,^DSPAM_HOMEDIR=.*,DSPAM_HOMEDIR=/var/lib/dspam," \
-e "s,^DSPAM_PURGE_SCRIPT_DIR=.*,DSPAM_PURGE_SCRIPT_DIR=$out/share/dspam/sql," \
-e "s,^DSPAM_BIN_DIR=.*,DSPAM_BIN_DIR=$out/bin," \
-e "s,^MYSQL_BIN_DIR=.*,MYSQL_BIN_DIR=/run/current-system/sw/bin," \
-e "s,^PGSQL_BIN_DIR=.*,PGSQL_BIN_DIR=/run/current-system/sw/bin," \
-e "s,^SQLITE_BIN_DIR=.*,SQLITE_BIN_DIR=/run/current-system/sw/bin," \
-e "s,^SQLITE3_BIN_DIR=.*,SQLITE3_BIN_DIR=/run/current-system/sw/bin," \
-e 's,^DSPAM_CRON_LOCKFILE=.*,DSPAM_CRON_LOCKFILE=/run/dspam/dspam_maintenance.pid,' \
$out/bin/dspam_maintenance
'';
meta = with lib; {
homepage = "http://nuclearelephant.com/";
description = "Community Driven Antispam Filter";
license = licenses.agpl3;
platforms = platforms.linux;
maintainers = with maintainers; [ abbradar ];
};
}
|