at 18.09-beta 65 lines 2.4 kB view raw
1{ stdenv, fetchurl, buildPackages, ncurses }: 2 3let dialect = with stdenv.lib; last (splitString "-" stdenv.hostPlatform.system); in 4 5stdenv.mkDerivation rec { 6 name = "lsof-${version}"; 7 version = "4.91"; 8 9 depsBuildBuild = [ buildPackages.stdenv.cc ]; 10 buildInputs = [ ncurses ]; 11 12 src = fetchurl { 13 urls = ["https://fossies.org/linux/misc/lsof_${version}.tar.bz2"] ++ # Mirrors seem to be down... 14 ["ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/lsof_${version}.tar.bz2"] 15 ++ map ( 16 # the tarball is moved after new version is released 17 isOld: "ftp://sunsite.ualberta.ca/pub/Mirror/lsof/" 18 + "${stdenv.lib.optionalString isOld "OLD/"}lsof_${version}.tar.bz2" 19 ) [ false true ] 20 ++ map ( 21 # the tarball is moved after new version is released 22 isOld: "http://www.mirrorservice.org/sites/lsof.itap.purdue.edu/pub/tools/unix/lsof/" 23 + "${stdenv.lib.optionalString isOld "OLD/"}lsof_${version}.tar.bz2" 24 ) [ false true ] 25 ; 26 sha256 = "18sh4hbl9jw2szkf0gvgan8g13f3g4c6s2q9h3zq5gsza9m99nn9"; 27 }; 28 29 unpackPhase = "tar xvjf $src; cd lsof_*; tar xvf lsof_*.tar; sourceRoot=$( echo lsof_*/); "; 30 31 patches = stdenv.lib.optional stdenv.isDarwin ./darwin-dfile.patch; 32 33 postPatch = stdenv.lib.optionalString stdenv.hostPlatform.isMusl '' 34 substituteInPlace dialects/linux/dlsof.h --replace "defined(__UCLIBC__)" 1 35 '' + stdenv.lib.optionalString stdenv.isDarwin '' 36 sed -i 's|lcurses|lncurses|g' Configure 37 ''; 38 39 # Stop build scripts from searching global include paths 40 LSOF_INCLUDE = "${stdenv.lib.getDev stdenv.cc.libc}/include"; 41 configurePhase = "LINUX_CONF_CC=$CC_FOR_BUILD LSOF_CC=$CC LSOF_AR=\"$AR cr\" LSOF_RANLIB=$RANLIB ./Configure -n ${dialect}"; 42 preBuild = '' 43 for filepath in $(find dialects/${dialect} -type f); do 44 sed -i "s,/usr/include,$LSOF_INCLUDE,g" $filepath 45 done 46 ''; 47 48 installPhase = '' 49 mkdir -p $out/bin $out/man/man8 50 cp lsof.8 $out/man/man8/ 51 cp lsof $out/bin 52 ''; 53 54 meta = { 55 homepage = ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/; 56 description = "A tool to list open files"; 57 longDescription = '' 58 List open files. Can show what process has opened some file, 59 socket (IPv6/IPv4/UNIX local), or partition (by opening a file 60 from it). 61 ''; 62 maintainers = [ stdenv.lib.maintainers.dezgeg ]; 63 platforms = stdenv.lib.platforms.unix; 64 }; 65}