summaryrefslogtreecommitdiff
path: root/net-p2p/syncthing/syncthing-scm.ebuild
blob: 1bdbe73baa8b023da631ea5703fbcfbbc3de6f60 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

EAPI=5
inherit eutils base git-r3 systemd

DESCRIPTION="Open, trustworthy and decentralized syncing engine"
HOMEPAGE="http://${PN}.net"

EGIT_REPO_URI="https://github.com/${PN}/${PN}.git"

LICENSE="MIT"
SLOT="0"
KEYWORDS=""
IUSE="systemd"

DEPEND="
	>=dev-lang/go-1.3
"
RDEPEND="${DEPEND}"

DOCS=( README.md AUTHORS LICENSE CONTRIBUTING.md )

export GOPATH="${S}"

GO_PN="github.com/${PN}/${PN}"
EGIT_CHECKOUT_DIR="${S}/src/github.com/syncthing/syncthing"
S=${EGIT_CHECKOUT_DIR}

src_compile() {
	go run build.go
}

src_install() {
	dobin bin/syncthing
	base_src_install_docs
	if use systemd; then
		systemd_newunit "${FILESDIR}"/${PN}.service ${PN}@.service
	else
		newinitd ${FILESDIR}/rc/init ${PN}
		newconfd ${FILESDIR}/rc/conf ${PN}
	fi
}

pkg_postinst() {
	if use systemd; then
		ECHO_1="systemctl start ${PN}@<user>"
		ECHO_2="systemctl enable ${PN}@<user>"
	else
		ECHO_1="/etc/init.d/${PN} start"
		ECHO_2="rc-update add ${PN} default"
	fi

	einfo
	elog "To run syncthing as a service:"
	elog "  ${ECHO_1}"
	elog "To enable it at startup:"
	elog "  ${ECHO_2}"
	einfo
}