2024-02-29 20:09:43 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, buildPackages, perl, which, ncurses, nukeReferences }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-11-21 17:40:18 +00:00
|
|
|
let
|
2024-09-19 14:19:46 +00:00
|
|
|
dialect = lib.last (lib.splitString "-" stdenv.hostPlatform.system);
|
2022-11-21 17:40:18 +00:00
|
|
|
in
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "lsof";
|
2024-02-29 20:09:43 +00:00
|
|
|
version = "4.99.3";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "lsof-org";
|
|
|
|
repo = "lsof";
|
|
|
|
rev = version;
|
2024-02-29 20:09:43 +00:00
|
|
|
hash = "sha256-XW3l+E9D8hgI9jGJGKkIAKa8O9m0JHgZhEASqg4gYuw=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
postPatch = ''
|
|
|
|
patchShebangs --build lib/dialects/*/Mksrc
|
|
|
|
# Do not re-build version.h in every 'make' to allow nuke-refs below.
|
|
|
|
# We remove phony 'FRC' target that forces rebuilds:
|
|
|
|
# 'version.h: FRC ...' is translated to 'version.h: ...'.
|
|
|
|
sed -i lib/dialects/*/Makefile -e 's/version.h:\s*FRC/version.h:/'
|
2024-09-26 11:04:55 +00:00
|
|
|
'' + lib.optionalString stdenv.hostPlatform.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 ];
|
2024-02-29 20:09:43 +00:00
|
|
|
nativeBuildInputs = [ nukeReferences perl which ];
|
2022-11-21 17:40:18 +00:00
|
|
|
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
|
2024-02-29 20:09:43 +00:00
|
|
|
|
|
|
|
# Wipe out development-only flags from CFLAGS embedding
|
|
|
|
make version.h
|
|
|
|
nuke-refs version.h
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
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
|
|
|
|
'';
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
meta = {
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://github.com/lsof-org/lsof";
|
2024-06-20 14:57:18 +00:00
|
|
|
description = "Tool to list open files";
|
2024-04-21 15:54:59 +00:00
|
|
|
mainProgram = "lsof";
|
2020-04-24 23:36:52 +00:00
|
|
|
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).
|
|
|
|
'';
|
2024-09-19 14:19:46 +00:00
|
|
|
license = lib.licenses.purdueBsd;
|
|
|
|
maintainers = with lib.maintainers; [ dezgeg ];
|
|
|
|
platforms = lib.platforms.unix;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|