Subject: [alpine-devel] Zabbix APKBUILD

From: Carlo Landmeter <[email-masked]>
Date: Fri, 28 Jan 2011 23:56:30 +0100

Hi,

I wanted to give Zabbix a try but it didn't find the supported db I
needed. It seems Zabbix does not support building against multiple
db's so we must build it separately.
Because i don't like seeing so many APKBUILD files for the same
program I modified the current one to build against 3 db's mysql pgsql
and sqlite.
Im not sure if this is preferred or will cause any issues so im
including my work as a complete apkbuild instead of a diff for review.
If this is OK i will commit to my tree.
I also made some other changes which seems to make sense.

### APKBUILD ###

# Contributor: Jeff Bilyk <jbilyk at gmail>
# Maintainer: Natanael Copa <[email-masked]>
pkgname=zabbix
pkgver=1.8.4
pkgrel=2
pkgdesc="Enterprise-class open source distributed monitoring"
url="www.zabbix.com"
arch="all"
license="GPL"
depends="fping"
makedepends="postgresql-dev curl-dev libiconv-dev net-snmp-dev
        sqlite-dev mysql-dev curl-dev"
install="$pkgname.pre-install"
pkgusers="zabbix"
pkggroups="zabbix"
subpackages="$pkgname-doc $pkgname-agent $pkgname-pgsql $pkgname-mysql
        $pkgname-webif $pkgname-sqlite $pkgname-utils $pkgname-setup"
source="http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz
        zabbix_server.conf
        zabbix_trapper.conf
        zabbix_proxy.conf
        zabbix_agentd.conf
        zabbix-dn_skipname.patch
        zabbix-getloadavg.patch
        zabbix-server.initd
        zabbix-agentd.initd
        zabbix-proxy.initd
        "

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

prepare() {
        cd "$_builddir"
        for i in $source; do
                case $i in
                *.patch)
                        msg "Applying $i"
                        patch -p1 -i "$srcdir"/$i || return 1
                        ;;
                esac
        done
}

build() {
        # set default configure flags
        _configure="--prefix=/usr \
                        --sysconfdir=/etc \
                        --mandir=/usr/share/man \
                        --infodir=/usr/share/info \
                        --enable-server \
                        --enable-agent \
                        --enable-proxy \
                        --enable-ipv6 \
                        --with-net-snmp \
                        --with-libcurl
                        "
        # we run build for each db type
        # make sure prepare is same for each db
        for db in pgsql mysql sqlite3; do
                cd "$srcdir"
                msg "Building for $db"
                cp -r "$pkgname-$pkgver" "$pkgname-$pkgver-$db"
                cd "$_builddir-$db"
                ./configure --with-$db \
                        $_configure
                make || return 1
        done
}

package() {
        # doing manual install
        for i in agentd proxy server; do
                install -D -m755 "$_builddir"/man/zabbix_$i.man \
                        "$pkgdir"/usr/share/man/man8/zabbix_$i.8
        done
        for i in get sender; do
                install -D -m755 "$_builddir"/man/zabbix_$i.man \
                        "$pkgdir"/usr/share/man/man1/zabbix_$i.1
        done
        install -d -m0750 -o zabbix -g zabbix \
                "$pkgdir"/var/run/zabbix "$pkgdir"/var/log/zabbix
        install -D -m0644 "$srcdir"/zabbix_server.conf \
                "$pkgdir"/etc/zabbix/zabbix_server.conf
        install -D -m0644 "$srcdir"/zabbix_trapper.conf \
                "$pkgdir"/etc/zabbix/zabbix_trapper.conf
        for i in server proxy; do
                install -D -m0755 "$srcdir"/zabbix-$i.initd \
                        "$pkgdir"/etc/init.d/zabbix-$i || return 1
        done
}

setup() {
        pkgdesc="Zabbix images and sql files"
        depends=
        mkdir -p "$subpkgdir"/usr/share/zabbix/create
        mv "$srcdir"/$pkgname-$pkgver/create/data \
                "$subpkgdir"/usr/share/zabbix/create
        mv "$srcdir"/$pkgname-$pkgver/create/schema \
                "$subpkgdir"/usr/share/zabbix/create
}

_do_db() {
        pkgdesc="Zabbix server with $1 database support"
        depends=$pkgname
        mkdir -p "$subpkgdir"/usr/sbin
        mv "$_builddir-$1"/src/zabbix_server/zabbix_server \
                "$subpkgdir"/usr/sbin/ || return 1
        mv "$_builddir-$1"/src/zabbix_proxy/zabbix_proxy \
                "$subpkgdir"/usr/sbin/ || return 1
        return 0
}

pgsql()         { _do_db pgsql; }
mysql()         { _do_db mysql; }
sqlite()        { _do_db sqlite3; }

utils() {
        pkgdesc="Zabbix client utilities"
        depends=
        mkdir -p "$subpkgdir"/usr/bin
        mv "$_builddir-pgsql"/src/zabbix_get/zabbix_get \
                "$subpkgdir"/usr/bin
        mv "$_builddir-pgsql"/src/zabbix_sender/zabbix_sender \
                        "$subpkgdir"/usr/bin
}

webif() {
        pkgdesc="Zabbix web-interface"
        depends="php php-pgsql php-gd php-curl php-bcmath php-sockets php-iconv"
        _wwwdir="$subpkgdir"/usr/share/webapps/zabbix
        mkdir -p $_wwwdir
        mv "$_builddir"/frontends/php/* "$_wwwdir"
}

agent() {
        pkgdesc="Zabbix Network Monitoring Agent"
        depends=
        install="$subpkgname.pre-install"
        install -d -m0750 -o zabbix -g zabbix \
                "$subpkgdir"/var/run/zabbix "$subpkgdir"/var/log/zabbix
        install -D -m0644 "$srcdir"/zabbix_agentd.conf \
                "$subpkgdir"/etc/zabbix/zabbix_agentd.conf
        install -D -m0755 "$srcdir"/zabbix-agentd.initd \
                "$subpkgdir"/etc/init.d/zabbix-agentd
        mkdir -p "$subpkgdir"/usr/sbin
        mv "$_builddir-pgsql"/src/zabbix_agent/zabbix_agent \
                "$subpkgdir"/usr/sbin/
        mv "$_builddir-pgsql"/src/zabbix_agent/zabbix_agentd \
                        "$subpkgdir"/usr/sbin/

}

md5sums="969ce09317c98b205bc96157e16f5c8c  zabbix-1.8.4.tar.gz
26b0401a83bdb1dce29338e5b2786620  zabbix_server.conf
9832a81e134c8e2c11e2a06b7adbf88f  zabbix_trapper.conf
0310b92afb3f35c1075fff53db737212  zabbix_proxy.conf
721c18077fa739f956340afca9f067f4  zabbix_agentd.conf
d13166483792401be2d25b37b0170b82  zabbix-dn_skipname.patch
8d1d2e53479173aac0df0c38a4d6afda  zabbix-getloadavg.patch
e42394e798ab98a8ff4babe68e04633a  zabbix-server.initd
88374bba8a8fdfabfcfe9be6dd12095f  zabbix-agentd.initd
32abde1cc00c2eeccddb7e038117d0ab  zabbix-proxy.initd"

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---

---

From: "Computer Department (Watchtower South Africa Branch)" <[email-masked]>
Date: Mon, 31 Jan 2011 08:38:48 +0200

Apologies for top-posting...

Thanks for figuring out a way to do this! I had wanted to do something
like this before, so this is great. 

Just one point - we probably want to add a "replaces=zabbix" line to
support upgrading. And pkgrel should be 3 if my earlier commit from
Friday gets put in.

Thanks!

duane hughes

-----Original Message-----
From: Carlo Landmeter [mailto:[email-masked]] 
Sent: 29 January 2011 00:57
To: Alpine-devel
Subject: [alpine-devel] Zabbix APKBUILD

Hi,

I wanted to give Zabbix a try but it didn't find the supported db I
needed. It seems Zabbix does not support building against multiple db's
so we must build it separately.
Because i don't like seeing so many APKBUILD files for the same program
I modified the current one to build against 3 db's mysql pgsql and
sqlite.
Im not sure if this is preferred or will cause any issues so im
including my work as a complete apkbuild instead of a diff for review.
If this is OK i will commit to my tree.
I also made some other changes which seems to make sense.

### APKBUILD ###

# Contributor: Jeff Bilyk <jbilyk at gmail> # Maintainer: Natanael Copa
<[email-masked]> pkgname=zabbix
pkgver=1.8.4
pkgrel=2
pkgdesc="Enterprise-class open source distributed monitoring"
url="www.zabbix.com"
arch="all"
license="GPL"
depends="fping"
makedepends="postgresql-dev curl-dev libiconv-dev net-snmp-dev
        sqlite-dev mysql-dev curl-dev"
install="$pkgname.pre-install"
pkgusers="zabbix"
pkggroups="zabbix"
subpackages="$pkgname-doc $pkgname-agent $pkgname-pgsql $pkgname-mysql
        $pkgname-webif $pkgname-sqlite $pkgname-utils $pkgname-setup"
source="http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.g
z
        zabbix_server.conf
        zabbix_trapper.conf
        zabbix_proxy.conf
        zabbix_agentd.conf
        zabbix-dn_skipname.patch
        zabbix-getloadavg.patch
        zabbix-server.initd
        zabbix-agentd.initd
        zabbix-proxy.initd
        "

prepare() {
        cd "$_builddir"
        for i in $source; do
                case $i in
                *.patch)
                        msg "Applying $i"

build() {

package() {
        # doing manual install

setup() {

_do_db() {

utils() {
                        "$subpkgdir"/usr/bin }

webif() {
        pkgdesc="Zabbix web-interface"
        depends="php php-pgsql php-gd php-curl php-bcmath php-sockets
php-iconv"
        _wwwdir="$subpkgdir"/usr/share/webapps/zabbix
        mkdir -p $_wwwdir
        mv "$_builddir"/frontends/php/* "$_wwwdir"
}

agent() {

}

---

---

---

From: Carlo Landmeter <[email-masked]>
Date: Tue, 1 Feb 2011 20:49:08 +0100

On Mon, Jan 31, 2011 at 7:38 AM, Computer Department (Watchtower South
> support upgrading. And pkgrel should be 3 if my earlier commit from

Because your changes are already in my apkbuild I just commited it
like this and its currently in aports. Hope you don't mind.

-carlo

---