diff options
Diffstat (limited to 'nixpkgs/pkgs/development/tools/misc/lsof')
-rw-r--r-- | nixpkgs/pkgs/development/tools/misc/lsof/default.nix | 64 | ||||
-rw-r--r-- | nixpkgs/pkgs/development/tools/misc/lsof/no-build-info.patch | 40 |
2 files changed, 104 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/tools/misc/lsof/default.nix b/nixpkgs/pkgs/development/tools/misc/lsof/default.nix new file mode 100644 index 000000000000..2faefedd6656 --- /dev/null +++ b/nixpkgs/pkgs/development/tools/misc/lsof/default.nix @@ -0,0 +1,64 @@ +{ lib, stdenv, fetchFromGitHub, buildPackages, perl, which, ncurses }: + +let + dialect = with lib; last (splitString "-" stdenv.hostPlatform.system); +in + +stdenv.mkDerivation rec { + pname = "lsof"; + version = "4.98.0"; + + src = fetchFromGitHub { + owner = "lsof-org"; + repo = "lsof"; + rev = version; + sha256 = "sha256-DQLY0a0sOCZFEJA4Y4b18OcWZw47RyqKZ0mVG0CDVTI="; + }; + + patches = [ + ./no-build-info.patch + ]; + + postPatch = lib.optionalString stdenv.hostPlatform.isMusl '' + substituteInPlace dialects/linux/dlsof.h --replace "defined(__UCLIBC__)" 1 + '' + lib.optionalString stdenv.isDarwin '' + sed -i 's|lcurses|lncurses|g' Configure + ''; + + depsBuildBuild = [ buildPackages.stdenv.cc ]; + nativeBuildInputs = [ perl which ]; + buildInputs = [ ncurses ]; + + # Stop build scripts from searching global include paths + LSOF_INCLUDE = "${lib.getDev stdenv.cc.libc}/include"; + configurePhase = "LINUX_CONF_CC=$CC_FOR_BUILD LSOF_CC=$CC LSOF_AR=\"$AR cr\" LSOF_RANLIB=$RANLIB ./Configure -n ${dialect}"; + + 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 + ''; + + meta = with lib; { + 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; + maintainers = with maintainers; [ dezgeg ]; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/tools/misc/lsof/no-build-info.patch b/nixpkgs/pkgs/development/tools/misc/lsof/no-build-info.patch new file mode 100644 index 000000000000..3c518896b045 --- /dev/null +++ b/nixpkgs/pkgs/development/tools/misc/lsof/no-build-info.patch @@ -0,0 +1,40 @@ +--- a/usage.c ++++ b/usage.c +@@ -931,24 +931,6 @@ usage(err, fh, version) + (void) fprintf(stderr, " configuration info: %s\n", cp); + #endif /* defined(LSOF_CINFO) */ + +- cp = isnullstr(LSOF_HOST); +- if (!(cp1 = isnullstr(LSOF_LOGNAME))) +- cp1 = isnullstr(LSOF_USER); +- if (cp || cp1) { +- if (cp && cp1) +- cp2 = "by and on"; +- else if (cp) +- cp2 = "on"; +- else +- cp2 = "by"; +- (void) fprintf(stderr, " constructed %s: %s%s%s\n", +- cp2, +- cp1 ? cp1 : "", +- (cp && cp1) ? "@" : "", +- cp ? cp : "" +- ); +- } +- + #if defined(LSOF_BLDCMT) + if ((cp = isnullstr(LSOF_BLDCMT))) + (void) fprintf(stderr, " builder's comment: %s\n", cp); +@@ -958,12 +940,6 @@ usage(err, fh, version) + (void) fprintf(stderr, " compiler: %s\n", cp); + if ((cp = isnullstr(LSOF_CCV))) + (void) fprintf(stderr, " compiler version: %s\n", cp); +- if ((cp = isnullstr(LSOF_CCFLAGS))) +- (void) fprintf(stderr, " compiler flags: %s\n", cp); +- if ((cp = isnullstr(LSOF_LDFLAGS))) +- (void) fprintf(stderr, " loader flags: %s\n", cp); +- if ((cp = isnullstr(LSOF_SYSINFO))) +- (void) fprintf(stderr, " system info: %s\n", cp); + // display configurations that might affect output + char *features[] = { + #if defined(HASEFFNLINK) |