summaryrefslogtreecommitdiff
blob: 33a5201ff2192cf8fe148ebab9d77003011c82c5 (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Copyright 1999-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

EAPI=6

BASE_URI="http://linux-packages.resilio.com/${PN}/deb/pool/non-free/r/${PN}/${PN}_${PV}-1_@arch@.deb"

inherit pax-utils readme.gentoo-r1 systemd tmpfiles unpacker user

NAME="rslsync"
QA_PREBUILT="usr/bin/${NAME}"

DESCRIPTION="Resilient, fast and scalable file synchronization tool"
HOMEPAGE="https://getsync.com/"
SRC_URI="amd64? ( ${BASE_URI/@arch@/amd64} )
	x86? ( ${BASE_URI/@arch@/i386} )"

LICENSE="all-rights-reserved"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="pax_kernel"
RESTRICT="mirror"

S="${WORKDIR}"

DOC_CONTENTS="You may need to review /etc/${PN}/config.json\\n
Default metadata path is /var/lib/${PN}/.sync\\n
Default web-gui URL is http://localhost:8888/\\n\\n"

pkg_setup() {
	enewgroup "${NAME}"
	enewuser "${NAME}" -1 -1 /var/lib/"${PN}" "${NAME}"
}

src_unpack() {
	unpacker_src_unpack

	unpack usr/share/man/man1/"${PN}".1.gz
}

src_install() {
	dobin usr/bin/"${NAME}"
	use pax_kernel && pax-mark m "${ED%/}"/usr/bin/"${NAME}"

	doman "${PN}".1

	dodir /var/log/"${PN}"
	keepdir /etc/"${PN}" /var/lib/"${PN}"/ /var/lib/"${PN}"/.sync /var/log/"${PN}"
	fperms 0700 /etc/"${PN}" /var/lib/"${PN}" /var/lib/"${PN}"/.sync /var/log/"${PN}"
	fowners -R "${NAME}":"${NAME}" /etc/"${PN}" /var/lib/"${PN}" /var/log/"${PN}"

	newinitd "${FILESDIR}"/"${PN}".initd "${PN}"
	newconfd "${FILESDIR}"/"${PN}".confd "${PN}"
	newinitd "${FILESDIR}"/"${PN}"-user.initd "${PN}"-user
	newconfd "${FILESDIR}"/"${PN}"-user.confd "${PN}"-user
	systemd_dounit "${FILESDIR}"/"${PN}".service
	systemd_douserunit "${FILESDIR}"/"${PN}"-user.service
	newtmpfiles "${FILESDIR}"/resilio-sync.tmpfile resilio-sync.conf

	readme.gentoo_create_doc

	# Generate sample config
	"${ED%/}"/usr/bin/"${NAME}" --dump-sample-config > \
		"${ED%/}"/etc/"${PN}"/config.json || die "generate config failed"
	fowners "${NAME}":"${NAME}" /etc/"${PN}"/config.json
	# Uncomment config directives and change their values
	sed -i \
		-e "/storage_path/s|//| |g" \
		-e "/pid_file/s|//| |g" \
		-e "/storage_path/s|/home/user/.sync|/var/lib/${PN}/.sync|g" \
		-e "/pid_file/s|resilio/resilio|${PN}/${PN}|g" \
		"${ED%/}"/etc/"${PN}"/config.json || die "sed failed for config.json"
}

pkg_postinst() {
	tmpfiles_process resilio-sync.conf
	readme.gentoo_print_elog
}