acr-cli: init at 0.14 (#359508)
[NixPkgs.git] / pkgs / by-name / hp / hping / package.nix
blob10bd63d489271d7c3c9a6ceaedb519fa418ff89d
1 { lib, stdenv, fetchFromGitHub, fetchpatch, libpcap, withTcl ? true, tcl }:
3 stdenv.mkDerivation rec {
4   pname = "hping";
5   version = "2014-12-26";
7   src = fetchFromGitHub {
8     owner = "antirez";
9     repo = pname;
10     rev = "3547c7691742c6eaa31f8402e0ccbb81387c1b99"; # there are no tags/releases
11     sha256 = "0y0n1ybij3yg9lfgzcwfmjz1sjg913zcqrv391xx83dm0j80sdpb";
12   };
13   patches = [
14     # Pull patch pending upstream inclusion for -fno-common toolchain
15     # support: https://github.com/antirez/hping/pull/64
16     (fetchpatch {
17       name = "fno-common.patch";
18       url = "https://github.com/antirez/hping/pull/64/commits/d057b9309aec3a5a53aaee1ac3451a8a5b71b4e8.patch";
19       sha256 = "0bqr7kdlziijja588ipj8g5hv2109wq01c6x2qadbhjfnsps1b6l";
20     })
21   ];
23   buildInputs = [ libpcap ] ++ lib.optional withTcl tcl;
25   postPatch = ''
26     substituteInPlace Makefile.in --replace "gcc" "$CC"
27     substituteInPlace version.c --replace "RELEASE_DATE" "\"$version\""
28   '' + lib.optionalString stdenv.hostPlatform.isLinux ''
29     sed -i -e 's|#include <net/bpf.h>|#include <pcap/bpf.h>|' \
30       libpcap_stuff.c script.c
31   '' + lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) ''
32     substituteInPlace configure --replace 'BYTEORDER=`./byteorder -m`' BYTEORDER=${
33       {
34         littleEndian = "__LITTLE_ENDIAN_BITFIELD";
35         bigEndian = "__BIG_ENDIAN_BITFIELD";
36       }.${stdenv.hostPlatform.parsed.cpu.significantByte.name}}
37     substituteInPlace Makefile.in --replace './hping3 -v' ""
38   '';
40   configureFlags = [ (if withTcl then "TCLSH=${tcl}/bin/tclsh" else "--no-tcl") ];
42   installPhase = ''
43     install -Dm755 hping3 -t $out/sbin
44     ln -s $out/sbin/hping3 $out/sbin/hping
45     ln -s $out/sbin/hping3 $out/sbin/hping2
46     install -Dm644 docs/hping3.8 -t $out/share/man/man8
47     ln -s hping3.8.gz $out/share/man/man8/hping.8.gz
48     ln -s hping3.8.gz $out/share/man/man8/hping2.8.gz
49   '';
51   meta = with lib; {
52     description = "Command-line oriented TCP/IP packet assembler/analyzer";
53     homepage = "http://www.hping.org/";
54     license = licenses.gpl2Only;
55     platforms = platforms.unix;
56   };