Subject: [alpine-aports] [PATCH] main/cacti: upgrade to 1.0.0

From: Valery Kartel <[email-masked]>
Date: Thu, 2 Feb 2017 18:21:36 +0200

--
create user 'cacti' for php and cli operations
move writable data to cacti's home /var/lib/cacti
move all documentaion to -doc
move installation-related data to -inst subpackage
add -php5 & -php7 subpackages for autoinstall php dependencies
fix net-snmp dependency -> net-snmp-tools
add dependency for cacti-scripts: bash, perl
---
 main/cacti/APKBUILD          | 88 ++++++++++++++++++++++++++++++++------------
 main/cacti/cacti.pre-install |  9 +++++
 2 files changed, 73 insertions(+), 24 deletions(-)
 create mode 100644 main/cacti/cacti.pre-install

diff --git a/main/cacti/APKBUILD b/main/cacti/APKBUILD
index 6abe94767d..0c0e1d952d 100644
--- a/main/cacti/APKBUILD
+++ b/main/cacti/APKBUILD
@@ -1,38 +1,78 @@
+# Contributor: Valery Kartel <[email-masked]>
 # Maintainer: Jeff Bilyk <[email-masked]>
-_php=php5
 pkgname=cacti
-pkgver=0.8.8h
+pkgver=1.0.0
 pkgrel=0
-pkgdesc="Network monitoring tool based on RRDtool"
+pkgdesc="The complete rrdtool-based graphing solution"
 url="http://www.cacti.net"
 arch="noarch"
 license="GPL2+"
-depends="$_php ${_php}-mysql ${_php}-snmp rrdtool net-snmp ${_php}-sockets
-	${_php}-xml ${_php}-gd"
+pkgusers="cacti"
+pkggroups="www-data"
+depends="bash perl net-snmp-tools rrdtool"
 makedepends=""
-source="http://www.cacti.net/downloads/$pkgname-$pkgver.tar.gz
-	"
-
-_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
+subpackages="$pkgname-doc $pkgname-inst $pkgname-php5:_php $pkgname-php7:_php"
+install="$pkgname.pre-install"
+source="http://www.cacti.net/downloads/$pkgname-$pkgver.tar.gz"
+builddir="$srcdir/$pkgname-$pkgver"
+
+package() {
+	cd "$builddir"
+
+	mkdir -p "$pkgdir"/usr/share/webapps/$pkgname \
+		"$pkgdir"/var/lib/$pkgname
+
+	cp -r * "$pkgdir"/usr/share/webapps/$pkgname/ || return 1
+
+	local dir; for dir in cache log plugins resource rra scripts; do
+		mv "$pkgdir"/usr/share/webapps/$pkgname/$dir \
+			"$pkgdir"/var/lib/$pkgname/$dir || return 1
+		chown -R $pkgusers:$pkggroups "$pkgdir"/var/lib/$pkgname/$dir
+		ln -s /var/lib/$pkgname/$dir "$pkgdir"/usr/share/webapps/$pkgname/$dir
 	done
+	chown $pkgusers:$pkggroups "$pkgdir"/var/lib/$pkgname/log/*.log
+
+	mv "$pkgdir"/usr/share/webapps/$pkgname/include/config.php \
+		"$pkgdir"/var/lib/$pkgname/config.php || return 1
+	ln -s /var/lib/$pkgname/include/config.php \
+		"$pkgdir"/usr/share/webapps/$pkgname/include/config.php
 }
 
-build() {
-	cd "$_builddir"
-	return 0
+doc() {
+	default_doc || return 1
+
+	mkdir -p "$subpkgdir"/usr/share/webapps/$pkgname
+	cd "$pkgdir"/usr/share/webapps/$pkgname
+	mv docs "$subpkgdir"/usr/share/webapps/$pkgname/
+
+	local file;
+	for file in $(find ./ -name "LICENSE" -o -name "NEWS" \
+			 -o -name "README*" -o -name "VERSION" \
+			 -o -name "CHANGELOG" -o -name "*.rst")
+	do
+		mkdir -p "$subpkgdir"/usr/share/webapps/$pkgname/${file%/*}
+		mv $file "$subpkgdir"/usr/share/webapps/$pkgname/$file
+	done
 }
 
-package() {
-	mkdir -p "$pkgdir"/usr/share/webapps/cacti
-	mv "$srcdir"/$pkgname-$pkgver/* "$pkgdir"/usr/share/webapps/cacti/ || return 1
+inst() {
+	pkgdesc="$pkgdesc (installation data)"
+	depends="$pkgname"
 
+	mkdir -p "$subpkgdir"/usr/share/webapps/$pkgname
+	cd "$pkgdir"/usr/share/webapps/$pkgname
+	mv install *.sql "$subpkgdir"/usr/share/webapps/$pkgname/
 }
-md5sums="e5a2eb9e1b187a92284f46e7d4cd6505  cacti-0.8.8h.tar.gz"
-sha256sums="0673bd9513dad381c8bbb9133c721a32bc6422dc91c5a81de16e3cd32e4d0600  cacti-0.8.8h.tar.gz"
-sha512sums="11bb0682a7220af5581f42579cf9c38d94aae202425ce15b824849684b1a6778d6f14e6a62ec94c608b7ba06562a825be7fd6d812d0800daa5eb56e640ac1c5f  cacti-0.8.8h.tar.gz"
+
+_php() {
+	local php=${subpkgname#$pkgname-}
+	pkgdesc="$pkgdesc ($php dependencies)"
+	install_if="$php $pkgname=$pkgver-r$pkgrel"
+	depends="$php $php-gd $php-gmp $php-json $php-ldap $php-pdo_mysql
+		$php-openssl $php-posix $php-snmp $php-sockets $php-xml $php-zlib"
+	mkdir -p "$subpkgdir"
+}
+
+md5sums="e711a305a12484623669e3c873126348  cacti-1.0.0.tar.gz"
+sha256sums="180a23102af0415b961ef4d4181f93f49d40ebed36c5392ac988650d3753e693  cacti-1.0.0.tar.gz"
+sha512sums="9133bb3d34ee6a4fe94e8258ce76df1ceac5cc76ccc8a492ae9a1263cbfb765f88f169c2780f2b36c14d8df4607e8effaf448bcb632cd4171533d0f9842550b1  cacti-1.0.0.tar.gz"
diff --git a/main/cacti/cacti.pre-install b/main/cacti/cacti.pre-install
new file mode 100644
index 0000000000..19c56021b5
--- /dev/null
+++ b/main/cacti/cacti.pre-install
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+addgroup -S cacti 2>/dev/null
+addgroup -Sg 82 www-data 2>/dev/null
+
+adduser -SDh /var/lib/cacti -s /sbin/nologin -G cacti -g cacti cacti 2>/dev/null
+adduser cacti www-data 2>/dev/null
+
+exit 0
-- 
2.11.0

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