# Contributor: Peter de Zoeten <peter@dezoeten.mine.nu>
# Maintainer:  Peter de Zoeten <peter@dezoeten.mine.nu>
setvar pkgname = 'pnp4nagios'
setvar pkgver = '0.6.15'
setvar pkgrel = '0'
setvar pkgdesc = ""PNP4Nagios""
setvar url = ""http://www.pnp4nagios.org""
setvar arch = ""all""
setvar license = ""GPL""
setvar depends = ""nagios perl-time-hires perl-rrd php-zlib""
setvar depends_dev = """"
setvar makedepends = "$depends_dev"
setvar install = """"
setvar subpackages = ""$pkgname-doc""
setvar source = ""http://sourceforge.net/projects/pnp4nagios/files/PNP-0.6/pnp4nagios-$pkgver.tar.gz""

setvar _builddir = ""$srcdir"/$pkgname-$pkgver"
proc prepare {
       local i
       cd $_builddir
       for i in $source {
               case (i) {
               *.patch { msg $i; patch -p1 -i "$srcdir"/$i || return 1}
               }
       }
}

proc build {
       cd $_builddir
       ./configure --prefix=/usr/share/webapps/pnp4nagios \
       		--exec-prefix=/usr \
       		--libexecdir=/usr/lib/pnp4nagios \
       		--sysconfdir=/etc/pnp4nagios \
		--mandir=/usr/share/man \
       		--infodir=/usr/share/info \
       		--localstatedir=/var/run \
       		--datarootdir=/usr/share/webapps/pnp4nagios \
       		--with-perfdata-logfile=/var/pnp4nagios/perfdata/process_perfdata.pl \
       		--with-perfdata-dir=/var/pnp4nagios/perfdata \
       		--with-perfdata-spool-dir=/var/pnp4nagios/perfdata/spool \
       		|| return 1
       make all || return 1
}
proc doc {
        setvar arch = ""noarch""
        # Man pages
        mkdir -p "$subpkgdir"/usr/share/man || return 1
        mv "$pkgdir"/usr/share/webapps/pnp4nagios/man/man* "$subpkgdir"/usr/share/man/ \
        || return 1

        # Doc files
        setvar _docs = ""INSTALL README""
        for _doc in $_docs {
                install -Dm644 "$srcdir"/$pkgname-$pkgver/$_doc \
	        "$subpkgdir"/usr/share/doc/$pkgname/$_doc || return 1
        }
	rmdir "$pkgdir"/usr/share/webapps/pnp4nagios/man
}

proc package {
       cd $_builddir
       make fullinstall DESTDIR="$pkgdir" || return 1
       mkdir -p "$pkgdir"/usr/share/nagios/htdocs/ssi
       cp "$_builddir"/contrib/ssi/status-header.ssi "$pkgdir"/usr/share/nagios/htdocs/ssi/status-header.ssi
#       rm -rf "$pkgdir"/etc/httpd
       mkdir -p "$pkgdir"/etc/lighttpd
       cp "$_builddir"/sample-config/lighttpd.pnp4nagios.conf "$pkgdir"/etc/lighttpd/pnp4nagios.conf.sample
       install -D -m644 ../../npcd.cfg "$pkgdir"/etc/pnp4nagios/npcd.cfg
       rm -f "$pkgdir"/etc/init.d/npcd
       install -D -m755 ../../npcd "$pkgdir"/etc/init.d/npcd
       chown nagios.nagios "$pkgdir"/var/pnp4nagios
}


setvar md5sums = ""27cdab96510e15cfa0f4b7c2bf15dd2b  pnp4nagios-0.6.15.tar.gz""