# Maintainer: Antoine Martin (ayakael) <dev@ayakael.net>
# Contributor: Antoine Martin (ayakael) <dev@ayakael.net>

pkgname=scanbd
pkgver=1.5.1
pkgrel=0
pkgdesc="Scanner button daemon looking for scanner button pressed"
arch="x86_64"
url="http://scanbd.sourceforge.net/"
license="GPL-2.0-only"
makedepends="
	sane-dev
	dbus-dev
	confuse-dev
	"
source="
	https://downloads.sourceforge.net/scanbd/scanbd-$pkgver.tgz
	string-bounds.patch
	"
builddir="$srcdir/$pkgver"
subpackages="$pkgname-doc"

prepare() {
	default_prepare
	sed -i 's/"saned">.*/"daemon">/' integration/scanbd_dbus.conf
	sed -i 's@\(user    = \)saned$@\1daemon@' conf/scanbd.conf
	sed -i 's@\(group   = \)lp$@\1scanner@' conf/scanbd.conf
	sed -i 's@/var\(/run/scanbd.pid\)@\1@' conf/scanbd.conf
	sed -i 's@\(debug-level =\)7$@\1 2@' conf/scanbd.conf
	sed -i 's@\(SANE_CONFIG_DIR=\)\(/etc/scanbd\)@\1\2/sane.d@' conf/scanbd.conf
}

build() {
	./configure --prefix=/usr --sysconfdir=/etc --sbindir=/sbin
	make
}

package() {
	make DESTDIR="$pkgdir" install

	install -Dm644 integration/scanbd_dbus.conf -t "$pkgdir/etc/dbus-1/system.d/"
	install -Dm644 doc/README.txt -t "$pkgdir/usr/share/doc/$pkgname/"
	install -Dm644 AUTHORS -t "$pkgdir/usr/share/doc/$pkgname/"
	install -dm755 "$pkgdir/etc/scanbd/sane.d"
}

sha512sums="
1a20c96520184b7d7cabe997005dd48e7481d70c1ca4d9b691aa21a32cc1bed942d0ca7bd40b140e26a8dc40afe54c1bf6fcd1fa55bc3cc788af1b6ac82ad445  scanbd-1.5.1.tgz
708994fbfb953d5ad67fd6460a805a88168929f01881898be6da13d415c91a7be65211e0b84bd2c4fd2cf371ad6fb430d8d3294475cfb7442725faef21c06c4f  string-bounds.patch
"
