# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=devicemaster-linux
pkgver=7.15
pkgrel=0
pkgdesc="Userspace tools for NS-Link Device Drivers"
url="http://www.comtrol.com/resources/product-resources-white-papers/ns-link-device-drivers"
arch="all"
license="GPL"
depends=""
makedepends="linux-headers"
install=
subpackages="$pkgname-doc"
source="http://dev.alpinelinux.org/archive/$pkgname/$pkgname-$pkgver.tar.gz
	makefile.patch
	nslink.initd
	"
srcurl="ftp://ftp.comtrol.com/dev_mstr/rts/drivers/linux/devicemaster-linux-$pkgver.tar.gz"
disturl="dev.alpinelinux.org:/archive/$pkgname/"

snapshot() {
	cd "$_builddir"
	curl -ss -o "$pkgname-$pkgver.tar.gz" "$srcurl"
	rsync --progress -La $pkgname-${pkgver}.tar.gz \
		$disturl || return 1
}

_builddir="$srcdir"/devicemaster-linux-$pkgver
prepare() {
	cd "$_builddir"
	for i in $source; do
		case $i in
		*.patch|*.diff)
			msg "Applying $i"
			patch -p1 -i "$srcdir"/$i || return 1
			;;
		esac
	done
}

build() {
	cd "$_builddir"
	make nslinkd nslinkadmin nslinkrelease nslinktool || return 1
}

package() {
	cd "$_builddir"
	install -d \
		"$pkgdir"/etc/init.d \
		"$pkgdir"/sbin \
		"$pkgdir"/usr/share/man/man5 \
		"$pkgdir"/usr/share/man/man8 \
		|| reutrn 1
	install -m700 nslinkadmin nslinktool nslinkrelease nslinkd \
		"$pkgdir"/sbin/ || return 1
	install nslink.conf "$pkgdir"/etc/ || return 1
	install -m755 "$srcdir"/nslink.initd "$pkgdir"/etc/init.d/nslink

	install -m644 *.8 "$pkgdir"/usr/share/man/man8 || return 1
	install -m644 *.5 "$pkgdir"/usr/share/man/man5 || return 1
}
sha512sums="794f680613db6462f1452e32f17ab7e30e637d0a77d4c7c5cf43650776f5ec0d3c5144ebdf92fc5bf0f2f0fba456c2710d2cd2280981a208ff936b472388c3ba  devicemaster-linux-7.15.tar.gz
adadb7b6502b0b6fd2d72a1a453dcea2ff8800d08258b80c5df751bd9fc8de5e88760560c2ab1e911e994999db58882555b5ab6e72f466ed26a47b327f6a668a  makefile.patch
6e67a184ec73d5909d67b7d606d4789cad0e0b4134bb52bfd4019fd7f65b928c15c241dfe6f8a1c6e0854f4d509d7bb150beb9d41ae2a2315ebc040c240abc22  nslink.initd"
