view app-admin/collectd/collectd-4.4.2.ebuild @ 145:93b38fc95d26

ebuild for new Skype beta version
author Dirk Olmes <dirk@xanthippe.ping.de>
date Wed, 02 Sep 2009 02:53:28 +0200
parents baac049cd305
children
line wrap: on
line source

# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit autotools eutils flag-o-matic linux-info

DESCRIPTION="A small daemon which collects system performance statistics"
HOMEPAGE="http://collectd.org"

SRC_URI="${HOMEPAGE}/files/${P}.tar.bz2"
LICENSE="GPL-2"

SLOT="0"

KEYWORDS="~amd64 ~x86"
HTTP_FLAGS="apache2 lighttpd nginx"
LIBVIRT_FLAGS="kvm openvz qemu xen"
IUSE="apcups dns email hal hddtemp ipmi ithreads lm_sensors
    memcache mysql network nfs ntp nut perl rrdtool snmp
    syslog vserver wifi ${HTTP_FLAGS} ${LIBVIRT_FLAGS}
"
HTTP_DEPEND="
    apache2?	( >=net-misc/curl-7.17.0 )
    lighttpd?	( >=net-misc/curl-7.17.0 )
    nginx?	( >=net-misc/curl-7.17.0 )
"
LIBVIRT_DEPEND="
    kvm?	( >=app-emulation/libvirt-0.3.3 )
    openvz?	( >=app-emulation/libvirt-0.3.3 )
    qemu?	( >=app-emulation/libvirt-0.3.3 )
    xen?	( >=app-emulation/libvirt-0.3.3 )
"
COMMON_DEPEND="${HTTP_DEPEND} ${LIBVIRT_DEPEND}
    dns?	( >=net-libs/libpcap-0.9.8 )
    hal?	( >=sys-apps/hal-0.5.9.1-r3 )
    ipmi?	( >=sys-libs/openipmi-2.0.11 )
    lm_sensors?	( >=sys-apps/lm_sensors-2.10.4 )
    mysql?	( >=virtual/mysql-5.0 )
    perl?	( >=dev-lang/perl-5.8.8-r4 )
    nut?	( >=sys-power/nut-2.2.0 )
    rrdtool?	( >=net-analyzer/rrdtool-1.2.27 )
    snmp?	( >=net-analyzer/net-snmp-5.4.1-r3 )
"
DEPEND="${COMMON_DEPEND}
    sys-devel/libtool
    >=dev-libs/libxml2-2.6.31
"
RDEPEND="${COMMON_DEPEND}
    apcups?	( >=sys-power/apcupsd-3.14.2 )
    !hal?	( >=sys-apps/dmidecode-2.9 )
    hddtemp?	( >=app-admin/hddtemp-0.3_beta15-r3 )
    memcache?	( >=net-misc/memcached-1.2.2-r2 )
    ntp?	( >=net-misc/ntp-4.2.4_p4 )
    syslog?	( virtual/logger )
"

pkg_setup()
{
    linux-info_pkg_setup
    local flag

    (linux_chkconfig_present ACPI_BATTERY) \
    || ewarn "ACPI_BATTERY needs to be enabled in your kernel for the battery plug-in to work correctly"
    (linux_chkconfig_present CPU_FREQ) \
    || ewarn "CPU_FREQ needs to be enabled in your kernel for the cpufreq plug-in to work correctly"
    (linux_chkconfig_present SERIAL_CORE) \
    || ewarn "SERIAL_CORE needs to be enabled in your kernel for the serial plug-in to work correctly"
    (linux_chkconfig_present SWAP) \
    || ewarn "SWAP needs to be enabled in your kernel for the swap plug-in to work correctly"    
    (use vserver) && !(linux_chkconfig_present IP_VS) \
    && ewarn "IP_VS should to be enabled in your kernel when the USE flag vserver is enabled"

    for flag in "${LIBVIRT_FLAGS}"; do
        (use ${flag}) && !(built_with_use app-emulation/libvirt ${flag}) && \
	die "USE flag ${flag} requires that libvirt was compiled with the USE flag ${flag}"
    done    
    
    if (use perl); then
	if (use ithreads); then
	    (built_with_use perl ithreads) \
	    || die "The perl plug-in requires that libperl was compiled with the USE flag ithreads"
	else
	    ewarn "The perl plug-in requires the ithreads USE flag."
	fi
    fi

    ((linux_chkconfig_present PROC_FS) && (linux_chkconfig_present SYSFS)) \
    || die "${P} requires that PROC_FS and SYSFS are enabled in your kernel"
}

src_unpack()
{
    unpack ${A}
    cd "${S}"

    ebegin "Applying sed no-automagic-patch"
    sed -i -e '/^AC_PLUGIN/ s/\ [[].*[]],/[no],/' \
    configure.in \
    || die "sed no-automagic-patch failed"
    eend 0

    epatch "${FILESDIR}/${PN}-4.4.2-ipvs.patch"
    epatch "${FILESDIR}/${PN}-4.4.2-localstatedir.patch"
    epatch "${FILESDIR}/${PN}-4.4.2-libtool-compatibility.patch"

    ebegin "Remove provided libtool/libltdl"
    rm -R ./libltdl \
    && rm config.guess config.sub install-sh ltmain.sh \
    || die "removing libtool failed"
    eend 0

    eautoreconf || die "eautoreconf failed"
}

src_compile()
{
    local flag
    local myconf
    local no_check_plugins="csv df logfile multimeter tail users uuid"
    local proc_sys_fs_plugins="battery cpu cpufreq disk entropy irq load memory processes serial swap vmem"
    local network_plugins="interface iptables network ping teamspeak2 tcpconns unixsock"

    for flag in ${no_check_plugins} ${proc_sys_fs_plugins}; do
	myconf+=" --enable-${flag}"
    done

    if (use network); then
	for flag in ${network_plugins}; do
	    myconf+=" --enable-${flag}"
	done
    fi

    myconf+="
    $(( use apache2 || use lighttpd ) && echo --enable-apache)
    $(use_enable apcups)
    $(use_enable dns)
    $(use_enable hddtemp)
    $(use_enable email)
    $(use_enable ipmi)
    $(use_enable vserver ipvs)
    $(( use kvm || use openvz || use qemu || use xen ) && echo --enable-libvirt)
    $(use_enable memcache memcached)
    $(use_enable mysql)
    $(use_enable nfs)
    $(use_enable nginx)
    $(use_enable ntp ntpd)
    $(use_enable nut)
    $(use_enable dns powerdns)
    $(use_enable snmp)
    $(use_enable syslog)
    $(use_enable rrdtool)
    $(use_enable vserver)
    $(use_enable lm_sensors sensors)
    $(use_enable wifi wireless)"

    myconf+="
    $(use ithreads && use_enable perl)
    $(use_with perl perl-bindings)"

    KERNEL_DIR="${KERNEL_DIR}" econf \
    --localstatedir=/var ${myconf} \
    || die "econf failed"

    emake || die "emake failed"
}

src_install()
{
    emake DESTDIR="${D}" install || die "emake install failed"

    dodoc AUTHORS ChangeLog NEWS README TODO || die "dodoc failed"

    insinto /usr/share/doc/${PF}
    doins -r contrib || die "doins contrib failed"

    keepdir /var/lib/${PN} || die "keepdir failed"

    newinitd "${FILESDIR}/${PN}-4.4.2.initd" ${PN} || die "newinitd failed"
    newconfd "${FILESDIR}/${PN}-4.4.2.confd" ${PN} || die "newconfd failed"
}

pkg_postinst()
{
    einfo
    einfo "collectd introduced some changes in the new 4.x series."
    einfo "For further information, read ${HOMEPAGE}/migrate-v3-v4.shtml"
    einfo "The migration script can be found at:"
    einfo "/usr/share/doc/${PF}/contrib/migrate-3-4.px"
    einfo
}