Mail archive
alpine-aports

[alpine-aports] [PATCH] testing/flowd: new aport

From: Valery Kartel <valery.kartel_at_gmail.com>
Date: Tue, 11 Apr 2017 17:12:36 +0300

https://code.google.com/p/flowd
Small, fast and secure NetFlow collector
---
 testing/flowd/APKBUILD          | 88 +++++++++++++++++++++++++++++++++++++++++
 testing/flowd/fix_path.patch    | 40 +++++++++++++++++++
 testing/flowd/fix_user.patch    | 11 ++++++
 testing/flowd/flowd.initd       | 27 +++++++++++++
 testing/flowd/flowd.pre-install |  6 +++
 5 files changed, 172 insertions(+)
 create mode 100644 testing/flowd/APKBUILD
 create mode 100644 testing/flowd/fix_path.patch
 create mode 100644 testing/flowd/fix_user.patch
 create mode 100644 testing/flowd/flowd.initd
 create mode 100644 testing/flowd/flowd.pre-install
diff --git a/testing/flowd/APKBUILD b/testing/flowd/APKBUILD
new file mode 100644
index 0000000000..0d003b3ce8
--- /dev/null
+++ b/testing/flowd/APKBUILD
_at_@ -0,0 +1,88 @@
+# Contributor: Valery Kartel <valery.kartel_at_gmail.com>
+# Maintainer: Valery Kartel <valery.kartel_at_gmail.com>
+pkgname=flowd
+pkgver=0.9.1
+pkgrel=0
+pkgdesc="Small, fast and secure NetFlow collector"
+url="https://code.google.com/p/flowd"
+arch="all"
+license="BSD"
+install="$pkgname.pre-install"
+pkgusers=$pkgname
+makedepends="byacc perl-dev python2-dev"
+subpackages="$pkgname-dev $pkgname-doc py-$pkgname:_py
+	perl-$pkgname:_perl perl-$pkgname-doc:_perldoc:noarch
+	$pkgname-rrd::noarch $pkgname-tools::noarch"
+source="https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/$pkgname/$pkgname-$pkgver.tar.gz
+	fix_path.patch
+	fix_user.patch
+	$pkgname.initd"
+builddir="$srcdir/$pkgname-$pkgver"
+
+build() {
+	cd "$builddir"
+	./configure \
+		--prefix=/usr \
+		--localstatedir=/var \
+		--sysconfdir=/etc/$pkgname \
+		|| return 1
+	make || return 1
+
+	# python2
+	python2 setup.py build || return 1
+
+	# perl
+	cd Flowd-perl
+	CFLAGS=$(perl -MConfig -E 'say $Config{ccflags}')
+	PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
+	make
+}
+
+check() {
+	make -C "$builddir"/Flowd-perl test
+}
+
+package() {
+	make -C "$builddir" DESTDIR="$pkgdir" install || return 1
+	install -dm750 -o $pkgname "$pkgdir"/var/lib/$pkgname || return 1
+	install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
+}
+
+_perl() {
+	pkgdesc="$pkgdesc (perl module)"
+	make -C "$builddir"/Flowd-perl DESTDIR="$subpkgdir" install || return 1
+	find "$subpkgdir" \( -name perllocal.pod -o -name .packlist \) -delete || return 1
+	mkdir -p "$subpkgdir-doc"/usr || return 1
+	mv "$subpkgdir"/usr/share "$subpkgdir-doc"/usr
+}
+
+_perldoc() {
+	pkgdesc="$pkgdesc (perl module documentation)"
+	install_if="docs perl-$pkgname=$pkgver-r$pkgrel"
+}
+
+_py() {
+	provides="py2-$pkgname"
+	pkgdesc="$pkgdesc (python2 bindings)"
+	cd "$builddir"
+	python2 setup.py install --prefix=/usr --root="$subpkgdir"
+}
+
+rrd() {
+	pkgdesc="$pkgdesc (simple interface to rrd)"
+	depends="python2 rrdtool py-rrd py-$pkgname"
+	mkdir -p "$subpkgdir"/usr/share/$pkgname/rrd || return 1
+	cp "$builddir"/tools/flowrrd/*.* "$subpkgdir"/usr/share/$pkgname/rrd
+}
+
+tools() {
+	pkgdesc="$pkgdesc (various tools)"
+	depends="perl python2 perl-$pkgname perl-dbd-sqlite py-$pkgname"
+	mkdir -p "$subpkgdir"/usr/share/$pkgname || return 1
+	cp "$builddir"/tools/*.* "$subpkgdir"/usr/share/$pkgname
+}
+
+sha512sums="c86d810de9a163206525c4ac12029d650209a370213d701d38b0e7ea746e087d2a0f80ab1657ccca87851cdf64628813666028e267529d6b7391b63542230967  flowd-0.9.1.tar.gz
+427a0b690519ddeb28da581ba7740faa6de9c6baf40ba285ad82f5652def3c950c8b080ca677de9748eea6cc1c2c5ab38559a139655e6cb176b021a5a9d5d912  fix_path.patch
+5264f4e913464c7cd6957ea4ef2a458551e3b52c66d1b709e90bfbe014327b72fbff52e282acbf6a2222972ca96f5908410f6ab51c3d8a161e9eef111634d8f2  fix_user.patch
+4aed4356a94f4e8a1d8c63d1418bca7e8cd3d43f5c04617432e404751c806970a4a1320d201df6db9a48bca673925a51d94d239e7196a676b47c40e2efb55598  flowd.initd"
diff --git a/testing/flowd/fix_path.patch b/testing/flowd/fix_path.patch
new file mode 100644
index 0000000000..42b672dbf2
--- /dev/null
+++ b/testing/flowd/fix_path.patch
_at_@ -0,0 +1,40 @@
+--- a/flowd.conf
++++ b/flowd.conf
+_at_@ -1,7 +1,5 @@
+-# $Id: flowd.conf,v 1.15 2005/05/14 06:04:48 djm Exp $
+-
+ # Specify where flowd should store its flow records
+-logfile "/var/log/flowd"
++logfile "/var/lib/flowd/data"
+ 
+ # Specify what addresses/ports flowd should listen on.
+ # Multiple addresses may be specified
+--- a/flowd.conf.5.in
++++ b/flowd.conf.5.in
+_at_@ -156,7 +156,7 @@
+ .Pp
+ For example,
+ .Bd -literal -offset indent
+-logfile "/var/log/flowd.bin"
++logfile "/var/lib/flowd/data"
+ .Ed
+ .Pp
+ There is no default value for this option and it it mandatory 
+_at_@ -172,7 +172,7 @@
+ .Pp
+ For example,
+ .Bd -literal -offset indent
+-logsock "/var/log/flowd.sock"
++logsock "/var/lib/flowd/socket"
+ .Ed
+ .Pp
+ This option accepts the modifier
+_at_@ -184,7 +184,7 @@
+ .Pp
+ For example,
+ .Bd -literal -offset indent
+-logsock "/var/log/flowd.sock" bufsize 65536
++logsock "/var/lib/flowd/socket" bufsize 65536
+ .Ed
+ .Pp
+ There is no default value for
diff --git a/testing/flowd/fix_user.patch b/testing/flowd/fix_user.patch
new file mode 100644
index 0000000000..12800d0442
--- /dev/null
+++ b/testing/flowd/fix_user.patch
_at_@ -0,0 +1,11 @@
+--- a/flowd.h
++++ b/flowd.h
+_at_@ -35,7 +35,7 @@
+ 
+ #define DEFAULT_CONFIG			SYSCONFDIR "/flowd.conf"
+ #define DEFAULT_PIDFILE			PIDFILEDIR "/flowd.pid"
+-#define PRIVSEP_USER			"_flowd"
++#define PRIVSEP_USER			"flowd"
+ 
+ /* Initial stateholding limits */
+ /* XXX these are not actually tunable yet */
diff --git a/testing/flowd/flowd.initd b/testing/flowd/flowd.initd
new file mode 100644
index 0000000000..fefaff9c2d
--- /dev/null
+++ b/testing/flowd/flowd.initd
_at_@ -0,0 +1,27 @@
+#!/sbin/openrc-run
+
+description="NetFlow –°ollector"
+command=/usr/sbin/flowd
+command_args="-g"
+command_background=yes
+pidfile=/run/flowd.pid
+required_files=/etc/flowd/flowd.conf
+extra_started_commands="reload reopen"
+description_reload="Reload configuration"
+description_reopen="Reopen log files"
+
+depend() {
+	need localmount net
+}
+
+reload() {
+	ebegin "Reloading $RC_SVCNAME"
+	start-stop-daemon --signal HUP --pidfile $pidfile
+	eend $?
+}
+
+reopen() {
+	ebegin "Reopening $RC_SVCNAME log files"
+	start-stop-daemon --signal USR1 --pidfile $pidfile
+	eend $?
+}
diff --git a/testing/flowd/flowd.pre-install b/testing/flowd/flowd.pre-install
new file mode 100644
index 0000000000..52d6273b88
--- /dev/null
+++ b/testing/flowd/flowd.pre-install
_at_@ -0,0 +1,6 @@
+#!/bin/sh
+
+addgroup -S flowd 2>/dev/null
+adduser -S -D -H -h /var/lib/flowd -s /sbin/nologin -G flowd -g flowd flowd 2>/dev/null
+
+exit 0
-- 
2.12.2
---
Unsubscribe:  alpine-aports+unsubscribe_at_lists.alpinelinux.org
Help:         alpine-aports+help_at_lists.alpinelinux.org
---
Received on Tue Apr 11 2017 - 17:12:36 UTC