Subject: [alpine-aports] [PATCH] main/pingu: V2 fix pkgdesc & url, remove /var from package. Init-script: made some cleanups and rundir creation added

From: Valery Kartel <[email-masked]>
Date: Wed, 6 Jan 2016 23:33:45 +0200

I tried to use configure --rundir=/run option to move pid and ctl file from /var/run to /run but it does not work. So I leave it in /var/run
---
 main/pingu/APKBUILD    | 32 +++++++-------------------------
 main/pingu/pingu.initd | 22 +++++++++-------------
 2 files changed, 16 insertions(+), 38 deletions(-)

diff --git a/main/pingu/APKBUILD b/main/pingu/APKBUILD
index 8afe781..52215d7 100644
--- a/main/pingu/APKBUILD
+++ b/main/pingu/APKBUILD
@@ -2,9 +2,9 @@
 # Maintainer: Natanael Copa <[email-masked]>
 pkgname=pingu
 pkgver=1.5
-pkgrel=1
-pkgdesc="Small daemon that pings hosts and executes a script when status change"
-url="http://git.alpinelinux.org/cgit/pingu"
+pkgrel=2
+pkgdesc="Policy routing daemon with failover and load-balancing for multi ISP setups"
+url="http://git.alpinelinux.org/cgit/hosted/pingu/about"
 arch="all"
 license="GPL"
 makedepends="libev-dev lua-dev asciidoc linux-headers"
@@ -16,15 +16,6 @@ source="pingu-$pkgver.tar.gz::https://github.com/ncopa/pingu/archive/v$pkgver.ta
 
 _builddir="$srcdir"/$pkgname-$pkgver
 
-prepare() {
-	cd "$_builddir"
-	for i in $source; do
-		case $i in
-		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
-		esac
-	done
-}
-
 build() {
 	cd "$_builddir"
 	./configure \
@@ -36,21 +27,12 @@ build() {
 	make || return 1
 }
 
-prepare() {
-        local i
-        cd "$_builddir"
-        for i in $source; do
-                case $i in
-                *.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
-                esac
-	done
-}
-
 package() {
 	cd "$_builddir"
 	make DESTDIR="$pkgdir" install install-lua
 	install -m644 -D pingu.conf "$pkgdir"/etc/pingu/pingu.conf
 	install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
+	rm -fr "$pkgdir"/var
 }
 
 mtu() {
@@ -66,8 +48,8 @@ _lua() {
 }
 
 md5sums="3454ef7723e446d917c389c0615c62b4  pingu-1.5.tar.gz
-dd46546d05395893a1624e467b04b1d4  pingu.initd"
+d832f5b8718ab46b1413058d3d99a525  pingu.initd"
 sha256sums="1caaef8765e7bd6950be8109a58187ad529237eec89742d923c1888f4c2a9f6d  pingu-1.5.tar.gz
-1d4388e96a257c0bc01a585df36c0e6bc6c1ba53c9bb0b67290eaff7e8a6d1b3  pingu.initd"
+39bfd33e59f6f2cc5dfe1795106dccbf0e443c16170e5e70fa955c0fea2a7b27  pingu.initd"
 sha512sums="71e5fbe93f831f24d168957cdeaff2817a22f407575316d6515755bec760d10724821070549eaab562924237b96976a1a776ca903d5fe0cd9f9b69a38eadd8c9  pingu-1.5.tar.gz
-93859ab4e84d07c776915045b3fe533de551c55465dab4aa283f5606c0e8a439875f91e0e1db419bc97b01f7e4c4b0f5d434885edcf9ad77e6f65f6f27715de8  pingu.initd"
+b989d060a29000acc0efd6cc187abdddbd2c3844fb5e2dff62c72555659a2ac8e8450330a588bc88dfd3265ea1d55b60423a02aaa74841fe397892c29ef73434  pingu.initd"
diff --git a/main/pingu/pingu.initd b/main/pingu/pingu.initd
index 517bdd8..7913b41 100644
--- a/main/pingu/pingu.initd
+++ b/main/pingu/pingu.initd
@@ -3,9 +3,9 @@
 description="MultiISP load balancing and failover"
 command=/usr/sbin/pingu
 command_args="-d $pingu_opts"
+cfgfile=/etc/pingu/pingu.conf
 pidfile=/var/run/pingu/pingu.pid
-route_rules=/etc/pingu/route-rules
-rundir=${pidfile%/*}
+required_files="$cfgfile"
 
 depend() {
 	need net
@@ -13,24 +13,20 @@ depend() {
 }
 
 start_pre() {
-	if ! [ -f "$route_rules" ]; then
-		return 0
-	fi
-	sed -e 's/\#.*//' -e '/^$/d' "$route_rules" | while read line; do
+	checkpath --directory ${pidfile%/*}
+	[ -f ${cfgfile%/*}/route-rules ] && \
+	sed -e 's/\#.*//' -e '/^$/d' ${cfgfile%/*}/route-rules | while read line; do
 		ebegin "Adding route rule: $line"
-		ip rule add $line && echo $line >> $rundir/route-rules
+		ip rule add $line && echo $line >> ${pidfile%/*}/route-rules
 		eend
 	done
 }
 
 stop_post() {
-	if ! [ -f "$rundir"/route-rules ]; then
-		return 0
-	fi
-	while read line; do
+	[ -f ${pidfile%/*}/route-rules ] && while read line; do
 		ebegin "Removing route rule: $line"
 		ip rule del $line
 		eend
-	done < "$rundir"/route-rules
-	rm "$rundir"/route-rules
+	done < ${pidfile%/*}/route-rules
+	rm -f ${pidfile%/*}/route-rules
 }
-- 
2.6.4

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