summary refs log tree commit diff
path: root/pkgs/tools/networking/hping
diff options
context:
space:
mode:
authorNikolay Korotkiy <sikmir@gmail.com>2020-09-06 22:10:45 +0300
committerGitHub <noreply@github.com>2020-09-06 21:10:45 +0200
commita8d6e4b7a5ac72da37f1dae32b13687d8bf4bf5b (patch)
tree8e7aeb8ede5c31d3f7aada5dff30535aa6948a8f /pkgs/tools/networking/hping
parent02590c96209d374d7f720293fcb8337e17104bc9 (diff)
hping: 20051105 -> 2014-12-26 (#94683)
Diffstat (limited to 'pkgs/tools/networking/hping')
-rw-r--r--pkgs/tools/networking/hping/default.nix55
1 files changed, 23 insertions, 32 deletions
diff --git a/pkgs/tools/networking/hping/default.nix b/pkgs/tools/networking/hping/default.nix
index 1ef02b599e839..daa0ba38e9ee7 100644
--- a/pkgs/tools/networking/hping/default.nix
+++ b/pkgs/tools/networking/hping/default.nix
@@ -1,50 +1,41 @@
-{ stdenv, fetchurl, libpcap, tcl }:
+{ stdenv, fetchFromGitHub, libpcap, withTcl ? true, tcl }:
 
 stdenv.mkDerivation rec {
   pname = "hping";
-  version = "20051105";
+  version = "2014-12-26";
 
-  src = fetchurl {
-    url = "http://www.hping.org/hping3-${version}.tar.gz";
-    sha256 = "1s5f9xd1msx05ibhwaw37jmc7l9fahcxxslqz8a83p0i5ak739pm";
+  src = fetchFromGitHub {
+    owner = "antirez";
+    repo = pname;
+    rev = "3547c7691742c6eaa31f8402e0ccbb81387c1b99"; # there are no tags/releases
+    sha256 = "0y0n1ybij3yg9lfgzcwfmjz1sjg913zcqrv391xx83dm0j80sdpb";
   };
 
-  buildInputs = [ libpcap tcl ];
+  buildInputs = [ libpcap ] ++ stdenv.lib.optional withTcl tcl;
 
-  configurePhase = ''
-    MANPATH="$out/share/man" ./configure
-    sed -i -r -e 's|/usr(/s?bin)|'"$out"'\1|g' Makefile
-  '';
-
-  TCLSH = "${tcl}/bin/tclsh";
-
-  prePatch = ''
-    sed -i -e '/#if.*defined(__i386__)/a \
-      || defined(__x86_64__) \\
-    ' bytesex.h
-
-    sed -i -e 's|#include.*net/bpf.h|#include <pcap/bpf.h>|' \
+  postPatch = ''
+    substituteInPlace Makefile.in --replace "gcc" "$CC"
+    substituteInPlace version.c --replace "RELEASE_DATE" "\"$version\""
+  '' + stdenv.lib.optionalString stdenv.isLinux ''
+    sed -i -e 's|#include <net/bpf.h>|#include <pcap/bpf.h>|' \
       libpcap_stuff.c script.c
-
-    sed -i -r -e 's|"(/usr/(local/)?)?bin/"|"${tcl}/bin"|g' \
-              -e 's!/usr/(local/)?(lib|include)!${tcl}/\2!g' \
-              configure
   '';
 
-  preInstall = ''
-    mkdir -vp "$out/sbin" "$out/share/man/man8"
-  '';
+  configureFlags = [ (if withTcl then "TCLSH=${tcl}/bin/tclsh" else "--no-tcl") ];
 
-  postInstall = ''
-    ln -vs hping3.8.gz "$out/share/man/man8/hping.8.gz"
-    ln -vs hping3.8.gz "$out/share/man/man8/hping2.8.gz"
+  installPhase = ''
+    install -Dm755 hping3 -t $out/sbin
+    ln -s $out/sbin/hping3 $out/sbin/hping
+    ln -s $out/sbin/hping3 $out/sbin/hping2
+    install -Dm644 docs/hping3.8 -t $out/share/man/man8
+    ln -s hping3.8.gz $out/share/man/man8/hping.8.gz
+    ln -s hping3.8.gz $out/share/man/man8/hping2.8.gz
   '';
 
   meta = with stdenv.lib; {
     description = "A command-line oriented TCP/IP packet assembler/analyzer";
     homepage = "http://www.hping.org/";
-    license = licenses.gpl2;
-    platforms = platforms.all;
-    broken = stdenv.isDarwin;
+    license = licenses.gpl2Only;
+    platforms = platforms.unix;
   };
 }