blob: eee5a01500bb09f884ff46626e0cceb66b3e1e1c (
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
|
# Maintainer: PinkD <443657547@qq.com>
_pkgbase=ping_exporter
pkgname=prometheus-ping-exporter
pkgver=1.0.1
pkgrel=1
pkgdesc='A simple server that scrapes go-ping stats and exports them via HTTP for Prometheus consumption'
arch=('x86_64')
url="https://github.com/czerwonk/${_pkgbase}"
license=('MIT')
makedepends=('go' 'git')
source=("$_pkgbase"::"git+${url}.git#tag=${pkgver}")
sha256sums=('SKIP')
backup=("etc/$_pkgbase/config.yml" "etc/conf.d/$pkgname")
prepare(){
mkdir -p "$srcdir/gopath"
export GOPATH="$srcdir/gopath"
cd "$srcdir/$_pkgbase"
# add env to pass args to command line
sed -i -e "s/ExecStart=\/usr\/bin\/$_pkgbase/EnvironmentFile=-\/etc\/conf.d\/$pkgname\nExecStart=\/usr\/bin\/$pkgname \$PING_EXPORTER_ARGS/g" dist/$_pkgbase.service
mkdir -p build/
}
build() {
cd "$srcdir/$_pkgbase"
local _goldflags="-w -s"
go build \
-trimpath -mod=readonly -modcacherw \
-o "build/$_pkgbase" \
-ldflags "$_goldflags" \
.
}
package() {
# install ping_exporter
install -Dm755 "$srcdir/$_pkgbase/build/$_pkgbase" "$pkgdir/usr/bin/$pkgname"
# install config
install -Dm644 "$srcdir/$_pkgbase/dist/$_pkgbase.yaml" "$pkgdir/etc/$_pkgbase/config.yml"
# install conf.d
install -Dm644 "$startdir/$_pkgbase.conf.d" "$pkgdir/etc/conf.d/$pkgname"
# install systemd units
install -Dm644 "$srcdir/$_pkgbase/dist/$_pkgbase.service" "$pkgdir/usr/lib/systemd/system/$pkgname.service"
# install sys user
install -Dm644 "$startdir/$_pkgbase.sysusers" "$pkgdir/usr/lib/sysusers.d/$pkgname.conf"
# install license
install -Dm644 "$srcdir/$_pkgbase/LICENSE" "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
# install README.md
install -Dm644 "$srcdir/$_pkgbase/README.md" "$pkgdir/usr/share/doc/$pkgname/README.md"
}
|