aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/pkgs/tools/networking/hping/default.nix
blob: 1ef02b599e839142feca3dce6d3e011f766810d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
{ stdenv, fetchurl, libpcap, tcl }:

stdenv.mkDerivation rec {
  pname = "hping";
  version = "20051105";

  src = fetchurl {
    url = "http://www.hping.org/hping3-${version}.tar.gz";
    sha256 = "1s5f9xd1msx05ibhwaw37jmc7l9fahcxxslqz8a83p0i5ak739pm";
  };

  buildInputs = [ libpcap 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>|' \
      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"
  '';

  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"
  '';

  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;
  };
}