aboutsummaryrefslogtreecommitdiffstats
path: root/community/prometheus/APKBUILD
blob: 0e045a57efa7d75e2df0eafc806ed10a6a8b3b7e (plain) (blame)
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# Maintainer: Drew DeVault <sir@cmpwn.com>
pkgname=prometheus
pkgver=2.29.2
pkgrel=1
pkgdesc="The Prometheus monitoring system and time series database"
url="https://github.com/prometheus/prometheus"
# mips64 and riscv64 blocked by nodejs -> yarn
arch="all !mips64 !riscv64"
license="Apache-2.0"
options="!check" # Broken by integrations we don't care about
install="prometheus.pre-install"
makedepends="go yarn bash"
subpackages="$pkgname-openrc"
source="$pkgname-$pkgver.tar.gz::https://github.com/prometheus/prometheus/archive/v$pkgver.tar.gz
	prometheus.initd
	prometheus.confd
	"

# secfixes:
#   2.27.1-r0:
#     - CVE-2021-29622

build() {
	cd web/ui/react-app
	yarn --frozen-lockfile
	yarn lint
	cd ../../../
	./scripts/build_react_app.sh
	cd web/ui
	go generate -x -v
	cd ../../
	gofmt -w ./web/ui

	GOLDFLAGS="-X github.com/prometheus/common/version.Version=$pkgver
	        -X github.com/prometheus/common/version.Revision=AlpineLinux
			-X github.com/prometheus/common/version.Branch=master
	        -X github.com/prometheus/common/version.BuildUser=$USER@$HOSTNAME
			-X github.com/prometheus/common/version.BuildDate=$(date -u "+%Y%m%d-%H:%M:%S" ${SOURCE_DATE_EPOCH:+-d @$SOURCE_DATE_EPOCH})
	"

	if [ -n "$LDFLAGS" ]; then
		# LDFLAGS (and only LDFLAGS) should be passed to -extldflags.
		GOLDFLAGS="$GOLDFLAGS -extldflags $LDFLAGS"
	fi

	go mod vendor
	go build \
		-trimpath \
		-mod=vendor \
		-ldflags "$GOLDFLAGS" \
		-tags netgo,builtinassets \
		./cmd/prometheus
	go build \
		-trimpath \
		-mod=vendor \
		-ldflags "$GOLDFLAGS" \
		./cmd/promtool
}

check() {
	go test ./...
}

package() {
	install -Dm755 prometheus "$pkgdir"/usr/bin/prometheus
	install -Dm755 promtool "$pkgdir"/usr/bin/promtool

	install -Dm644 "$srcdir"/prometheus.confd \
		"$pkgdir"/etc/conf.d/prometheus
	install -Dm755 "$srcdir"/prometheus.initd \
		"$pkgdir"/etc/init.d/prometheus
	install -dm644 "$pkgdir"/var/lib/prometheus/data

	install -Dm644 -t "$pkgdir"/etc/prometheus \
		documentation/examples/prometheus.yml

	mkdir -p "$pkgdir"/etc/prometheus/console_libraries
	for file in console_libraries/*
	do
		install -Dm644 -t "$pkgdir"/etc/prometheus/console_libraries/ "$file"
	done

	mkdir -p "$pkgdir"/etc/prometheus/consoles
	for file in consoles/*
	do
		install -Dm644 -t "$pkgdir"/etc/prometheus/consoles/ "$file"
	done
}

sha512sums="
976bc2f33cd6060e0179712e7433de2c37d8f4607827b090360327e2176b597eddb870df52ec7ee03fcc564e972f79910ae12bfb0096ffe99ef3c6ff3eae74d8  prometheus-2.29.2.tar.gz
eb0cebe41782f90079f367832f7c9efa18b99df410506b65b2e0b11fa05f8f2956f68c0fca836664729d50b85fc969a96e99e1d32012fe3c655cddc0b16a7561  prometheus.initd
24b34e586238d5b331639aa5c43b6a927692f251af2cea2787335eab30d2fc7d46975059595db4697ae0dc1d35b5e23cfc4e4b2e424442c209a05283ca22a239  prometheus.confd
"