skim: 0.15.7 -> 0.16.0 (#376410)
[NixPkgs.git] / pkgs / by-name / sp / spamassassin / package.nix
blob790980da20753fbd56671f522168516f666940b4
2   lib,
3   fetchurl,
4   perlPackages,
5   makeBinaryWrapper,
6   gnupg,
7   re2c,
8   gcc,
9   gnumake,
10   libxcrypt,
11   openssl,
12   coreutils,
13   poppler_utils,
14   tesseract,
15   iana-etc,
18 perlPackages.buildPerlPackage rec {
19   pname = "SpamAssassin";
20   version = "4.0.1";
21   rulesRev = "r1916528";
23   src = fetchurl {
24     url = "mirror://apache/spamassassin/source/Mail-${pname}-${version}.tar.bz2";
25     hash = "sha256-l3XtdVnoPsPmwD7bK+j/x/FcxAX7E+hcFI6wvxkXIag=";
26   };
27   defaultRulesSrc = fetchurl {
28     url = "mirror://apache/spamassassin/source/Mail-${pname}-rules-${version}.${rulesRev}.tgz";
29     hash = "sha256-OB6t/H5RPl9zU4m3gXPeWvRx89Bv5quPEpY0pmRLS/Q=";
30   };
32   patches = [
33     ./satest-no-clean-path.patch
34     ./sa_compile-use-perl5lib.patch
35   ];
37   nativeBuildInputs = [ makeBinaryWrapper ];
38   buildInputs =
39     (with perlPackages; [
40       HTMLParser
41       NetCIDRLite
42       NetDNS
43       NetAddrIP
44       DBFile
45       HTTPDate
46       MailDKIM
47       LWP
48       LWPProtocolHttps
49       IOSocketSSL
50       DBI
51       EncodeDetect
52       IPCountry
53       NetIdent
54       Razor2ClientAgent
55       MailSPF
56       NetDNSResolverProgrammable
57       Socket6
58       ArchiveZip
59       EmailAddressXS
60       NetLibIDN2
61       MaxMindDBReader
62       GeoIP
63       MailDMARC
64       MaxMindDBReaderXS
65     ])
66     ++ [
67       openssl
68     ];
70   makeFlags = [
71     "PERL_BIN=${perlPackages.perl}/bin/perl"
72     "ENABLE_SSL=yes"
73   ];
75   makeMakerFlags = [ "SYSCONFDIR=/etc LOCALSTATEDIR=/var/lib/spamassassin" ];
77   checkInputs =
78     (with perlPackages; [
79       TextDiff # t/strip2.t
80     ])
81     ++ [
82       coreutils # date, t/basic_meta.t
83       poppler_utils # pdftotext, t/extracttext.t
84       tesseract # tesseract, t/extracttext.t
85       iana-etc # t/dnsbl_subtests.t (/etc/protocols used by Net::DNS::Nameserver)
86       re2c
87       gcc
88       gnumake
89     ];
90   preCheck = ''
91     substituteInPlace t/spamc_x_e.t \
92       --replace "/bin/echo" "${coreutils}/bin/echo"
93     export C_INCLUDE_PATH='${lib.makeSearchPathOutput "include" "include" [ libxcrypt ]}'
94     export HARNESS_OPTIONS="j''${NIX_BUILD_CORES}"
96     export HOME=$NIX_BUILD_TOP/home
97     mkdir -p $HOME
98     mkdir t/log  # pre-create to avoid race conditions
100     # https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8068
101     checkFlagsArray+=(TEST_FILES='$(shell find t -name *.t -not -name spamd_ssl_accept_fail.t)')
102   '';
104   postInstall = ''
105     mkdir -p $out/share/spamassassin
106     mv "rules/"* $out/share/spamassassin/
108     tar -xzf ${defaultRulesSrc} -C $out/share/spamassassin/
109     local moduleversion="$(${perlPackages.perl}/bin/perl -I lib -e 'use Mail::SpamAssassin; print $Mail::SpamAssassin::VERSION')"
110     sed -i -e "s/@@VERSION@@/$moduleversion/" $out/share/spamassassin/*.cf
112     for n in "$out/bin/"*; do
113       # Skip if this isn't a perl script
114       if ! head -n1 "$n" | grep -q bin/perl; then
115         continue
116       fi
117       echo "Wrapping $n for taint mode"
118       orig="$out/bin/.$(basename "$n")-wrapped"
119       mv "$n" "$orig"
120       # We don't inherit argv0 so that $^X works properly in e.g. sa-compile
121       makeWrapper "${perlPackages.perl}/bin/perl" "$n" \
122         --add-flags "-T $perlFlags $orig" \
123         --prefix PATH : ${
124           lib.makeBinPath [
125             gnupg
126             re2c
127             gcc
128             gnumake
129           ]
130         } \
131         --prefix C_INCLUDE_PATH : ${lib.makeSearchPathOutput "include" "include" [ libxcrypt ]}
132     done
133   '';
135   meta = {
136     homepage = "https://spamassassin.apache.org/";
137     description = "Open-Source Spam Filter";
138     license = lib.licenses.asl20;
139     platforms = lib.platforms.unix;
140     maintainers = with lib.maintainers; [
141       qknight
142       qyliss
143     ];
144   };