summaryrefslogtreecommitdiff
blob: a0cae01a73afa8e08d6243c25341861535e44152 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

EAPI=6

EGO_PN="github.com/syncthing/relaysrv"
EGIT_COMMIT=v${PV}

inherit golang-vcs-snapshot systemd user versionator

DESCRIPTION="Syncthing relay server"
HOMEPAGE="https://syncthing.net"
SRC_URI="https://${EGO_PN}/archive/${EGIT_COMMIT}.tar.gz -> ${P}.tar.gz"

LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64 ~x86 ~arm"
IUSE=""

DEPEND=""
RDEPEND=""

DOCS="README.md"

USER=syncthing-relaysrv
BINARY=syncthing-relaysrv

pkg_setup() {
	enewgroup ${USER}
	enewuser ${USER} -1 -1 /var/lib/${USER} ${USER}
}

src_compile() {
	cd "src/${EGO_PN}" || die "build failed"
	export GOPATH="$(pwd)/Godeps/_workspace"
	go build -i -v -ldflags -w -o ${BINARY} || die "build failed"
}

src_install() {
	dobin "src/${EGO_PN}/${BINARY}"

	# openrc and systemd daemon routines
	newconfd "${FILESDIR}/syncthing-relaysrv.confd" syncthing-relaysrv
	newinitd "${FILESDIR}/syncthing-relaysrv.initd" syncthing-relaysrv
	systemd_newunit "${FILESDIR}/syncthing-relaysrv.service" \
		syncthing-relaysrv.service
}