Patches for aports can be sent to this list

3 2

[alpine-aports] [PATCH v3] testing/flow-tools: new aport

Valery Kartel
Details
Message ID
<20170426130420.20396-1-valery.kartel@gmail.com>
Sender timestamp
1493211860
DKIM signature
missing
Download raw message
Patch: +163 -0
Tool set for working with NetFlow data
https://code.google.com/p/flow-tools

---
v1 -> v2: split to subpackages

v2 -> v3: fix and improve $command_args in init-script
---
 testing/flow-tools/APKBUILD                 | 106 ++++++++++++++++++++++++++++
 testing/flow-tools/flow-capture.confd       |  33 +++++++++
 testing/flow-tools/flow-capture.initd       |  18 +++++
 testing/flow-tools/flow-capture.pre-install |   6 ++
 4 files changed, 163 insertions(+)
 create mode 100644 testing/flow-tools/APKBUILD
 create mode 100644 testing/flow-tools/flow-capture.confd
 create mode 100644 testing/flow-tools/flow-capture.initd
 create mode 100644 testing/flow-tools/flow-capture.pre-install

diff --git a/testing/flow-tools/APKBUILD b/testing/flow-tools/APKBUILD
new file mode 100644
index 0000000000..4d6c222889
--- /dev/null
+++ b/testing/flow-tools/APKBUILD
@@ -0,0 +1,106 @@
+# Contributor: Valery Kartel <valery.kartel@gmail.com>
+# Maintainer: Valery Kartel <valery.kartel@gmail.com>
+pkgname=flow-tools
+pkgver=0.68.5.1
+pkgrel=0
+_pkgreal=flow
+pkgdesc="Tool set for working with NetFlow data"
+url="https://code.google.com/p/flow-tools"
+arch="all"
+license="BSD"
+options="!check"
+install="$_pkgreal-capture.pre-install"
+pkgusers=$_pkgreal
+pkggroups=$_pkgreal
+depends_dev="perl"
+makedepends="zlib-dev"
+subpackages="$pkgname-doc libft-dev libft:libs
+	$_pkgreal-capture $_pkgreal-log2rrd::noarch
+	$_pkgreal-rptfmt::noarch $_pkgreal-rpt2rrd::noarch
+	"
+_tools="cat dscan expire export fanout filter gen header import
+	mask merge nfilter print receive report send split stat tag xlate"
+_tools_list="$_pkgreal-capture"
+for _tool in $_tools; do
+	subpackages="$subpackages $_pkgreal-$_tool:_tool"
+	_tools_list="$_tools_list $_pkgreal-$_tool"
+done
+source="https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/$pkgname/$pkgname-$pkgver.tar.bz2
+	$_pkgreal-capture.initd
+	$_pkgreal-capture.confd"
+builddir="$srcdir/$pkgname-$pkgver"
+
+prepare() {
+	default_prepare || return 1
+
+	cd "$builddir"
+	local file
+	for file in bin/flow-rpt*; do
+		sed -i -e "s:/usr/local/netflow/var:/etc/$_pkgreal:" $file || return 1
+	done
+	update_config_sub
+}
+
+build() {
+	cd "$builddir"
+	./configure \
+		--build=$CBUILD \
+		--host=$CHOST \
+		--target=$CTARGET \
+		--prefix=/usr \
+		--sysconfdir=/etc/$_pkgreal \
+		--localstatedir=/var/lib/$_pkgreal \
+		|| return 1
+	make
+}
+
+package() {
+	depends=$_tools_list
+	make -C "$builddir" DESTDIR="$pkgdir" install
+}
+
+dev() {
+	default_dev || return 1
+
+	mkdir -p "$subpkgdir"/usr || return 1
+	mv "$pkgdir"/usr/share "$subpkgdir"/usr || return 1
+}
+
+libs() {
+	default_libs || return 1
+	mv "$pkgdir"/etc "$subpkgdir" || return 1
+}
+
+_tool() {
+	pkgdesc="$pkgdesc (${subpkgname#$_pkgreal-} tool)"
+	mkdir -p "$subpkgdir"/usr/bin || return 1
+	mv "$pkgdir"/usr/bin/$subpkgname "$subpkgdir"/usr/bin || return 1
+}
+
+capture() {
+	_tool || return 1
+	install -Dm644 "$srcdir"/$subpkgname.confd \
+		"$subpkgdir"/etc/conf.d/$subpkgname || return 1
+	install -Dm755 "$srcdir"/$subpkgname.initd \
+		"$subpkgdir"/etc/init.d/$subpkgname || return 1
+	install -Dm750 -o $_pkgreal -g $_pkgreal -d "$subpkgdir"/var/lib/$_pkgreal
+}
+
+rptfmt() {
+	_tool || return 1
+	depends="python2"
+}
+
+rpt2rrd() {
+	_tool || return 1
+	depends="python2 py-rrd"
+}
+
+log2rrd() {
+	_tool || return 1
+	depends="python2 py-rrd"
+}
+
+sha512sums="ae17ba39854daa8ef3deecd3a554bb6d1fa47648cb791d8225a40bec13f65bf0692871660b2c3490d133b1251875c323d066bb0c0483eceb0707cec9b7714c57  flow-tools-0.68.5.1.tar.bz2
+3692d8ae28de6b7aea65714ba66f7f561a0f40500dc79804f02d631c1eb2ba72caf97018a08b3e1ee89c1df1f1e50c845646911224299871d208af9254db4200  flow-capture.initd
+1716f9dfc8ac23aedce95cc692f18f4b17865748aa63780347b94eb8fbc78f6509a66438bd07fa9e0871bba05f03a129ef084615533d513b625320f3eb3bb373  flow-capture.confd"
diff --git a/testing/flow-tools/flow-capture.confd b/testing/flow-tools/flow-capture.confd
new file mode 100644
index 0000000000..8b40f7bcae
--- /dev/null
+++ b/testing/flow-tools/flow-capture.confd
@@ -0,0 +1,33 @@
+# port to listen on
+#FLOW_PORT=2055
+
+# local ip. if configured flow-capture will only ps flows sent to this ip.
+#FLOW_LOCAL_IP=0
+
+# remote ip. If this is configured only flows from this exporter will be accepted
+# by default we will accept any flows sent to us
+#FLOW_REMOTE_IP=0
+
+# dir we will be saving flows and working in
+#FLOW_WORKDIR=/var/lib/flow
+
+# user to run as
+#FLOW_USER=flow
+
+# This is the default and should be left unless you know what you are doing
+#FLOW_VER=5
+
+# You probably don't want to change this, but in case you do - nest level
+#FLOW_NEST=0
+
+# Retain the maximum number of files so that the total storage is less than SIZE
+# The letters b,K,M,G can be used as multipliers, ie 16 Megabytes is 16M.
+#FLOW_SIZE=1G
+
+# number of rotations per day
+#FLOW_ROTATIONS=287
+
+# program used to rotate 
+#FLOW_ROTATE_PROG="/var/lib/flow/rotate.sh"
+
+#FLOW_ARGS=
diff --git a/testing/flow-tools/flow-capture.initd b/testing/flow-tools/flow-capture.initd
new file mode 100644
index 0000000000..5dfdddff7c
--- /dev/null
+++ b/testing/flow-tools/flow-capture.initd
@@ -0,0 +1,18 @@
+#!/sbin/openrc-run
+
+name="NetFlow capture"
+command=/usr/bin/flow-capture
+command_args="$FLOW_ARGS \
+	${FLOW_VER:+-V $FLOW_VER} \
+	${FLOW_NEST:+-N $FLOW_NEST} \
+	${FLOW_SIZE:+-E $FLOW_SIZE} \
+	${FLOW_ROTATIONS:+-n $FLOW_ROTATIONS} \
+	${FLOW_ROTATE_PROG:+-R $FLOW_ROTATE_PROG} \
+	-D -w ${FLOW_WORKDIR:-/var/lib/flow} ${FLOW_LOCAL_IP:-0}/${FLOW_REMOTE_IP:-0}/${FLOW_PORT:-2055}"
+command_background=yes
+pidfile=/run/$RC_SVCNAME.pid
+start_stop_daemon_args="-u ${FLOW_USER:-flow}"
+
+depend() {
+	need net localmount
+}
diff --git a/testing/flow-tools/flow-capture.pre-install b/testing/flow-tools/flow-capture.pre-install
new file mode 100644
index 0000000000..316e61ba4f
--- /dev/null
+++ b/testing/flow-tools/flow-capture.pre-install
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+addgroup -S flow 2>/dev/null
+adduser -S -D -H -h /var/lib/flow -s /sbin/nologin -G flow -g flow flow 2>/dev/null
+
+exit 0
-- 
2.12.2



---
Unsubscribe:  alpine-aports+unsubscribe@lists.alpinelinux.org
Help:         alpine-aports+help@lists.alpinelinux.org
---
Leonardo Arena
Details
Message ID
<41e904e6-570b-bd2e-6e24-45b75de244f0@gmail.com>
In-Reply-To
<20170426130420.20396-1-valery.kartel@gmail.com> (view parent)
Sender timestamp
1496126198
DKIM signature
missing
Download raw message
Hi,


On 04/26/2017 03:04 PM, Valery Kartel wrote:
> Tool set for working with NetFlow data
> https://code.google.com/p/flow-tools
>
> ---
> v1 -> v2: split to subpackages
>
> v2 -> v3: fix and improve $command_args in init-script
> ---
>   testing/flow-tools/APKBUILD                 | 106 ++++++++++++++++++++++++++++
>   testing/flow-tools/flow-capture.confd       |  33 +++++++++
>   testing/flow-tools/flow-capture.initd       |  18 +++++
>   testing/flow-tools/flow-capture.pre-install |   6 ++
>   4 files changed, 163 insertions(+)
>   create mode 100644 testing/flow-tools/APKBUILD
>   create mode 100644 testing/flow-tools/flow-capture.confd
>   create mode 100644 testing/flow-tools/flow-capture.initd
>   create mode 100644 testing/flow-tools/flow-capture.pre-install
>
> diff --git a/testing/flow-tools/APKBUILD b/testing/flow-tools/APKBUILD
> new file mode 100644
> index 0000000000..4d6c222889
> --- /dev/null
> +++ b/testing/flow-tools/APKBUILD
> @@ -0,0 +1,106 @@
> +# Contributor: Valery Kartel <valery.kartel@gmail.com>
> +# Maintainer: Valery Kartel <valery.kartel@gmail.com>
> +pkgname=flow-tools
> +pkgver=0.68.5.1
> +pkgrel=0
> +_pkgreal=flow
> +pkgdesc="Tool set for working with NetFlow data"
> +url="https://code.google.com/p/flow-tools"
> +arch="all"
> +license="BSD"
> +options="!check"
> +install="$_pkgreal-capture.pre-install"
> +pkgusers=$_pkgreal
> +pkggroups=$_pkgreal
> +depends_dev="perl"
> +makedepends="zlib-dev"
> +subpackages="$pkgname-doc libft-dev libft:libs
> +	$_pkgreal-capture $_pkgreal-log2rrd::noarch
> +	$_pkgreal-rptfmt::noarch $_pkgreal-rpt2rrd::noarch
> +	"
> +_tools="cat dscan expire export fanout filter gen header import
> +	mask merge nfilter print receive report send split stat tag xlate"
> +_tools_list="$_pkgreal-capture"
> +for _tool in $_tools; do
> +	subpackages="$subpackages $_pkgreal-$_tool:_tool"
> +	_tools_list="$_tools_list $_pkgreal-$_tool"
> +done

I see that 26 subpackages are created which are few KB in size. Is it 
really recommended to have such amount of subpkgs or the APKBUILD could 
be simplified?

Thanks!

/eo




---
Unsubscribe:  alpine-aports+unsubscribe@lists.alpinelinux.org
Help:         alpine-aports+help@lists.alpinelinux.org
---
Valery Kartel
Details
Message ID
<CAKTwcDP0t6aiTiRhbK1Kegjz3rf=3y20=KTk9qRkMuwtpBViYQ@mail.gmail.com>
In-Reply-To
<41e904e6-570b-bd2e-6e24-45b75de244f0@gmail.com> (view parent)
Sender timestamp
1496140871
DKIM signature
missing
Download raw message
Hi,

All those subpackages are very specific tools. Most of them are used very
rarely. I have no idea how to combine it in a set, so I just split it one
by one.

In real life, to collect, filter and have readable output I use the only 3
of them: flow-capture, flow-nfilter, flow-print.

Somebody, who have simple filter rules, can change flow-nfilter to
flow-filter.
If somebody want to have a deal with several flow-files in a time, can add
flow-cat command, etc.

So it's like "lego" constructor.

2017-05-30 9:36 GMT+03:00 Leonardo Arena <rnalrd@gmail.com>:

> Hi,
>
>
> On 04/26/2017 03:04 PM, Valery Kartel wrote:
>
>> Tool set for working with NetFlow data
>> https://code.google.com/p/flow-tools
>>
>> ---
>> v1 -> v2: split to subpackages
>>
>> v2 -> v3: fix and improve $command_args in init-script
>> ---
>>   testing/flow-tools/APKBUILD                 | 106
>> ++++++++++++++++++++++++++++
>>   testing/flow-tools/flow-capture.confd       |  33 +++++++++
>>   testing/flow-tools/flow-capture.initd       |  18 +++++
>>   testing/flow-tools/flow-capture.pre-install |   6 ++
>>   4 files changed, 163 insertions(+)
>>   create mode 100644 testing/flow-tools/APKBUILD
>>   create mode 100644 testing/flow-tools/flow-capture.confd
>>   create mode 100644 testing/flow-tools/flow-capture.initd
>>   create mode 100644 testing/flow-tools/flow-capture.pre-install
>>
>> diff --git a/testing/flow-tools/APKBUILD b/testing/flow-tools/APKBUILD
>> new file mode 100644
>> index 0000000000..4d6c222889
>> --- /dev/null
>> +++ b/testing/flow-tools/APKBUILD
>> @@ -0,0 +1,106 @@
>> +# Contributor: Valery Kartel <valery.kartel@gmail.com>
>> +# Maintainer: Valery Kartel <valery.kartel@gmail.com>
>> +pkgname=flow-tools
>> +pkgver=0.68.5.1
>> +pkgrel=0
>> +_pkgreal=flow
>> +pkgdesc="Tool set for working with NetFlow data"
>> +url="https://code.google.com/p/flow-tools"
>> +arch="all"
>> +license="BSD"
>> +options="!check"
>> +install="$_pkgreal-capture.pre-install"
>> +pkgusers=$_pkgreal
>> +pkggroups=$_pkgreal
>> +depends_dev="perl"
>> +makedepends="zlib-dev"
>> +subpackages="$pkgname-doc libft-dev libft:libs
>> +       $_pkgreal-capture $_pkgreal-log2rrd::noarch
>> +       $_pkgreal-rptfmt::noarch $_pkgreal-rpt2rrd::noarch
>> +       "
>> +_tools="cat dscan expire export fanout filter gen header import
>> +       mask merge nfilter print receive report send split stat tag xlate"
>> +_tools_list="$_pkgreal-capture"
>> +for _tool in $_tools; do
>> +       subpackages="$subpackages $_pkgreal-$_tool:_tool"
>> +       _tools_list="$_tools_list $_pkgreal-$_tool"
>> +done
>>
>
> I see that 26 subpackages are created which are few KB in size. Is it
> really recommended to have such amount of subpkgs or the APKBUILD could be
> simplified?
>
> Thanks!
>
> /eo
>
>
>
Leonardo Arena
Details
Message ID
<883b5f30-5d74-ec02-8de1-421682d9f315@gmail.com>
In-Reply-To
<CAKTwcDP0t6aiTiRhbK1Kegjz3rf=3y20=KTk9qRkMuwtpBViYQ@mail.gmail.com> (view parent)
Sender timestamp
1496671048
DKIM signature
missing
Download raw message
Sorry for getting back so late.

Given that subpkgs are few KBs each, and don't depend on any other big 
package, I'd just ship a monolithic package.

Thanks

/eo


On 05/30/2017 12:41 PM, Valery Kartel wrote:
> Hi,
>
> All those subpackages are very specific tools. Most of them are used 
> very rarely. I have no idea how to combine it in a set, so I just 
> split it one by one.
>
> In real life, to collect, filter and have readable output I use the 
> only 3 of them: flow-capture, flow-nfilter, flow-print.
>
> Somebody, who have simple filter rules, can change flow-nfilter to 
> flow-filter.
> If somebody want to have a deal with several flow-files in a time, can 
> add flow-cat command, etc.
>
> So it's like "lego" constructor.
>
> 2017-05-30 9:36 GMT+03:00 Leonardo Arena <rnalrd@gmail.com 
> <mailto:rnalrd@gmail.com>>:
>
>     Hi,
>
>
>     On 04/26/2017 03:04 PM, Valery Kartel wrote:
>
>         Tool set for working with NetFlow data
>         https://code.google.com/p/flow-tools
>         <https://code.google.com/p/flow-tools>
>
>         ---
>         v1 -> v2: split to subpackages
>
>         v2 -> v3: fix and improve $command_args in init-script
>         ---
>           testing/flow-tools/APKBUILD                 | 106
>         ++++++++++++++++++++++++++++
>           testing/flow-tools/flow-capture.confd       |  33 +++++++++
>           testing/flow-tools/flow-capture.initd       |  18 +++++
>           testing/flow-tools/flow-capture.pre-install |   6 ++
>           4 files changed, 163 insertions(+)
>           create mode 100644 testing/flow-tools/APKBUILD
>           create mode 100644 testing/flow-tools/flow-capture.confd
>           create mode 100644 testing/flow-tools/flow-capture.initd
>           create mode 100644 testing/flow-tools/flow-capture.pre-install
>
>         diff --git a/testing/flow-tools/APKBUILD
>         b/testing/flow-tools/APKBUILD
>         new file mode 100644
>         index 0000000000..4d6c222889
>         --- /dev/null
>         +++ b/testing/flow-tools/APKBUILD
>         @@ -0,0 +1,106 @@
>         +# Contributor: Valery Kartel <valery.kartel@gmail.com
>         <mailto:valery.kartel@gmail.com>>
>         +# Maintainer: Valery Kartel <valery.kartel@gmail.com
>         <mailto:valery.kartel@gmail.com>>
>         +pkgname=flow-tools
>         +pkgver=0.68.5.1
>         +pkgrel=0
>         +_pkgreal=flow
>         +pkgdesc="Tool set for working with NetFlow data"
>         +url="https://code.google.com/p/flow-tools
>         <https://code.google.com/p/flow-tools>"
>         +arch="all"
>         +license="BSD"
>         +options="!check"
>         +install="$_pkgreal-capture.pr
>         <http://pkgreal-capture.pr>e-install"
>         +pkgusers=$_pkgreal
>         +pkggroups=$_pkgreal
>         +depends_dev="perl"
>         +makedepends="zlib-dev"
>         +subpackages="$pkgname-doc libft-dev libft:libs
>         +       $_pkgreal-capture $_pkgreal-log2rrd::noarch
>         +       $_pkgreal-rptfmt::noarch $_pkgreal-rpt2rrd::noarch
>         +       "
>         +_tools="cat dscan expire export fanout filter gen header import
>         +       mask merge nfilter print receive report send split
>         stat tag xlate"
>         +_tools_list="$_pkgreal-capture"
>         +for _tool in $_tools; do
>         +       subpackages="$subpackages $_pkgreal-$_tool:_tool"
>         +       _tools_list="$_tools_list $_pkgreal-$_tool"
>         +done
>
>
>     I see that 26 subpackages are created which are few KB in size. Is
>     it really recommended to have such amount of subpkgs or the
>     APKBUILD could be simplified?
>
>     Thanks!
>
>     /eo
>
>
>