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