# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=shellinabox
_daemonname=${pkgname}d
pkgver=2.20
pkgrel=0
pkgdesc="Implementation of a web server that can export arbitrary command line tools to a web based terminal emulator"
url="https://github.com/shellinabox/shellinabox"
arch="all"
license="GPL-2.0"
makedepends="autoconf automake m4 libtool libressl-dev zlib-dev"
subpackages="$pkgname-doc"
pkgusers="$_daemonname"
pkggroups="$_daemonname"
install="$pkgname.pre-install"
source="$pkgname-$pkgver.tar.gz::https://github.com/$pkgname/$pkgname/archive/v$pkgver.tar.gz
	$pkgname.initd
	$pkgname.confd"
builddir="$srcdir/$pkgname-$pkgver"

check() {
	cd "$builddir"
	make check
}

prepare() {
	cd "$builddir"
	autoreconf -i
	default_prepare
}

build() {
	cd "$builddir"
	export CPPFLAGS="${CPPFLAGS/-D_FORTIFY_SOURCE=2/}"
	./configure \
		--prefix=/usr \
		--disable-static \
		--disable-utmp
	make
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir/" install
	install -D -m 755 "$srcdir/$pkgname.initd" "$pkgdir/etc/init.d/$_daemonname"
	install -D -m 644 "$srcdir/$pkgname.confd" "$pkgdir/etc/conf.d/$_daemonname"
	mkdir -p "$pkgdir"/var/run/$_daemonname
	chown $pkgusers:$pkggroups "$pkgdir"/var/run/$_daemonname
}

sha512sums="369fb6e0041fc3eb52a533f14d1f856a71ec1bf166441e25a5d61bb129f2db5de6b61205ddd0cb08d53384baaf4e087bd2c549f7919b96ee465d4cc3318d2237  shellinabox-2.20.tar.gz
47206ce991f642e474387c5c00ee4fd8cae0c71da6075e3c62381bb75b46085c35767e817932da64a112b58535516fc620d089434e478c844b4cd7c62bdae654  shellinabox.initd
2e0ef340d88cd62cac4c7c073bdcb79e2e88c77aab7e310daa4ae8b27c297b6138262762dae1f054928f02b38d4a8185dd9b357fd3f59a635c04697fd620cfef  shellinabox.confd"
