# Template build file for 'gogs'
pkgname=gogs
version=0.6.3
revision=2
build_style=go
go_import_path="github.com/gogits/gogs"
short_desc="Self-hosted Git Service in Go"
maintainer="John Regan <john@jrjrtech.com>"
license="MIT"
homepage="http://gogs.io"
depends="git"
distfiles="https://github.com/gogits/gogs/archive/v${version}.tar.gz"
checksum=6fbd21805ae86b2d1eb1735a8659952036f1a08047a37a0647baaa57fea342bb
hostmakedepends="git"

conf_files="/etc/gogs.ini"
system_accounts="gogs"
gogs_homedir="/srv/gogs"
make_dirs="
	/srv/gogs 0755 gogs gogs
	/srv/gogs/repo 0755 gogs gogs
	/srv/gogs/data 0755 gogs gogs
	/srv/gogs/data/avatars 0755 gogs gogs
	/srv/gogs/data/attachments 0755 gogs gogs
	/var/log/gogs 0755 gogs gogs"

export CGO_ENABLED=1

post_extract() {
	mkdir tmp
	mkdir -p $GOPATH/src/github.com/gogits
	ln -s $PWD $GOPATH/src/github.com/gogits/${pkgname}
	TMPDIR=${PWD}/tmp/ go get -tags "sqlite redis memcache" "github.com/gogits/gogs"
}


do_build() {
	go fix
	TMPDIR=${PWD}/tmp/ GOOS=linux go build -tags "sqlite redis memcache"
	rm -rf tmp
}

do_install() {
	vbin gogs-${version} gogs
	install -d "$DESTDIR/usr/share/themes/gogs/default"
	cp -r public "$DESTDIR/usr/share/themes/gogs/default/"
	cp -r templates "$DESTDIR/usr/share/themes/gogs/default/"
	vconf ${FILESDIR}/gogs.ini
	vsconf ${FILESDIR}/gogs.ini
	vlicense LICENSE
	vdoc README.md
	vsv gogs
}
