# Contributor: Sergei Lukin <sergej.lukin@gmail.com>
# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
_php=php7
pkgname=postfixadmin
pkgver=3.0.2
pkgrel=2
pkgdesc="Web Based Management tool for Postfix"
url="http://postfixadmin.com/"
arch="noarch"
license="GPL"
depends="$_php"
options="!check"
source="http://downloads.sourceforge.net/project/postfixadmin/postfixadmin/postfixadmin-$pkgver/postfixadmin-$pkgver.tar.gz"

# secfixes:
#   3.0.2-r0:
#   - CVE-2017-5930

builddir="$srcdir"/postfixadmin-$pkgver

prepare() {
	default_prepare || return 1
}

build() {
	cd "$builddir"
}

package() {
	cd "$builddir"
	mkdir -p "$pkgdir"/usr/share/webapps/postfixadmin \
		"$pkgdir"/etc/postfixadmin
	cp -r * "$pkgdir"/usr/share/webapps/postfixadmin/

	# move config to /etc/postfixadmin and create symlink
	mv "$pkgdir"/usr/share/webapps/postfixadmin/config.inc.php \
		"$pkgdir"/etc/postfixadmin/
	ln -s /etc/postfixadmin/config.inc.php \
		"$pkgdir"/usr/share/webapps/postfixadmin/config.inc.php
	echo -e "User-Agent: *\nDisallow: /" \
		> "$pkgdir"/usr/share/webapps/postfixadmin/robots.txt
}

sha512sums="19db70cc59e8e41356e4cd632b0cb9df8d8de0f0451e7e2c84d61a0aa6ede5cc93bbf8914786a2eec012e4c013ad130a001d143ce869aa54b54a50fb798ed92b  postfixadmin-3.0.2.tar.gz"