# Template build file for 'gogs'
pkgname=gogs
version=0.11.34
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=cc6b51cc53b6effed44c37ac7086af5822e2ceff9e2589316782e6c7b28a445f
hostmakedepends="git-perl curl"

conf_files="/etc/gogs.ini"
system_accounts="gogs"
gogs_homedir="/srv/gogs"
gogs_shell="/bin/bash"

export CGO_ENABLED=1


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

do_build() {
	cd "$GOPATH/src/github.com/gogits/gogs"
	TMPDIR=${PWD}/tmp/ GOOS=linux GOPATH=$GOPATH go build -tags "sqlite redis memcache"
	rm -rf tmp
}

do_install() {
	cd "$GOPATH/src/github.com/gogits/gogs"
	vbin gogs 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
}
