--- net-snmp-5.4.2.1-r1.ebuild +++ net-snmp-5.4.2.1-r2.ebuild @@ -1,6 +1,8 @@ # Copyright 1999-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/net-analyzer/net-snmp/net-snmp-5.4.2.1-r1.ebuild,v 1.6 2009/07/19 16:38:51 nixnut Exp $ +# $Header: $ + +EAPI=2 inherit fixheadtails flag-o-matic perl-module python autotools @@ -10,10 +12,10 @@ LICENSE="as-is BSD" SLOT="0" -KEYWORDS="alpha ~amd64 arm hppa ia64 ~mips ppc ~ppc64 s390 sh sparc x86" -IUSE="diskio doc elf ipv6 lm_sensors mfd-rewrites minimal perl python rpm selinux smux ssl tcpd X sendmail extensible" +KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86" +IUSE="bzip2 diskio doc elf extensible ipv6 kernel_linux lm_sensors mfd-rewrites minimal perl python rpm selinux sendmail smux ssl tcpd X zlib" -DEPEND="ssl? ( >=dev-libs/openssl-0.9.6d ) +COMMON="ssl? ( >=dev-libs/openssl-0.9.6d ) tcpd? ( >=sys-apps/tcp-wrappers-7.6 ) rpm? ( app-arch/rpm @@ -21,11 +23,15 @@ app-arch/bzip2 >=sys-libs/zlib-1.1.4 ) + bzip2? ( app-arch/bzip2 ) + zlib? ( >=sys-libs/zlib-1.1.4 ) elf? ( dev-libs/elfutils ) - lm_sensors? ( =sys-apps/lm_sensors-2* ) + lm_sensors? ( + kernel_linux? ( sys-apps/lm_sensors ) + ) python? ( dev-python/setuptools )" -RDEPEND="${DEPEND} +RDEPEND="${COMMON} perl? ( X? ( dev-perl/perl-tk ) !minimal? ( dev-perl/TermReadKey ) @@ -33,17 +39,20 @@ selinux? ( sec-policy/selinux-snmpd )" # Dependency on autoconf due to bug #225893 -DEPEND="${DEPEND} +DEPEND="${COMMON} >=sys-devel/autoconf-2.61-r2 >=sys-apps/sed-4 doc? ( app-doc/doxygen )" -src_unpack() { - unpack ${A} - cd "${S}" - +src_prepare() { # Fix CVE-2008-6123 - epatch "${FILESDIR}/CVE-2008-6123.patch" + epatch "${FILESDIR}"/CVE-2008-6123.patch + + # lm_sensors-3 support + if use lm_sensors ; then + epatch "${FILESDIR}"/${PN}-5.4.1-sensors3.patch \ + "${FILESDIR}"/${PN}-5.4.1-sensors3-version_detect.patch + fi # fix access violation in make check sed -i -e 's/\(snmpd.*\)-Lf/\1-l/' testing/eval_tools.sh || \ @@ -55,8 +64,9 @@ if use python ; then python_version PYTHON_MODNAME="netsnmp" - PYTHON_DIR=/usr/$(get_libdir)/python${PYVER}/site-packages - sed -i -e "s:\(install --basedir=\$\$dir\):\1 --root='${D}':" Makefile.in || die "sed python failed" + PYTHON_DIR="/usr/$(get_libdir)/python${PYVER}/site-packages" + sed -i -e "s:\(install --basedir=\$\$dir\):\1 --root='${D}':" Makefile.in || \ + die "sed python failed" fi # snmpconf generates config files with proper selinux context @@ -70,17 +80,35 @@ ht_fix_all } -src_compile() { - local mibs - +src_configure() { strip-flags - mibs="host ucd-snmp/dlmod" - use smux && mibs="${mibs} smux" - use sendmail && mibs="${mibs} mibII/mta_sendmail" - use lm_sensors && mibs="${mibs} ucd-snmp/lmSensors" + local mibs="host ucd-snmp/dlmod" use diskio && mibs="${mibs} ucd-snmp/diskio" use extensible && mibs="${mibs} ucd-snmp/extensible" + use lm_sensors && mibs="${mibs} ucd-snmp/lmsensorsMib" + use sendmail && mibs="${mibs} mibII/mta_sendmail" + use smux && mibs="${mibs} smux" + + local myconf="$(use_enable ipv6) \ + $(use_enable mfd-rewrites) \ + $(use_enable perl embedded-perl) \ + $(use_enable !ssl internal-md5) \ + $(use_with elf) \ + $(use_with perl perl-modules) \ + $(use_with python python-modules) \ + $(use_with ssl openssl) \ + $(use_with tcpd libwrap)" + if use rpm ; then + myconf="${myconf} \ + --with-rpm \ + --with-bzip2 \ + --with-zlib" + else + myconf="${myconf} \ + $(use_with bzip2) \ + $(use_with zlib)" + fi econf \ --with-install-prefix="${D}" \ @@ -93,29 +121,12 @@ --enable-ucd-snmp-compatibility \ --enable-shared \ --enable-as-needed \ - $(use_enable mfd-rewrites) \ - $(use_enable perl embedded-perl) \ - $(use_enable ipv6) \ - $(use_enable !ssl internal-md5) \ - $(use_with ssl openssl) \ - $(use_with tcpd libwrap) \ - $(use_with rpm) \ - $(use_with rpm bzip2) \ - $(use_with rpm zlib) \ - $(use_with elf) \ - $(use_with python python-modules) \ - || die "econf failed" + ${myconf} +} +src_compile() { emake -j1 || die "emake failed" - if use perl ; then - emake perlmodules || die "compile perl modules problem" - fi - - if use python ; then - emake pythonmodules || die "compile python modules problem" - fi - if use doc ; then einfo "Building HTML Documentation" make docsdox || die "failed to build docs" @@ -138,35 +149,29 @@ make DESTDIR="${D}" install || die "make install failed" if use perl ; then - make DESTDIR="${D}" perlinstall || die "make perlinstall failed" fixlocalpod - - use X || rm -f "${D}/usr/bin/tkmib" + use X || rm -f "${D}"/usr/bin/tkmib else - rm -f "${D}/usr/bin/mib2c" "${D}/usr/bin/tkmib" "${D}/usr/bin/snmpcheck" + rm -f "${D}"/usr/bin/mib2c "${D}"/usr/bin/snmpcheck "${D}"/usr/bin/tkmib fi - if use python ; then - mkdir -p "${D}/${PYTHON_DIR}" || die "Couldn't make $PYTHON_DIR" - make pythoninstall || die "make pythoninstall failed" - fi + dodoc AGENT.txt ChangeLog FAQ INSTALL NEWS PORTING README* TODO || die + newdoc EXAMPLE.conf.def EXAMPLE.conf || die - dodoc AGENT.txt ChangeLog FAQ INSTALL NEWS PORTING README* TODO - newdoc EXAMPLE.conf.def EXAMPLE.conf - - use doc && dohtml docs/html/* + use doc && { dohtml docs/html/* || die ; } keepdir /etc/snmp /var/lib/net-snmp - newinitd "${FILESDIR}"/snmpd.rc7 snmpd - newconfd "${FILESDIR}"/snmpd.conf snmpd + newinitd "${FILESDIR}"/snmpd.init snmpd || die + newconfd "${FILESDIR}"/snmpd.conf snmpd || die - newinitd "${FILESDIR}"/snmptrapd.rc7 snmptrapd - newconfd "${FILESDIR}"/snmptrapd.conf snmptrapd + newinitd "${FILESDIR}"/snmptrapd.init snmptrapd || die + newconfd "${FILESDIR}"/snmptrapd.conf snmptrapd || die - # Remove everything, keeping only the snmpd, snmptrapd, MIBs, libs, and includes. + # Remove everything not required for an agent. + # Keep only the snmpd, snmptrapd, MIBs, headers and libraries. if use minimal; then - elog "USE=minimal is set. Cleaning up excess cruft for a embedded/minimal/server only install." + elog "USE='minimal' is set. Removing excess/non-minimal components." rm -rf "${D}"/usr/bin/{encode_keychange,snmp{get,getnext,set,usm,walk,bulkwalk,table,trap,bulkget,translate,status,delta,test,df,vacm,netstat,inform,snmpcheck}} rm -rf "${D}"/usr/share/snmp/snmpconf-data "${D}"/usr/share/snmp/*.conf @@ -177,13 +182,11 @@ # bug 113788, install example config insinto /etc/snmp - newins "${S}"/EXAMPLE.conf snmpd.conf.example + newins "${S}"/EXAMPLE.conf snmpd.conf.example || die } pkg_postrm() { - if use python ; then - python_mod_cleanup - fi + use python && python_mod_cleanup } pkg_postinst() { --- files/snmpd.rc7 +++ files/snmpd.init @@ -1,30 +1,47 @@ #!/sbin/runscript -# Copyright 1999-2004 Gentoo Foundation +# Copyright 1999-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/net-analyzer/net-snmp/files/snmpd.rc7,v 1.1 2006/11/26 21:37:22 cedk Exp $ +# $Header: $ + +opts="${opts} reload" depend() { use logger need net } +SNMPD_PIDFILE="${SNMPD_PIDFILE:-/var/run/snmpd.pid}" + checkconfig() { if [ ! -e /etc/snmp/snmpd.conf ] ; then - eerror "You need an /etc/snmp/snmpd.conf config file to run snmpd" + eerror "${SVCNAME} requires an /etc/snmp/snmpd.conf configuration file" return 1 fi } start() { checkconfig || return 1 - ebegin "Starting net-snmpd" + ebegin "Starting ${SVCNAME}" start-stop-daemon --start --quiet --exec /usr/sbin/snmpd \ - -- -p /var/run/snmpd.pid ${SNMPD_FLAGS} + -- -p ${SNMPD_PIDFILE} ${SNMPD_FLAGS} eend $? } stop() { - ebegin "Stopping net-snmpd" - start-stop-daemon --stop --quiet --pidfile /var/run/snmpd.pid + ebegin "Stopping ${SVCNAME}" + start-stop-daemon --stop --quiet --pidfile ${SNMPD_PIDFILE} + eend $? +} + +reload() { + checkconfig || return 1 + if [ ! -f ${SNMPD_PIDFILE} ]; then + eerror "Cannot reload configuration, ${SVCNAME} is not running" + eend 1 + return 1 + fi + + ebegin "Reloading ${SVCNAME} configuration" + kill -HUP $(< ${SNMPD_PIDFILE}) &>/dev/null eend $? } --- files/snmptrapd.rc7 +++ files/snmptrapd.init @@ -1,22 +1,24 @@ #!/sbin/runscript -# Copyright 1999-2004 Gentoo Foundation +# Copyright 1999-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/net-analyzer/net-snmp/files/snmptrapd.rc7,v 1.1 2006/11/26 21:37:22 cedk Exp $ +# $Header: $ depend() { use logger need net } +SNMPTRAPD_PIDFILE="${SNMPTRAPD_PIDFILE:-/var/run/snmptrapd.pid}" + start() { - ebegin "Starting snmptrapd" + ebegin "Starting ${SVCNAME}" start-stop-daemon --start --quiet --exec /usr/sbin/snmptrapd \ - -- -p /var/run/snmptrapd.pid ${SNMPTRAPD_FLAGS} + -- -p ${SNMPTRAPD_PIDFILE} ${SNMPTRAPD_FLAGS} eend $? } stop() { - ebegin "Stopping snmptrapd" - start-stop-daemon --stop --quiet --pidfile /var/run/snmptrapd.pid + ebegin "Stopping ${SVCNAME}" + start-stop-daemon --stop --quiet --pidfile ${SNMPTRAPD_PIDFILE} eend $? }