1{ stdenv, fetchurl }:
2
3stdenv.mkDerivation rec {
4 name = "lsof-${version}";
5 version = "4.89";
6
7 src = fetchurl {
8 urls =
9 ["ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/lsof_${version}.tar.bz2"]
10 ++ map (
11 # the tarball is moved after new version is released
12 isOld: "ftp://sunsite.ualberta.ca/pub/Mirror/lsof/"
13 + "${stdenv.lib.optionalString isOld "OLD/"}lsof_${version}.tar.bz2"
14 ) [ false true ];
15 sha256 = "061p18v0mhzq517791xkjs8a5dfynq1418a1mwxpji69zp2jzb41";
16 };
17
18 unpackPhase = "tar xvjf $src; cd lsof_*; tar xvf lsof_*.tar; sourceRoot=$( echo lsof_*/); ";
19
20 preBuild = "sed -i Makefile -e 's/^CFGF=/& -DHASIPv6=1/;';";
21
22 configurePhase = ''
23 # Stop build scripts from searching global include paths
24 export LSOF_INCLUDE=/$(md5sum <(echo $name) | awk '{print $1}')
25 ./Configure -n ${if stdenv.isDarwin then "darwin" else "linux"}
26 '';
27
28 installPhase = ''
29 mkdir -p $out/bin $out/man/man8
30 cp lsof.8 $out/man/man8/
31 cp lsof $out/bin
32 '';
33
34 meta = {
35 homepage = ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/;
36 description = "A tool to list open files";
37 longDescription = ''
38 List open files. Can show what process has opened some file,
39 socket (IPv6/IPv4/UNIX local), or partition (by opening a file
40 from it).
41 '';
42 maintainers = [ stdenv.lib.maintainers.mornfall ];
43 platforms = stdenv.lib.platforms.linux;
44 };
45}