summaryrefslogtreecommitdiffstats
path: root/main/smokeping/APKBUILD
blob: 24f5de44abc913e6b2abd136c597be142e1af0df (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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# Contributor: Jeff Bilyk <jbilyk@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=smokeping
pkgver=2.6.9
pkgrel=0
pkgdesc="Smokeping network latency monitoring"
pkgusers="smokeping"
pkggroups="smokeping"
install="$pkgname.pre-install"
url="http://oss.oetiker.ch/smokeping/"
source="http://oss.oetiker.ch/smokeping/pub/smokeping-$pkgver.tar.gz
	smokeping.initd
	smokeping-perl-5.18.patch
	xss-fix-from-Steven-Chamberlain.patch"
depends="perl fping rrdtool perl-rrd
	perl-uri
	perl-digest-hmac
	perl-cgi-session
	perl-libwww
	perl-snmp-session
	perl-net-dns
	perl-fcgi
	perl-config-grammar
	"
arch="noarch"
license="GPL"
subpackages="$pkgname-doc"

_builddir="$srcdir"/$pkgname-$pkgver
_vendorlib=/usr/share/perl5/vendor_perl

prepare() {
	cd "$_builddir"

	for i in $source; do
		case $i in
			*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
		esac
	done

	# provided by perl-snmp-session
	rm -r lib/BER.pm lib/SNMP_Session.pm lib/SNMP_util.pm
}

build() {
	cd "$_builddir"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--bindir=/usr/bin \
		--libdir=/usr/lib \
		--sysconfdir=/etc/smokeping \
		--libexecdir=/usr/libexec \
		--datarootdir=/usr/share \
		--mandir=/usr/share/man \
		--with-htdocs-dir=/usr/share/webapps/smokeping \
		|| return 1
}

package() {
	cd "$_builddir"
	make DESTDIR="$pkgdir" install || return 1

	for i in basepage.html config smokemail smokeping_secrets tmail; do
		mv "$pkgdir"/etc/smokeping/${i}.dist "$pkgdir"/etc/smokeping/${i}
	done

	# Next part here cleans up the mess that the Makefile leaves behind...

	mkdir -p "$pkgdir"/$_vendorlib
	mv "$pkgdir"/usr/lib/Smokeping.pm "$pkgdir"/$_vendorlib/
	mv "$pkgdir"/usr/lib/Smokeping "$pkgdir"/$_vendorlib/

	# Fix path to config file
	sed -i -e 's#/usr/etc/config#/etc/smokeping/config#' "$pkgdir"/usr/share/webapps/smokeping/smokeping.fcgi.dist
	
	# Install cgi in the right spot and fix permissions
	mv "$pkgdir"/usr/share/webapps/smokeping/smokeping.fcgi.dist "$pkgdir"/usr/share/webapps/smokeping/smokeping.cgi
	chmod 755 "$pkgdir"/usr/share/webapps/smokeping/smokeping.cgi

	# Fix up some paths within smokeping.cgi
	sed -i -e 's:^use lib:#use lib:' \
		-e 's:/etc/config:/etc/smokeping/config:' \
		-e '1s:.*:#!/usr/bin/perl:' \
		"$pkgdir"/usr/bin/smokeping_cgi || return 1

	for i in smokeping smokeinfo; do
		sed -e 's:^use lib:#use lib:g' \
			-e 's:etc/config:etc/smokeping/config:' \
			-i "$pkgdir"/usr/bin/$i
	done

	sed -e 's#Smokeping::main("$FindBin::Bin/../etc/config")#Smokeping::main("/etc/smokeping/config")#' \
		-i "$pkgdir"/usr/bin/smokeping
	
	sed -e 's:etc/config.dist:etc/smokeping/config:' \
		-i "$pkgdir"/usr/bin/tSmoke
	
	# config
	sed -e '/^imgcache/{s:\(^imgcache[ \t]*=\).*:\1 /var/lib/smokeping/.simg:}' \
		-e '/^imgurl/{s:\(^imgurl[ \t]*=\).*:\1 img:}' \
		-e '/^datadir/{s:\(^datadir[ \t]*=\).*:\1 /var/lib/smokeping:}' \
		-e '/^piddir/{s:\(^piddir[ \t]*=\).*:\1 /var/run/smokeping:}' \
		-e '/^cgiurl/{s#\(^cgiurl[ \t]*=\).*#\1 http://some.place.xyz/perl/smokeping.pl#}' \
		-e '/^smokemail/{s:\(^smokemail[ \t]*=\).*:\1 /etc/smokeping/smokemail:}' \
		-e '/^tmail/{s:\(^tmail[ \t]*=\).*:\1 /etc/smokeping/tmail:}' \
		-e '/^secrets/{s:\(^secrets[ \t]*=\).*:\1 /etc/smokeping/smokeping_secrets:}' \
		-e '/^template/{s:\(^template[ \t]*=\).*:\1 /etc/smokeping/basepage.html:}' \
		-e '/^sendmail/{s:usr/lib:usr/sbin:}' \
		-i "$pkgdir"/etc/smokeping/config || return 1

	# Create softlink for image directory
	ln -s /var/lib/smokeping/.simg/ "$pkgdir"/usr/share/webapps/smokeping/img

	sed -e '/^<script/{s:cropper/:/cropper/:}' \
		-i "$pkgdir"/etc/smokeping/basepage.html \
		|| return 1

	chmod 700 "$pkgdir"/etc/smokeping/smokeping_secrets
	
	# initscript
	install -Dm755 "$srcdir"/smokeping.initd "$pkgdir"/etc/init.d/smokeping\
		|| return 1

	install -d -o smokeping -g smokeping -m755 \
		"$pkgdir"/var/lib/smokeping \
		"$pkgdir"/var/lib/smokeping/.simg \
		"$pkgdir"/var/run/smokeping
}

md5sums="0c2361b734866dd37facf2af3f8f7144  smokeping-2.6.9.tar.gz
a63b42b8165f9c728706ac112658548b  smokeping.initd
d6aaecc3110968671248b7bebbdb087b  smokeping-perl-5.18.patch
cee64c8fe5d813534dfb29c2cd3a1324  xss-fix-from-Steven-Chamberlain.patch"
sha256sums="cd551d4384d8b19879d128ea0566bd680c19bb4ad8664a3c5a304604746f8863  smokeping-2.6.9.tar.gz
1b83d2e35e922e71bb3c91deee7c247cfbaebe47022451aabde87b790c5a61ca  smokeping.initd
961bcb8979de2ff508c988d79f8b54bb936fc29ed8bf28c6377458c12a1e3f2f  smokeping-perl-5.18.patch
f7750494a81e56dac2d8c7bc996eb63ac590168fff92d237e883807c036f07ac  xss-fix-from-Steven-Chamberlain.patch"
sha512sums="ab3cec15fd9f90510f902da7ce5bac5915558cac198cc88f0ce193a53a0158c9055e28c8c6671cc6653ac42ab51346e1eb19e537f1ab5c234fd498c6b777499d  smokeping-2.6.9.tar.gz
b1d6f769b870a14856f4e4f6e699d6a9eb7744d9c447e5cd799cf21dd1eb83807aaa270029e15a49c709e8a9160c395d264bcc1d3281233160e2a907e61473ad  smokeping.initd
8b415778970ca9093fb8847cb391aea2546041512496e2f74e755358f2d6dd0a9e6e332c8a9c90a09da5f3eeeb4aabd3f1e188c1d63e324a17ee06f20e259ca2  smokeping-perl-5.18.patch
ab13cbf69a8b7d9cce7684eaf6a61ff5d827bcd4abc04cec7df47a97ab4d73eac5034addcb8e061ced246a2dcff69d04a9114b89e6c20014e2f3eb6c8fff0c11  xss-fix-from-Steven-Chamberlain.patch"