# Template file for 'burp-server'
_desc="A network-based backup and restore program"

pkgname=burp-server
version=1.4.40
revision=2
short_desc="${_desc} - Server"
maintainer="Pierre Bourgin <pierre.bourgin@free.fr>"
license="AGPL-3, BSD, GPL-2.1 and LGPL-2.1"
homepage="http://burp.grke.org/"
wrksrc="burp-${version}"
distfiles="https://github.com/grke/burp/archive/${version}.tar.gz>${pkgname}-${version}.tar.gz"
checksum=2e6a9a28453a11f3e36d0beefa185e72e7781a8718b55d3101144c9900752d6f

hostmakedepends="automake libtool perl"
# note: burp provides its internal copy of "uthash-devel"
makedepends="
 libressl-devel zlib-devel librsync-devel ncurses-devel
 acl-devel yajl-devel ca-certificates"

# unique binary for both client and server: server depends on client package.
depends="burp-client-${version}_${revision}"

build_style=gnu-configure
configure_args="--sysconfdir=/etc/burp --sbindir=/usr/bin"
conf_files="/etc/burp/burp-server.conf"

post_install() {
	vsv ${pkgname}

	vdoc "README"
	vdoc "UPGRADING"
	vlicense "LICENSE"

	# /usr/sbin/burp_ca is hardcoded in conf files
	sed -e "s,/usr/sbin/burp_ca,/usr/bin/burp_ca,g" \
	    -i ${DESTDIR}/etc/burp/burp-server.conf

	# storage folder
	touch -f ${PKGDESTDIR}/var/spool/burp/.empty_on_purpose
}

burp-client_package() {
	short_desc="${_desc} - client"
	# openssl binary needed by burp_ca script
	depends="ca-certificates"
	conf_files="/etc/burp/burp.conf"
	pkg_install() {
		vmove "usr/bin/burp"
		vmove "usr/bin/burp_ca"
		vmove "usr/share/man/man8/burp.8.gz"
		vmove "usr/share/man/man8/burp_ca.8.gz"
		vmove "etc/burp/CA-client"
		vmove "etc/burp/burp.conf"
		vdoc "README"
		vlicense "LICENSE"

		# /usr/sbin/burp_ca is hardcoded in conf files
		sed -e "s,/usr/sbin/burp_ca,/usr/bin/burp_ca,g" \
		    -i ${PKGDESTDIR}/etc/burp/burp.conf

		# burp_ca requires directory CA-client
		touch -f ${PKGDESTDIR}/etc/burp/CA-client/.empty_on_purpose
	}
}
