1{
2 bdbSupport ? true, # build support for Berkeley DB repositories
3 httpServer ? false, # build Apache DAV module
4 httpSupport ? true, # client must support http
5 pythonBindings ? false,
6 perlBindings ? false,
7 javahlBindings ? false,
8 saslSupport ? false,
9 lib,
10 stdenv,
11 fetchurl,
12 apr,
13 aprutil,
14 zlib,
15 sqlite,
16 openssl,
17 lz4,
18 utf8proc,
19 autoconf,
20 libtool,
21 apacheHttpd ? null,
22 expat,
23 swig ? null,
24 jdk ? null,
25 python3 ? null,
26 py3c ? null,
27 perl ? null,
28 sasl ? null,
29 serf ? null,
30}:
31
32assert bdbSupport -> aprutil.bdbSupport;
33assert httpServer -> apacheHttpd != null;
34assert pythonBindings -> swig != null && python3 != null && py3c != null;
35assert javahlBindings -> jdk != null && perl != null;
36
37let
38 common =
39 {
40 version,
41 sha256,
42 extraPatches ? [ ],
43 }:
44 stdenv.mkDerivation (
45 rec {
46 inherit version;
47 pname = "subversion${lib.optionalString (!bdbSupport && perlBindings && pythonBindings) "-client"}";
48
49 src = fetchurl {
50 url = "mirror://apache/subversion/subversion-${version}.tar.bz2";
51 inherit sha256;
52 };
53
54 # Can't do separate $lib and $bin, as libs reference bins
55 outputs = [
56 "out"
57 "dev"
58 "man"
59 ];
60
61 nativeBuildInputs = [
62 autoconf
63 libtool
64 python3
65 ];
66
67 buildInputs = [
68 zlib
69 apr
70 aprutil
71 sqlite
72 openssl
73 lz4
74 utf8proc
75 ]
76 ++ lib.optional httpSupport serf
77 ++ lib.optionals pythonBindings [
78 python3
79 py3c
80 ]
81 ++ lib.optional perlBindings perl
82 ++ lib.optional saslSupport sasl;
83
84 patches = [ ./apr-1.patch ] ++ extraPatches;
85
86 # remove vendored swig-3 files as these will shadow the swig provided
87 # ones and result in compile errors
88 postPatch = ''
89 rm subversion/bindings/swig/proxy/{perlrun.swg,pyrun.swg,python.swg,rubydef.swg,rubyhead.swg,rubytracking.swg,runtime.swg,swigrun.swg}
90 '';
91
92 # We are hitting the following issue even with APR 1.6.x
93 # -> https://issues.apache.org/jira/browse/SVN-4813
94 # "-P" CPPFLAG is needed to build Python bindings and subversionClient
95 CPPFLAGS = [ "-P" ];
96
97 preConfigure = ''
98 ./autogen.sh
99 '';
100
101 configureFlags = [
102 (lib.withFeature bdbSupport "berkeley-db")
103 (lib.withFeatureAs httpServer "apxs" "${apacheHttpd.dev}/bin/apxs")
104 (lib.withFeatureAs (pythonBindings || perlBindings) "swig" swig)
105 (lib.withFeatureAs saslSupport "sasl" sasl)
106 (lib.withFeatureAs httpSupport "serf" serf)
107 "--with-zlib=${zlib.dev}"
108 "--with-sqlite=${sqlite.dev}"
109 "--with-apr=${apr.dev}"
110 "--with-apr-util=${aprutil.dev}"
111 ]
112 ++ lib.optionals javahlBindings [
113 "--enable-javahl"
114 "--with-jdk=${jdk}"
115 ];
116
117 preBuild = ''
118 makeFlagsArray=(APACHE_LIBEXECDIR=$out/modules)
119 '';
120
121 postInstall = ''
122 if test -n "$pythonBindings"; then
123 make swig-py swig_pydir=$(toPythonPath $out)/libsvn swig_pydir_extra=$(toPythonPath $out)/svn
124 make install-swig-py swig_pydir=$(toPythonPath $out)/libsvn swig_pydir_extra=$(toPythonPath $out)/svn
125 fi
126
127 if test -n "$perlBindings"; then
128 make swig-pl-lib
129 make install-swig-pl-lib
130 cd subversion/bindings/swig/perl/native
131 perl Makefile.PL PREFIX=$out
132 make install
133 cd -
134 fi
135
136 mkdir -p $out/share/bash-completion/completions
137 cp tools/client-side/bash_completion $out/share/bash-completion/completions/subversion
138
139 for f in $out/lib/*.la $out/lib/python*/site-packages/*/*.la; do
140 substituteInPlace $f \
141 --replace "${expat.dev}/lib" "${expat.out}/lib" \
142 --replace "${zlib.dev}/lib" "${zlib.out}/lib" \
143 --replace "${sqlite.dev}/lib" "${sqlite.out}/lib" \
144 --replace "${openssl.dev}/lib" "${lib.getLib openssl}/lib"
145 done
146 '';
147
148 inherit perlBindings pythonBindings;
149
150 enableParallelBuilding = true;
151 # Missing install dependencies:
152 # libtool: error: error: relink 'libsvn_ra_serf-1.la' with the above command before installing it
153 # make: *** [build-outputs.mk:1316: install-serf-lib] Error 1
154 enableParallelInstalling = false;
155
156 nativeCheckInputs = [ python3 ];
157 doCheck = false; # fails 10 out of ~2300 tests
158
159 meta = with lib; {
160 description = "Version control system intended to be a compelling replacement for CVS in the open source community";
161 license = licenses.asl20;
162 homepage = "https://subversion.apache.org/";
163 mainProgram = "svn";
164 maintainers = with maintainers; [ lovek323 ];
165 platforms = platforms.linux ++ platforms.darwin;
166 };
167
168 }
169 // lib.optionalAttrs stdenv.hostPlatform.isDarwin {
170 CXX = "clang++";
171 CC = "clang";
172 CPP = "clang -E";
173 CXXCPP = "clang++ -E";
174 }
175 );
176
177in
178{
179 subversion = common {
180 version = "1.14.5";
181 sha256 = "sha256-54op53Zri3s1RJfQj3GlVkGrxTZ1zhh1WEeBquNWRKE=";
182 };
183}