1{
2 lib,
3 stdenv,
4 buildPackages,
5 fetchurl,
6 which,
7 autoconf,
8 automake,
9 flex,
10 bison,
11 glibc,
12 perl,
13 libkrb5,
14 libxslt,
15 docbook_xsl,
16 file,
17 docbook_xml_dtd_43,
18 libtool_2,
19 withDevdoc ? false,
20 doxygen,
21 dblatex, # Extra developer documentation
22 withNcurses ? false,
23 ncurses, # Extra ncurses utilities. Needed for debugging and monitoring.
24 withTsm ? false,
25 tsm-client, # Tivoli Storage Manager Backup Client from IBM
26}:
27
28with (import ./srcs.nix { inherit fetchurl; });
29let
30 inherit (lib) optional optionalString optionals;
31
32in
33stdenv.mkDerivation {
34 pname = "openafs";
35 inherit version srcs;
36
37 depsBuildBuild = [ buildPackages.stdenv.cc ];
38 nativeBuildInputs = [
39 autoconf
40 automake
41 flex
42 libxslt
43 libtool_2
44 perl
45 which
46 bison
47 ]
48 ++ optionals withDevdoc [
49 doxygen
50 dblatex
51 ];
52
53 buildInputs = [ libkrb5 ] ++ optional withNcurses ncurses;
54
55 patches = [
56 ./bosserver.patch
57 ./cross-build.patch
58 ]
59 ++ optional withTsm ./tsmbac.patch;
60
61 outputs = [
62 "out"
63 "dev"
64 "man"
65 "doc"
66 ]
67 ++ optional withDevdoc "devdoc";
68
69 enableParallelBuilding = false;
70
71 setOutputFlags = false;
72
73 # Makefiles don't include install targets for all new shared libs, yet.
74 dontDisableStatic = true;
75
76 preConfigure = ''
77 patchShebangs .
78 for i in `grep -l -R '/usr/\(include\|src\)' .`; do
79 echo "Patch /usr/include and /usr/src in $i"
80 substituteInPlace $i \
81 --replace "/usr/include" "${glibc.dev}/include" \
82 --replace "/usr/src" "$TMP"
83 done
84
85 for i in ./doc/xml/{AdminGuide,QuickStartUnix,UserGuide}/*.xml; do
86 substituteInPlace "''${i}" --replace "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" \
87 "${docbook_xml_dtd_43}/xml/dtd/docbook/docbookx.dtd"
88 done
89
90 ./regen.sh
91
92
93 configureFlagsArray=(
94 "--with-krb5"
95 "--sysconfdir=/etc"
96 "--localstatedir=/var"
97 "--disable-kernel-module"
98 "--disable-fuse-client"
99 "--with-docbook-stylesheets=${docbook_xsl}/share/xml/docbook-xsl"
100 ${optionalString withTsm "--enable-tivoli-tsm"}
101 ${optionalString (!withNcurses) "--disable-gtx"}
102 "--disable-linux-d_splice-alias-extra-iput"
103 )
104 ''
105 + optionalString withTsm ''
106 export XBSA_CFLAGS="-Dxbsa -DNEW_XBSA -I${tsm-client}/lib64/sample -DXBSA_TSMLIB=\\\"${tsm-client}/lib64/libApiTSM64.so\\\""
107 '';
108
109 buildFlags = [ "all_nolibafs" ];
110
111 postBuild = ''
112 for d in doc/xml/{AdminGuide,QuickStartUnix,UserGuide}; do
113 make -C "''${d}" index.html
114 done
115 ''
116 + optionalString withDevdoc ''
117 make dox
118 '';
119
120 postInstall = ''
121 mkdir -p $doc/share/doc/openafs/{AdminGuide,QuickStartUnix,UserGuide}
122 cp -r doc/txt README LICENSE $doc/share/doc/openafs
123 for d in AdminGuide QuickStartUnix UserGuide ; do
124 cp "doc/xml/''${d}"/*.html "$doc/share/doc/openafs/''${d}"
125 done
126
127 cp src/tools/dumpscan/{afsdump_dirlist,afsdump_extract,afsdump_scan,dumptool} $out/bin
128
129 rm -r $out/lib/openafs
130 ''
131 + optionalString withDevdoc ''
132 mkdir -p $devdoc/share/devhelp/openafs/doxygen
133 cp -r doc/{pdf,protocol} $devdoc/share/devhelp/openafs
134 cp -r doc/doxygen/output/html $devdoc/share/devhelp/openafs/doxygen
135 '';
136
137 # remove forbidden references to $TMPDIR
138 preFixup = ''
139 for f in "$out"/bin/*; do
140 if isELF "$f"; then
141 patchelf --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE" "$f"
142 fi
143 done
144 '';
145
146 meta = with lib; {
147 outputsToInstall = [
148 "out"
149 "doc"
150 "man"
151 ];
152 description = "Open AFS client";
153 homepage = "https://www.openafs.org";
154 license = licenses.ipl10;
155 platforms = platforms.linux;
156 maintainers = [
157 maintainers.maggesi
158 maintainers.spacefrogg
159 ];
160 };
161}