# Contributor: Alex McGrath <amk@amk.ie>
# Maintainer: Alex McGrath <amk@amk.ie>
pkgname=gonic
pkgver=0.16.2
pkgrel=5
pkgdesc="Subsonic compatible music streaming server"
url="https://github.com/sentriz/gonic"
arch="all"
license="GPL-3.0-or-later"
subpackages="$pkgname-openrc"
depends="ffmpeg"
makedepends="go taglib-dev zlib-dev sqlite-dev"
install="$pkgname.pre-install"
source="gonic-$pkgver.tar.gz::https://github.com/sentriz/gonic/archive/v$pkgver.tar.gz
	gonic.initd
	gonic.confd
	"
options="!check" # intermittent test failure

export GO111MODULES=on
export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	export GOFLAGS="$GOFLAGS -tags=libsqlite3"
	go build -o gonic ./cmd/gonic/gonic.go
}

check() {
	go test ./...
}

package() {
	install -m755 -D "$srcdir"/$pkgname.initd \
		"$pkgdir"/etc/init.d/$pkgname
	install -m644 -D "$srcdir"/$pkgname.confd \
		"$pkgdir"/etc/conf.d/$pkgname
	install -Dm755 "$builddir"/"$pkgname" \
		"$pkgdir"/usr/bin/"$pkgname"

}

sha512sums="
3d42be96b1381b58a44779e71294c4380c3005d22876b848d3f85bba5687f954883be45cda37ad40c147a64b4317566b3d647767375a76cd03c8311a26a1c972  gonic-0.16.2.tar.gz
e8a65612bffd1b62175968cc34a227393364ea6fedd661854bf515cc7306e9266d823544989b671f99beb72b6caf83728fa7c7fd9eedbc85a3e34ea84c1ce269  gonic.initd
b72e31c0f9f79694736aadb8ca581fdb269e82ece9f2c8e45cdb4edb3e01c7fd140e65c11be65cc242dddb273c8c93fde2af12a32241d7936318f3c3cd73d2ec  gonic.confd
"
