Mail archive
alpine-aports

[alpine-aports] [PATCH] community/softflowd: take maintainership

From: Valery Kartel <valery.kartel_at_gmail.com>
Date: Thu, 13 Apr 2017 17:46:44 +0300

fix url
add !check
remove unneeded code in apkbuild, cleanups
remade init script (compatible with old one but more functional)
---
 community/softflowd/APKBUILD        | 54 ++++++++++---------------
 community/softflowd/softflowd.confd | 12 ++----
 community/softflowd/softflowd.initd | 78 +++++++++++++++----------------------
 3 files changed, 55 insertions(+), 89 deletions(-)
diff --git a/community/softflowd/APKBUILD b/community/softflowd/APKBUILD
index 020cbefe03..5a2fad4b08 100644
--- a/community/softflowd/APKBUILD
+++ b/community/softflowd/APKBUILD
_at_@ -1,52 +1,38 @@
 # Contributor: Leonardo Arena <rnalrd_at_alpinelinux.org>
-# Maintainer:
+# Maintainer: Valery Kartel <valery.kartel_at_gmail.com>
 pkgname=softflowd
 pkgver=0.9.9
-pkgrel=0
-pkgdesc="Flow-based network traffic analyser "
-url="http://www.mindrot.org/projects/softflowd/"
+pkgrel=1
+pkgdesc="A software NetFlow probe"
+url="https://code.google.com/p/softflowd"
 arch="all"
 license="BSD"
-depends=
-depends_dev=
-makedepends="$depends_dev libpcap-dev"
-install=
+options="!check"
+makedepends="libpcap-dev"
 subpackages="$pkgname-doc"
-source="https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/softflowd/softflowd-$pkgver.tar.gz
-	softflowd.initd
-	softflowd.confd
+source="https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/$pkgname/$pkgname-$pkgver.tar.gz
+	$pkgname.initd
+	$pkgname.confd
 	"
-
-
-_builddir="$srcdir"/$pkgname-$pkgver
-
-prepare() {
-	cd "$_builddir"
-	grep -l "#include <sys/poll.h>" * | xargs sed -i 's|sys/poll.h|poll.h|g'
-}
+builddir="$srcdir/$pkgname-$pkgver"
 
 build() {
-	cd "$_builddir"
+	cd "$builddir"
 	./configure --prefix=/usr \
 		--sysconfdir=/etc \
+		--localstatedir=/ \
 		--mandir=/usr/share/man \
-		--infodir=/usr/share/info
-	make || return 1
+		--infodir=/usr/share/info \
+		|| return 1
+	make
 }
 
 package() {
-	cd "$_builddir"
-	make DESTDIR="$pkgdir" install
-	install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
-	install -m644 -D "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
+	make -C "$builddir" DESTDIR="$pkgdir" install || return 1
+	install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname || return 1
+	install -Dm644 "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
 }
 
-md5sums="ba83e2715e6250e6645ebcaa9ae1009d  softflowd-0.9.9.tar.gz
-1dc4e097474bfa6bcf471f5b6ed6e2e1  softflowd.initd
-7eab9e84a8711613d83efbaa79cda3fe  softflowd.confd"
-sha256sums="2313f2c50ea9b3f2db3524e38ec7cd71f9a6e885ac2e3b55ab037bccf8173612  softflowd-0.9.9.tar.gz
-1cb28ef2fd8d0ff0082c856812a26cce728332293115aa6e4fd8e877083a3568  softflowd.initd
-f8368e88d248d420dfb8b877c53f666116c195763f40323868b52d2345b2c45c  softflowd.confd"
 sha512sums="4d579c2a087c0f3cd4d2020bcfbddf9dab73254e40678b3509c93bec212bf8b5692f76bfb4e766577e431ff508f0bce0a2cf326184f192e3c5dc8ddf38514dbd  softflowd-0.9.9.tar.gz
-40b671b5dc126e3b58761156eadb7b172fe8cd23f04e43c90270fbfba9c7542a7adc9a496da557143fa025af3ee6644e4732a74096a66bbaf98d3cadd6d01149  softflowd.initd
-3e9ff7efb2f63519ed710af8b744a264c0ce97f22af1e1d2d4ec8e071276ff42e482183715eebba8b25ff6270afac1fe9620a9c69dc5dbda889d44b141d8cb09  softflowd.confd"
+a049158fe474bb76e497613a7e2109b92047a37210bfe695b18b50cf7f5be5407896a11927d685fc03dec899c50bd6dbfeffdccf8e918ba515cfcab5dbd2b2a9  softflowd.initd
+10b536cb5d32edbfe5d1a09e2b4ded4d95cb2bbfbe44cdcf267958efe1cde440f0caf4f60e41b4a59164a471bf430527912daf2c47df42f0dc47997352689e5d  softflowd.confd"
diff --git a/community/softflowd/softflowd.confd b/community/softflowd/softflowd.confd
index 3823c80c4d..7f31d779b4 100644
--- a/community/softflowd/softflowd.confd
+++ b/community/softflowd/softflowd.confd
_at_@ -1,10 +1,4 @@
-# Copyright 1999-2012 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# Copy conf file to softflowd.interface
-
-# SOFTFLOWD_COLLECTOR=host:port
-# SOFTFLOWD_TIMEOUTS="maxlife=600"
-# SOFTFLOWD_MAXFLOWS=17000
-# SOFTFLOWD_EXTRA=
-# SOFTFLOWD_INTERFACE_IDX=
+# SOFTFLOWD_COLLECTOR=<host:port>
+# SOFTFLOWD_INTERFACE=[index:]eth0
 
+# SOFTFLOWD_EXTRA="-m 17000 -t maxlife=600"
diff --git a/community/softflowd/softflowd.initd b/community/softflowd/softflowd.initd
index 3cf1e4231b..c6e05afc97 100644
--- a/community/softflowd/softflowd.initd
+++ b/community/softflowd/softflowd.initd
_at_@ -1,55 +1,41 @@
 #!/sbin/openrc-run
-# Copyright 1999-2012 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/net-analyzer/softflowd/files/softflowd.initd,v 1.2 2012/03/21 07:52:49 robbat2 Exp $
 
-depend() {
-	need net
-}
-
-softflowd_checkconfig() {
-	SOFTFLOWD_INTERFACE=${SVCNAME#*.}
-	if [ ${SOFTFLOWD_INTERFACE} = ${SVCNAME} ]; then
-		eerror "You have to create an init script for each interface:"
-		eerror "ln -s softflowd /etc/init.d/softflowd.eth0"
-		return 1
+name="Netflow probe"
+description="NetFlow Probe"
+command=/usr/sbin/softflowd
+pidfile=/run/$RC_SVCNAME.pid
+
+if [ -z "${RC_SVCNAME##*.*}" ]; then
+	_suffix=${RC_SVCNAME#*.}
+	SOFTFLOWD_INTERFACE=${_suffix%_at_*}
+	name="$name: $SOFTFLOWD_INTERFACE"
+	if [ -z "${_suffix##*_at_*}" ]; then
+		SOFTFLOWD_COLLECTOR=${_suffix#*_at_}
+		name="$name -> $SOFTFLOWD_COLLECTOR"
 	fi
+	command_args="-p $pidfile -c /run/$RC_SVCNAME.ctl"
+elif [ "${SOFTFLOWD_INTERFACE##*:*}" ]; then
+	SOFTFLOWD_INTERFACE="${SOFTFLOWD_INTERFACE_IDX:+$SOFTFLOWD_INTERFACE_IDX:}$SOFTFLOWD_INTERFACE"
+fi
 
-	if [ -z "${SOFTFLOWD_COLLECTOR}" ]; then
-		eerror "Specify the host and port that the accounting datagrams are to be"
-		eerror	"sent to in /etc/conf.d/${SVCNAME}." 
-		eerror "Example: SOFTFLOWD_COLLECTOR=collector.example.com:9995"
-		return 1
-	fi
-	SOFTFLOWD_PIDFILE="/var/run/softflowd.${SOFTFLOWD_INTERFACE}.pid"
-	SOFTFLOWD_CTLFILE="/var/run/softflowd.${SOFTFLOWD_INTERFACE}.ctl"
-}
+command_args="-i $SOFTFLOWD_INTERFACE -n $SOFTFLOWD_COLLECTOR $command_args $SOFTFLOWD_EXTRA"
 
+# legacy compatibility
+command_args="$command_args ${SOFTFLOWD_TIMEOUTS:+-t $SOFTFLOWD_TIMEOUTS}"
+command_args="$command_args ${SOFTFLOWD_MAXFLOWS:+-m $SOFTFLOWD_MAXFLOWS}"
 
-start() {
-	softflowd_checkconfig || return 1
-
-	ebegin "Starting softflowd on interface ${SOFTFLOWD_INTERFACE}"
-	iface_arg=${SOFTFLOWD_INTERFACE}
-	[ -n "${SOFTFLOWD_INTERFACE_IDX}" ] && iface_arg="${SOFTFLOWD_INTERFACE_IDX}:${iface_arg}"
-	start-stop-daemon --start \
-		--exec /usr/sbin/softflowd \
-		--	-i "${iface_arg}" \
-			-n "${SOFTFLOWD_COLLECTOR}" \
-			-p "${SOFTFLOWD_PIDFILE}" \
-			-c "${SOFTFLOWD_CTLFILE}" \
-			-t "${SOFTFLOWD_TIMEOUTS-maxlife=600}" \
-			-m "${SOFTFLOWD_MAXFLOWS-17000}" \
-			${SOFTFLOWD_EXTRA}
-	eend $?
+depend() {
+	need net
 }
 
-stop() {
-	softflowd_checkconfig || return 1
-
-	ebegin "Stopping softflowd on interface ${SOFTFLOWD_INTERFACE}"
-	# use softflowd's own way to shut it down
-	/usr/sbin/softflowctl -c ${SOFTFLOWD_CTLFILE} shutdown
-	eend $?
+start_pre() {
+	[ "$SOFTFLOWD_INTERFACE" -a "$SOFTFLOWD_COLLECTOR" ] && return 0
+	eerror Specify interface name in form [index:]ifname
+	eerror and collector host:port in /etc/conf.d/$RC_SVCNAME:
+	eerror "    SOFTFLOWD_INTERFACE=eth0"
+	eerror "    SOFTFLOWD_COLLECTOR=collector.host:9995"
+	eerror Or create an init script for each interface or interface_at_collector:
+	eerror "    cd /etc/init.d"
+	eerror "    ln -s softflowd softflowd.1:eth0_at_collector.host:9995"
+	return 1
 }
-
-- 
2.12.2
---
Unsubscribe:  alpine-aports+unsubscribe_at_lists.alpinelinux.org
Help:         alpine-aports+help_at_lists.alpinelinux.org
---
Received on Thu Apr 13 2017 - 17:46:44 UTC