Subject: [alpine-aports]

From: Corentin Henry <[email-masked]>
Date: Tue, 19 Jan 2016 11:50:37 +0000

hi,

hping3 is a network tool able to send custom TCP/IP packets and to display
target replies like ping do with ICMP replies. hping3 can handle fragmentation,
and almost arbitrary packet size and content, using the command line interface.

this package builds hping with tcl scripting support.

let me know if there is anything to change, I'm not used yet to packaging.

thanks,
Corentin

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---

---

From: Isaac Dunham <[email-masked]>
Date: Tue, 19 Jan 2016 07:28:54 -0800

> let me know if there is anything to change, I'm not used yet to packaging.

Looks like a typo in package() (hpin3 should presumably be hping3).

Quote $subpkgdir and $pkgdir ("$subpkgdir").

Send it all as one patch.
New APKBUILDS should be buildable from the start; creating a series of
patches like this:
1/4: add APKBUILD (references 1-foo.patch, 2-bar.patch, 3-baz.patch)
2/4: add 1-foo.patch
3/4: add 2-bar.patch
4/4: add 3-baz.patch

is needlessly cluttered, and likely to break autobuild scripts.
If you refer to a local source file, you should add it, the checksums,
and the reference in one commit.

Thanks,
Isaac Dunham

---

---

From: Timo Teras <[email-masked]>
Date: Thu, 21 Jan 2016 11:40:07 +0200

On Tue, 19 Jan 2016 07:28:54 -0800
Isaac Dunham <[email-masked]> wrote:

> > hping3 is a network tool able to send custom TCP/IP packets and to
> > display target replies like ping do with ICMP replies. hping3 can
> > handle fragmentation, and almost arbitrary packet size and content,
> > using the command line interface.
> > 

Yes, please flatten it all to one commit.

Additionally, you can look how to do github commitid based packaging.
See. e.g. main/bmd-tools for this:
http://git.alpinelinux.org/cgit/aports/tree/main/bmd-tools/APKBUILD

I believe the compression of manpages happens now automatic, so the
explicit gzip should not be needed in doc(). Well, you'd probably need
to install the .doc files before calling default_doc.

There was also few whitespace mismatches (tabs vs. spaces).

But other than these nitpicks on formatting, it looks good.

Please resubmit with fixes!

Thanks,
Timo

---

---

From: Corentin Henry <[email-masked]>
Date: Fri, 22 Jan 2016 13:21:20 +0000

> Please resubmit with fixes!

Thank you Timo and Isaac. Here is a new version, with (hopefully) all the
requested fixes:

    - fix typo (hpin -> hping)
    - convert hard tabs to spaces. I kept hard tabs in 
      10-add_tcl_version.patch though, since the patched file is using hard
      tabs.
      Let me know if you prefer otherwise.
    - do not zip the man pages
    - squash everything

Corentin

---
 testing/hping/10-add_tcl_version.patch    | 72 +++++++++++++++++++++++++++++++
 testing/hping/20-pass_CFLAGS_to_gcc.patch | 25 +++++++++++
 testing/hping/30-fix_bpf_include.patch    | 37 ++++++++++++++++
 testing/hping/APKBUILD                    | 72 +++++++++++++++++++++++++++++++
 4 files changed, 206 insertions(+)
 create mode 100644 testing/hping/10-add_tcl_version.patch
 create mode 100644 testing/hping/20-pass_CFLAGS_to_gcc.patch
 create mode 100644 testing/hping/30-fix_bpf_include.patch
 create mode 100644 testing/hping/APKBUILD

diff --git a/testing/hping/10-add_tcl_version.patch b/testing/hping/10-add_tcl_version.patch
new file mode 100644
index 0000000..9e6eae2
--- /dev/null
+++ b/testing/hping/10-add_tcl_version.patch
@@ -0,0 +1,72 @@
+From ab6a1f2d7d0b064514ee7cbf575b8ef4dd039d73 Mon Sep 17 00:00:00 2001
+From: Carsten Grohmann <[email-masked]>
+Date: Tue, 19 May 2015 17:55:42 +0200
+Subject: [PATCH] Quote variables and add new TCL versions "8.5" and "8.6"
+
+---
+ configure | 24 ++++++++++++------------
+ 1 file changed, 12 insertions(+), 12 deletions(-)
+
+diff --git a/configure b/configure
+index dab04ab..047712d 100755
+--- a/configure
++++ b/configure
+@@ -44,11 +44,11 @@ if [ ! "$CONFIGOSTYPE" ]; then
+ fi
+ 
+ # for BSD/OS use the historical name as it doesn't include '/'
+-if [  $CONFIGOSTYPE = "BSD/OS" ]; then
++if [  "$CONFIGOSTYPE" = "BSD/OS" ]; then
+ 	CONFIGOSTYPE=BSDI
+ fi
+ 
+-case $CONFIGOSTYPE in
++case "$CONFIGOSTYPE" in
+   SUNOS)
+     SOLARISLIB="-lsocket -lresolv -lnsl"
+     BUG='/* #define STUPID_SOLARIS_CHECKSUM_BUG */'
+@@ -63,31 +63,31 @@ esac
+ #
+ for TCLPATH_TRY in "/usr/bin/" "/usr/local/bin/" "/bin/"
+ do
+-	for TCLVER_TRY in "8.4" "8.3" "8.2" "8.1" "8.0"
++	for TCLVER_TRY in "8.6" "8.5" "8.4" "8.3" "8.2" "8.1" "8.0"
+ 	do
+-		if [ -z $TCLSH ]
++		if [ -z "$TCLSH" ]
+ 		then
+-			TCLSH_TRY=${TCLPATH_TRY}tclsh${TCLVER_TRY}
+-			if [ -f $TCLSH_TRY ]
++			TCLSH_TRY="${TCLPATH_TRY}tclsh${TCLVER_TRY}"
++			if [ -f "$TCLSH_TRY" ]
+ 			then
+-				TCLSH=$TCLSH_TRY
++				TCLSH="$TCLSH_TRY"
+ 				echo "===> Found Tclsh in: $TCLSH"
+ 			fi
+ 		fi
+ 	done
+ done
+-if [ -f $TCLSH ]
++if [ -f "$TCLSH" ]
+ then
+ 	TCL_VER=`echo puts \\$tcl_version | $TCLSH -`
+-	USE_TCL='-DUSE_TCL'
++	USE_TCL="-DUSE_TCL"
+ 	TCL_LIB="-ltcl${TCL_VER}"
+-	if [ -e /usr/include/tcl${TCL_VER} ]
++	if [ -e "/usr/include/tcl${TCL_VER}" ]
+ 	then
+ 		TCL_INC="-I/usr/include/tcl${TCL_VER}"
+-	elif [ -e /usr/include/tcl.h ]
++	elif [ -e "/usr/include/tcl.h" ]
+ 	then
+ 		TCL_INC=""
+-	elif [ -e /usr/local/include/tcl${TCL_VER} ]
++	elif [ -e "/usr/local/include/tcl${TCL_VER}" ]
+ 	then
+ 		TCL_INC="-I/usr/local/include/tcl${TCL_VER}"
+ 	else
+-- 
+2.7.0
+
diff --git a/testing/hping/20-pass_CFLAGS_to_gcc.patch b/testing/hping/20-pass_CFLAGS_to_gcc.patch
new file mode 100644
index 0000000..31d6689
--- /dev/null
+++ b/testing/hping/20-pass_CFLAGS_to_gcc.patch
@@ -0,0 +1,25 @@
+From 9b586fa0ae41cbf36e1043e6a5879d1bbc9e0ff6 Mon Sep 17 00:00:00 2001
+From: Corentin Henry <[email-masked]>
+Date: Mon, 11 Jan 2016 15:04:23 +0000
+Subject: [PATCH] add CFLAGS to gcc options
+
+---
+ Makefile.in | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Makefile.in b/Makefile.in
+index 5cccbdd..5b70092 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -9,7 +9,7 @@
+ CC= gcc
+ AR=/usr/bin/ar
+ RANLIB=/usr/bin/ranlib
+-CCOPT= -O2 -Wall @PCAP_INCLUDE@ @TCL_INC@ @USE_TCL@
++CCOPT= $(CFLAGS) -O2 -Wall @PCAP_INCLUDE@ @TCL_INC@ @USE_TCL@
+ DEBUG= -g
+ #uncomment the following if you need libpcap based build under linux
+ #(not raccomanded)
+-- 
+2.7.0
+
diff --git a/testing/hping/30-fix_bpf_include.patch b/testing/hping/30-fix_bpf_include.patch
new file mode 100644
index 0000000..c74ff79
--- /dev/null
+++ b/testing/hping/30-fix_bpf_include.patch
@@ -0,0 +1,37 @@
+From 73d4684bd0bbb1fbc82a290bcb742d76d0224647 Mon Sep 17 00:00:00 2001
+From: Corentin Henry <[email-masked]>
+Date: Mon, 11 Jan 2016 15:07:30 +0000
+Subject: [PATCH] fix bpf include
+
+---
+ libpcap_stuff.c | 1 -
+ script.c        | 1 -
+ 2 files changed, 2 deletions(-)
+
+diff --git a/libpcap_stuff.c b/libpcap_stuff.c
+index 26f9993..07ea1e6 100644
+--- a/libpcap_stuff.c
++++ b/libpcap_stuff.c
+@@ -16,7 +16,6 @@
+ #include <string.h>
+ #include <stdlib.h>
+ #include <sys/ioctl.h>
+-#include <net/bpf.h>
+ #include <pcap.h>
+ 
+ #include "globals.h"
+diff --git a/script.c b/script.c
+index 124370c..b2a328b 100644
+--- a/script.c
++++ b/script.c
+@@ -23,7 +23,6 @@
+ #include <sched.h>
+ 
+ #include <sys/ioctl.h>
+-#include <net/bpf.h>
+ #include <pcap.h>
+ 
+ #include "release.h"
+-- 
+2.7.0
+
diff --git a/testing/hping/APKBUILD b/testing/hping/APKBUILD
new file mode 100644
index 0000000..8f646a3
--- /dev/null
+++ b/testing/hping/APKBUILD
@@ -0,0 +1,72 @@
+# Contributor:
+# Maintainer: Corentin Henry <[email-masked]>
+pkgname=hping
+pkgver=0.r13.3547c7691742c6eaa31f8402e0ccbb81387c1b99
+pkgrel=1
+pkgdesc="network tool able to send custom TCP/IP packets and to display target replies"
+url="https://github.com/antirez/$pkgname"
+arch="all"
+license="GPL2"
+depends=""
+depends_dev=""
+makedepends="tcl-dev libpcap-dev"
+install=""
+subpackages="$pkgname-doc"
+source="http://dev.alpinelinux.org/archive/$pkgname/$pkgname-$pkgver.tar.gz
+        10-add_tcl_version.patch
+        20-pass_CFLAGS_to_gcc.patch
+        30-fix_bpf_include.patch"
+
+_builddir="$srcdir"/hping
+prepare() {
+        local i
+        cd "$_builddir"
+        echo $source
+        for i in $source; do
+                case $i in
+                *.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
+                esac
+        done
+}
+
+snapshot() {
+         abuild clean
+         mkdir -p "$srcdir"
+         cd "$srcdir"
+         msg "Checking out hping master branch"
+         git clone $url || return 1
+         tar zcf $pkgname-$pkgver.tar.gz hping || return 1
+}
+
+build() {
+        cd "$_builddir"
+        ./configure --prefix=/usr
+        make
+        make strip
+}
+
+package() {
+        cd "$_builddir"
+        install -D -m 755 hping3 "$pkgdir"/usr/sbin/hping3
+        ln -s "$pkgdir"/usr/sbin/hping3 "$pkgdir"/usr/sbin/hping
+        ln -s "$pkgdir"/usr/sbin/hping3 "$pkgdir"/usr/sbin/hping2
+}
+
+doc() {
+        cd "$_builddir"/docs
+        install -D -m 0644 hping2.8 "$subpkgdir"/usr/share/man/man8/hping2.8
+        install -D -m 0644 hping3.8 "$subpkgdir"/usr/share/man/man8/hping3.8
+        default_doc
+}
+md5sums="6cdce1aa966d00035038c3474dc7c41e  hping-0.r13.3547c7691742c6eaa31f8402e0ccbb81387c1b99.tar.gz
+b5b43469b3bc5451870c9214c178e380  10-add_tcl_version.patch
+05161223c57de36a3d07f7f6544cdcde  20-pass_CFLAGS_to_gcc.patch
+bc7819f6f76360b38f43447124f2e4d3  30-fix_bpf_include.patch"
+sha256sums="9cc450a609b88df77c575cb6df396c9189dc9caa67d86a7d871c21967cc77da9  hping-0.r13.3547c7691742c6eaa31f8402e0ccbb81387c1b99.tar.gz
+4b2ba6a21a7d14f6251bf7d186efceeef1dcf6261cab8429fe0e8b402dc4739e  10-add_tcl_version.patch
+dd33970382773f0cd0944ee2fc90d1e10a79c8a67e922662b7cb0f0491dee816  20-pass_CFLAGS_to_gcc.patch
+7dda17a55ca2e4ecb3003dfb84d804b30d3f030a1fcdf4ebdda65fa8a6fec410  30-fix_bpf_include.patch"
+sha512sums="c1051ecb7dae29afe1c3e931c1f85dc3f0c66397ad483bca383915e1ed96bb3e3ef05a824cc887341b4688d5d5e454d9ca122d7f38c78f78d45e1435257eeb61  hping-0.r13.3547c7691742c6eaa31f8402e0ccbb81387c1b99.tar.gz
+3d7629a77ddbed4231172c6702b0f3a6929e19a303c5629ecb014ab4cd593763a3573507c9cb2f45fc5ad2032d7f95410bea9ef8a68a6508695d77dfd8e00e9b  10-add_tcl_version.patch
+09b2b04bb9a6788a29da546c07c6301973757dbd67bd00a4e71dde2c762f9b39ad5c9e464a89c92569af762fd3fcecbcc01749f0f8bb4f416ab75ed95e0cae67  20-pass_CFLAGS_to_gcc.patch
+660a434837e8d0afeac9b3a1ca301ca8b8585bf02dcba79fa24b4d9b479336fc774a7c9b0e19e63b6782535a9c0c0a1ddb077735e0d0bb1ed7a41e77b581ac89  30-fix_bpf_include.patch"
-- 
2.7.0

---

---

From: Natanael Copa <[email-masked]>
Date: Wed, 10 Feb 2016 11:40:53 +0100

On Fri, 22 Jan 2016 13:21:20 +0000

It does not build:

>>> hping: Checking sanity of /home/ncopa/aports/testing/hping/APKBUILD...
>>> ERROR: hping: 0.r13.3547c7691742c6eaa31f8402e0ccbb81387c1b99 is not
>>> a valid version

I also think upstream should fix this issue before we package it:
https://github.com/antirez/hping/issues/20

-nc

---