aboutsummaryrefslogtreecommitdiffstats
path: root/main/collectd/APKBUILD
blob: 438f0e8c0d53dcae32fb3595e3545b09929a365f (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# Contributor: 
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=collectd
pkgver=5.0.0
pkgrel=3
pkgdesc="The system statistics collection daemon"
url="http://collectd.org"
arch="all"
license="GPL"
depends=
makedepends="pkgconfig curl-dev net-snmp-dev postgresql-dev perl-dev
	libgcrypt-dev mysql-dev zlib-dev openssl-dev iptables-dev"
install=
subpackages="$pkgname-dev $pkgname-doc $pkgname-perl $pkgname-snmp $pkgname-curl
	$pkgname-write_http $pkgname-nginx $pkgname-apache $pkgname-postgresql
	$pkgname-mysql $pkgname-network"

source="http://collectd.org/files/collectd-$pkgver.tar.bz2
	collectd-4.10.3-iptc-check.patch
	collectd.initd"

_builddir="$srcdir"/$pkgname-$pkgver

prepare() {
	cd "$_builddir"
	for i in $source; do
		case $i in
		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
		esac
	done
	# we need -lm
	sed -i -e 's/^collectd_LDADD = \(.*\)/collectd_LDADD = -lm \1/' \
		-e 's/^collectd_nagios_LDADD = \(.*\)/collectd_nagios_LDADD = -lm \1/' \
		src/Makefile.in || return 1
	sed -i -e 's/_LIBADD =/_LIBADD = -lm/' \
		src/libcollectdclient/Makefile.in || return 1
	sed -i -e '/CFLAGS/s/-Werror//' configure src/Makefile.in || return 1
}

build() {
	cd "$_builddir"
	./configure --prefix=/usr \
		--sysconfdir=/etc/collectd \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstate=/var \
		|| return 1
	make LDADD='-lm' || return 1
	# disable network plugin by default since its in a subpackage
	sed -i -e 's/^LoadPlugin network/#LoadPlugin network/' \
		src/collectd.conf
}

package() {
	cd "$_builddir"
	make DESTDIR="$pkgdir" install || return 1
	rm "$pkgdir"/usr/lib/*.la \
		"$pkgdir"/usr/lib/collectd/*.la || return 1

	find "$pkgdir" -name perllocal.pod -delete
	install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
}

perl() {
	pkgdesc="perl bindings to collectd"
	depends="perl"
	arch="noarch"
	install -d "$subpkgdir"/usr/lib/ "$subpkgdir"/usr/share
	mv "$pkgdir"/usr/lib/perl* "$subpkgdir"/usr/lib/
	mv "$pkgdir"/usr/share/perl* "$subpkgdir"/usr/share/
}

_plugin() {
	local mod=$1
	local desc=${2:-$mod}
	pkgdesc="$desc pluin for collectd"
	depends="collectd"
	install -d "$subpkgdir"/usr/lib/collectd
	mv "$pkgdir"/usr/lib/collectd/$mod.so "$subpkgdir"/usr/lib/collectd/
}

snmp()		{ _plugin snmp; }
curl() 		{ _plugin curl; }
write_http() 	{ _plugin write_http; }
nginx()		{ _plugin nginx; }
apache()	{ _plugin apache; }
postgresql()	{ _plugin postgresql; }
mysql()		{ _plugin mysql; }
network()	{ _plugin network; }

md5sums="7bfea6e82d35b36f16d1da2c71397213  collectd-5.0.0.tar.bz2
38f2ac1754e0dc0fcc70a04574cc7437  collectd-4.10.3-iptc-check.patch
13a36ae2f92634b5619ab94224e1b77d  collectd.initd"