# $Id: PKGBUILD 138344 2015-08-14 09:25:54Z bisson $
# Maintainer: Gaetan Bisson <bisson@archlinux.org>
# Contributor: Damir Perisa <damir.perisa@bluewin.ch>
# Contributor: Stewart Starbuck <stewart@stewartstarbuck.co.uk>

pkgname=sthttpd
pkgver=2.27.0
pkgrel=1
pkgdesc='Supported fork of the thttpd web server'
url='http://opensource.dyc.edu/sthttpd'
license=('custom:BSD')
arch=('i686' 'x86_64')
backup=('etc/thttpd.conf')
validpgpkeys=('1FEDFAD9D82C52A53BABDC799384FA6EF52D4BBA')
source=("http://opensource.dyc.edu/pub/${pkgname}/${pkgname}-${pkgver}.tar.gz"{,.asc}
        'discreet.patch'
        'service'
        'config')
sha1sums=('27ea739c4e3c7922979c4357a80fe6d141da4356' 'SKIP'
          'ae0143fce29cf7eb84ebbee9640b9a2c977b5093'
          '73bd76de0e89a9cc31e5605659837d83b3c8dfde'
          '7a6413491b6ba68625d450caa3c6f071af0ca1ac')

conflicts=('thttpd')
provides=('thttpd')
replaces=('thttpd')

prepare() {
	cd "${srcdir}/${pkgname}-${pkgver}"
	aclocal && automake --add-missing
	patch -p1 -i ../discreet.patch
}

build() {
	cd "${srcdir}/${pkgname}-${pkgver}"
	export WEBDIR=/srv/http
	export WEBGROUP=http
	./configure \
		--prefix=/usr \
		--sbindir=/usr/bin \
		--mandir=/usr/share/man \

	make
}

package() {
	cd "${srcdir}/${pkgname}-${pkgver}"
	make DESTDIR="${pkgdir}" install
	rm -fr "${pkgdir}"/srv

	install -Dm644 ../config "${pkgdir}"/etc/thttpd.conf
	install -Dm644 ../service "${pkgdir}"/usr/lib/systemd/system/thttpd.service
	install -Dm644 README "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"

	# Avoid conflicts with Apache
	mv "${pkgdir}"/usr/bin/htpasswd{,-thttpd}
	mv "${pkgdir}"/usr/share/man/man1/htpasswd{,-thttpd}.1
}
