2015-11-02 01:46:18 +01:00
|
|
|
{ stdenv, lib, fetchurl, makeWrapper
|
2016-02-12 15:58:53 +01:00
|
|
|
, gawk, gnused, gnugrep, coreutils, which
|
2015-11-02 01:46:18 +01:00
|
|
|
, perl, NetSMTP
|
|
|
|
, withMySQL ? false, zlib, libmysql
|
|
|
|
, 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"
|
|
|
|
);
|
2016-04-13 14:53:51 +02:00
|
|
|
maintenancePath = lib.makeBinPath [ gawk gnused gnugrep coreutils which ];
|
2015-11-02 01:46:18 +01:00
|
|
|
|
|
|
|
in stdenv.mkDerivation rec {
|
|
|
|
name = "dspam-3.10.2";
|
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "mirror://sourceforge/dspam/dspam/${name}/${name}.tar.gz";
|
|
|
|
sha256 = "1acklnxn1wvc7abn31l3qdj8q6k13s51k5gv86vka7q20jb5cxmf";
|
|
|
|
};
|
|
|
|
|
|
|
|
buildInputs = [ perl ]
|
|
|
|
++ lib.optionals withMySQL [ zlib libmysql ]
|
|
|
|
++ 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"
|
2016-08-01 17:46:30 +02:00
|
|
|
] ++ lib.optional withMySQL "--with-mysql-includes=${lib.getDev libmysql}/include/mysql"
|
2016-04-30 03:51:50 +02:00
|
|
|
++ lib.optional withPgSQL "--with-pgsql-libraries=${postgresql.lib}/lib";
|
2015-11-02 01:46:18 +01:00
|
|
|
|
|
|
|
# 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 "${lib.makePerlPath [ NetSMTP ]}"
|
|
|
|
|
|
|
|
# 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 \
|
2016-02-12 15:58:53 +01:00
|
|
|
-e "2iexport PATH=$out/bin:${maintenancePath}:\$PATH" \
|
2015-11-02 01:46:18 +01:00
|
|
|
-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," \
|
2016-02-12 15:58:53 +01:00
|
|
|
-e 's,^DSPAM_CRON_LOCKFILE=.*,DSPAM_CRON_LOCKFILE=/run/dspam/dspam_maintenance.pid,' \
|
2015-11-02 01:46:18 +01:00
|
|
|
$out/bin/dspam_maintenance
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
2016-08-13 02:18:13 +02:00
|
|
|
homepage = "http://nuclearelephant.com/";
|
2015-11-02 01:46:18 +01:00
|
|
|
description = "Community Driven Antispam Filter";
|
|
|
|
license = licenses.agpl3;
|
2016-06-11 02:40:22 +02:00
|
|
|
platforms = platforms.linux;
|
2015-11-02 01:46:18 +01:00
|
|
|
maintainers = with maintainers; [ abbradar ];
|
|
|
|
};
|
|
|
|
}
|