pkgbuilds/telegraf/PKGBUILD
2024-04-12 08:21:50 -05:00

58 lines
2.1 KiB
Bash

# Maintainer: "Amhairghin" Oscar Garcia Amor (https://ogarcia.me)
# Contributor: Nicolas Leclercq <nicolas.private@gmail.com>
# Contributor: Adam S Levy <adam@aslevy.com>
pkgname=telegraf
pkgver=1.30.1
pkgrel=1
pkgdesc='Plugin-driven server agent for reporting metrics into InfluxDB'
arch=('i686' 'x86_64' 'armv6h' 'armv7h' 'aarch64')
url='http://influxdb.org/'
license=('MIT')
depends=('glibc')
makedepends=('go' 'git')
options=('!lto')
backup=('etc/telegraf/telegraf.conf')
install="${pkgname}.install"
source=("https://github.com/influxdata/${pkgname}/archive/v${pkgver}/${pkgname}-v${pkgver}.tar.gz"
"${pkgname}.install"
"${pkgname}.service")
b2sums=('90701b2b09cd924288ef6593faa79a0ec099ead05211852cc8b617b35c3b319a403a0a1517ed3d09639b146b07abcc73a2fd3dba4045cfb5ce768ae06bec1b81'
'a6b2fd7a688ef5a23539c1256380a6389e6fa474312ad9dee5cc77bcfabe92910a8913ffcf599c940a93bb3a5c89e01f3bedad4176f4d57dd33a68e0499c30bd'
'd5a6845cb1ddb07f0cac20215c15d059f0c18aa43a7b549e7e738e58b8686b4db26b71426aafc8e682d6fd6f676fc0f468f53ea61968c4184feaaa22a23f5bc5')
prepare() {
cd "${pkgname}-${pkgver}"
mkdir -p build/
}
build() {
cd "${pkgname}-${pkgver}"
export CGO_CPPFLAGS="${CPPFLAGS}"
export CGO_CFLAGS="${CFLAGS}"
export CGO_CXXFLAGS="${CXXFLAGS}"
export CGO_LDFLAGS="${LDFLAGS}"
export GOFLAGS="-buildmode=pie -trimpath -mod=readonly -modcacherw"
_LDFLAGS="-X main.goos=$(go env GOOS) -X main.goarch=$(go env GOARCH) -X main.version=${pkgver} -X main.branch=tag-${pkgver} -X main.commit=tag-${pkgver}"
go build -o build -ldflags="${_LDFLAGS}" "./cmd/telegraf"
}
package() {
# binary
install -D -m755 "${srcdir}/${pkgname}-${pkgver}/build/telegraf" \
"${pkgdir}/usr/bin/telegraf"
# configuration files
install -dD -m755 "${pkgdir}/etc/telegraf/telegraf.d"
"${srcdir}/${pkgname}-${pkgver}/build/telegraf" -sample-config > \
"${pkgdir}/etc/telegraf/telegraf.conf"
# license
install -Dm644 "${srcdir}/${pkgname}-${pkgver}/LICENSE" \
"${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
# service
install -D -m644 "${srcdir}/${pkgname}.service" \
"${pkgdir}/usr/lib/systemd/system/${pkgname}.service"
}