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