summaryrefslogtreecommitdiff
blob: 01ad1e57dba0a020fa42c4afd06012fb671b5517 (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
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7
EGO_PN=github.com/influxdata/telegraf

inherit systemd

MY_PV="${PV/_rc/-rc.}"
COMMIT=da364558

DESCRIPTION="The plugin-driven server agent for collecting & reporting metrics."
HOMEPAGE="https://github.com/influxdata/telegraf"
SRC_URI="https://github.com/influxdata/telegraf/archive/${MY_PV}.tar.gz -> ${P}.tar.gz
	https://dev.gentoo.org/~williamh/dist/${P}-vendor.tar.gz"

LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64"

RESTRICT="strip"

BDEPEND="dev-lang/go"
DEPEND="acct-group/telegraf
	acct-user/telegraf"
	RDEPEND="${DEPEND}"

src_prepare() {
	default
	mv ../vendor .
}

src_compile() {
	echo module ${EGO_PN} > go.mod
	set -- env GO111MODULE=on go build -mod vendor -v -x -o telegraf \
		-ldflags="-X main.commit=${COMMIT} -X main.version=${PV}" \
		cmd/telegraf/telegraf.go
	echo "$@"
	"$@" || die
}

src_install() {
	dobin telegraf
	insinto /etc/telegraf
	doins etc/telegraf.conf
	keepdir /etc/telegraf/telegraf.d

	insinto /etc/logrotate.d
	doins etc/logrotate.d/telegraf

	systemd_dounit scripts/telegraf.service
	newconfd "${FILESDIR}"/telegraf.confd telegraf
	newinitd "${FILESDIR}"/telegraf.rc telegraf

	dodoc -r docs/*

	keepdir /var/log/telegraf
	fowners telegraf:telegraf /var/log/telegraf
}