2022-11-21 17:40:18 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, buildPackages, perl, which, ncurses }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-11-21 17:40:18 +00:00
|
|
|
let
|
|
|
|
dialect = with lib; last (splitString "-" stdenv.hostPlatform.system);
|
|
|
|
in
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "lsof";
|
2023-02-16 17:41:37 +00:00
|
|
|
version = "4.98.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "lsof-org";
|
|
|
|
repo = "lsof";
|
|
|
|
rev = version;
|
2023-02-16 17:41:37 +00:00
|
|
|
sha256 = "sha256-DQLY0a0sOCZFEJA4Y4b18OcWZw47RyqKZ0mVG0CDVTI=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-07-14 12:49:19 +00:00
|
|
|
patches = [
|
|
|
|
./no-build-info.patch
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
postPatch = lib.optionalString stdenv.hostPlatform.isMusl ''
|
2020-04-24 23:36:52 +00:00
|
|
|
substituteInPlace dialects/linux/dlsof.h --replace "defined(__UCLIBC__)" 1
|
2021-02-05 17:12:51 +00:00
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
2020-04-24 23:36:52 +00:00
|
|
|
sed -i 's|lcurses|lncurses|g' Configure
|
|
|
|
'';
|
|
|
|
|
2022-11-21 17:40:18 +00:00
|
|
|
depsBuildBuild = [ buildPackages.stdenv.cc ];
|
|
|
|
nativeBuildInputs = [ perl which ];
|
|
|
|
buildInputs = [ ncurses ];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
# Stop build scripts from searching global include paths
|
2021-02-05 17:12:51 +00:00
|
|
|
LSOF_INCLUDE = "${lib.getDev stdenv.cc.libc}/include";
|
2020-04-24 23:36:52 +00:00
|
|
|
configurePhase = "LINUX_CONF_CC=$CC_FOR_BUILD LSOF_CC=$CC LSOF_AR=\"$AR cr\" LSOF_RANLIB=$RANLIB ./Configure -n ${dialect}";
|
2022-11-21 17:40:18 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
preBuild = ''
|
|
|
|
for filepath in $(find dialects/${dialect} -type f); do
|
|
|
|
sed -i "s,/usr/include,$LSOF_INCLUDE,g" $filepath
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
# Fix references from man page https://github.com/lsof-org/lsof/issues/66
|
|
|
|
substituteInPlace Lsof.8 \
|
|
|
|
--replace ".so ./00DIALECTS" "" \
|
|
|
|
--replace ".so ./version" ".ds VN ${version}"
|
|
|
|
mkdir -p $out/bin $out/man/man8
|
|
|
|
cp Lsof.8 $out/man/man8/lsof.8
|
|
|
|
cp lsof $out/bin
|
|
|
|
'';
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://github.com/lsof-org/lsof";
|
|
|
|
description = "A tool to list open files";
|
|
|
|
longDescription = ''
|
|
|
|
List open files. Can show what process has opened some file,
|
|
|
|
socket (IPv6/IPv4/UNIX local), or partition (by opening a file
|
|
|
|
from it).
|
|
|
|
'';
|
|
|
|
license = licenses.purdueBsd;
|
2022-11-21 17:40:18 +00:00
|
|
|
maintainers = with maintainers; [ dezgeg ];
|
|
|
|
platforms = platforms.unix;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|