| 1 |
tove |
1.1 |
# Copyright 1999-2012 Gentoo Foundation
|
| 2 |
|
|
# Distributed under the terms of the GNU General Public License v2
|
| 3 |
flameeyes |
1.2 |
# $Header: /var/cvsroot/gentoo-x86/net-analyzer/net-snmp/net-snmp-5.4.3-r1.ebuild,v 1.1 2012/06/02 20:27:14 tove Exp $
|
| 4 |
tove |
1.1 |
|
| 5 |
|
|
EAPI="3"
|
| 6 |
|
|
PYTHON_DEPEND="python? 2"
|
| 7 |
|
|
|
| 8 |
|
|
inherit fixheadtails flag-o-matic perl-module python autotools
|
| 9 |
|
|
|
| 10 |
|
|
DESCRIPTION="Software for generating and retrieving SNMP data"
|
| 11 |
|
|
HOMEPAGE="http://net-snmp.sourceforge.net/"
|
| 12 |
|
|
SRC_URI="mirror://sourceforge/${PN}/${P}.tar.gz"
|
| 13 |
|
|
|
| 14 |
|
|
LICENSE="as-is BSD"
|
| 15 |
|
|
SLOT="0"
|
| 16 |
|
|
KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
|
| 17 |
|
|
IUSE="bzip2 diskio doc elf extensible ipv6 kernel_linux lm_sensors mfd-rewrites minimal perl python rpm selinux sendmail smux ssl tcpd X zlib"
|
| 18 |
|
|
|
| 19 |
|
|
COMMON="ssl? ( >=dev-libs/openssl-0.9.6d )
|
| 20 |
|
|
tcpd? ( >=sys-apps/tcp-wrappers-7.6 )
|
| 21 |
|
|
rpm? (
|
| 22 |
|
|
app-arch/rpm
|
| 23 |
|
|
dev-libs/popt
|
| 24 |
|
|
app-arch/bzip2
|
| 25 |
|
|
>=sys-libs/zlib-1.1.4
|
| 26 |
|
|
)
|
| 27 |
|
|
bzip2? ( app-arch/bzip2 )
|
| 28 |
|
|
zlib? ( >=sys-libs/zlib-1.1.4 )
|
| 29 |
|
|
elf? ( dev-libs/elfutils )
|
| 30 |
|
|
lm_sensors? (
|
| 31 |
|
|
kernel_linux? ( sys-apps/lm_sensors )
|
| 32 |
|
|
)
|
| 33 |
|
|
python? ( dev-python/setuptools )"
|
| 34 |
|
|
|
| 35 |
|
|
RDEPEND="${COMMON}
|
| 36 |
|
|
perl? (
|
| 37 |
|
|
X? ( dev-perl/perl-tk )
|
| 38 |
|
|
!minimal? ( dev-perl/TermReadKey )
|
| 39 |
|
|
)
|
| 40 |
|
|
selinux? ( sec-policy/selinux-snmp )"
|
| 41 |
|
|
|
| 42 |
|
|
# Dependency on autoconf due to bug #225893
|
| 43 |
|
|
DEPEND="${COMMON}
|
| 44 |
|
|
>=sys-devel/autoconf-2.61-r2
|
| 45 |
|
|
>=sys-apps/sed-4
|
| 46 |
|
|
doc? ( app-doc/doxygen )"
|
| 47 |
|
|
|
| 48 |
|
|
pkg_setup() {
|
| 49 |
|
|
if use python; then
|
| 50 |
|
|
python_set_active_version 2
|
| 51 |
|
|
python_pkg_setup
|
| 52 |
|
|
fi
|
| 53 |
|
|
}
|
| 54 |
|
|
|
| 55 |
|
|
src_prepare() {
|
| 56 |
|
|
# lm_sensors-3 support
|
| 57 |
|
|
if use lm_sensors ; then
|
| 58 |
|
|
epatch "${FILESDIR}"/${PN}-5.4.1-sensors3.patch \
|
| 59 |
|
|
"${FILESDIR}"/${PN}-5.4.1-sensors3-version_detect.patch
|
| 60 |
|
|
fi
|
| 61 |
|
|
|
| 62 |
|
|
# fix access violation in make check
|
| 63 |
|
|
sed -i -e 's/\(snmpd.*\)-Lf/\1-l/' testing/eval_tools.sh || \
|
| 64 |
|
|
die "sed eval_tools.sh failed"
|
| 65 |
|
|
# fix path in fixproc
|
| 66 |
|
|
sed -i -e 's|\(database_file =.*\)/local\(.*\)$|\1\2|' local/fixproc || \
|
| 67 |
|
|
die "sed fixproc failed"
|
| 68 |
|
|
|
| 69 |
|
|
if use python ; then
|
| 70 |
|
|
PYTHON_DIR="$(python_get_sitedir)"
|
| 71 |
|
|
sed -i -e "s:\(install --basedir=\$\$dir\):\1 --root='${D}':" Makefile.in || \
|
| 72 |
|
|
die "sed python failed"
|
| 73 |
|
|
fi
|
| 74 |
|
|
|
| 75 |
|
|
# snmpconf generates config files with proper selinux context
|
| 76 |
|
|
use selinux && epatch "${FILESDIR}"/${PN}-5.1.2-snmpconf-selinux.patch
|
| 77 |
|
|
|
| 78 |
|
|
# remove CFLAGS from net-snmp-config script (bug #257622):
|
| 79 |
|
|
sed -i -e 's|@CFLAGS@||g' -e 's|@LDFLAGS@||g' \
|
| 80 |
|
|
net-snmp-config.in || die "sedding CFLAGS/LDFLAGS failed"
|
| 81 |
|
|
|
| 82 |
|
|
# Respect LDFLAGS
|
| 83 |
|
|
sed -i Makefile.top \
|
| 84 |
|
|
-e '/^LIB_LD_CMD/{s|$(CFLAGS)|& $(LDFLAGS)|g}' \
|
| 85 |
|
|
|| die "sed LDFLAGS failed"
|
| 86 |
|
|
|
| 87 |
|
|
# Fix version number:
|
| 88 |
|
|
sed -i -e "s:NetSnmpVersionInfo = \".*\":NetSnmpVersionInfo = \"${PV}\":" \
|
| 89 |
|
|
snmplib/snmp_version.c || die "sedding version failed"
|
| 90 |
|
|
|
| 91 |
|
|
eautoreconf
|
| 92 |
|
|
|
| 93 |
|
|
ht_fix_all
|
| 94 |
|
|
}
|
| 95 |
|
|
|
| 96 |
|
|
src_configure() {
|
| 97 |
|
|
strip-flags
|
| 98 |
|
|
|
| 99 |
|
|
local mibs="host ucd-snmp/dlmod"
|
| 100 |
|
|
use diskio && mibs="${mibs} ucd-snmp/diskio"
|
| 101 |
|
|
use extensible && mibs="${mibs} ucd-snmp/extensible"
|
| 102 |
|
|
use lm_sensors && mibs="${mibs} ucd-snmp/lmsensorsMib"
|
| 103 |
|
|
use sendmail && mibs="${mibs} mibII/mta_sendmail"
|
| 104 |
|
|
use smux && mibs="${mibs} smux"
|
| 105 |
|
|
|
| 106 |
|
|
local myconf="$(use_enable ipv6) \
|
| 107 |
|
|
$(use_enable mfd-rewrites) \
|
| 108 |
|
|
$(use_enable perl embedded-perl) \
|
| 109 |
|
|
$(use_enable !ssl internal-md5) \
|
| 110 |
|
|
$(use_with elf) \
|
| 111 |
|
|
$(use_with perl perl-modules INSTALLDIRS=vendor ) \
|
| 112 |
|
|
$(use_with python python-modules) \
|
| 113 |
|
|
$(use_with ssl openssl) \
|
| 114 |
|
|
$(use_with tcpd libwrap)"
|
| 115 |
|
|
if use rpm ; then
|
| 116 |
|
|
myconf="${myconf} \
|
| 117 |
|
|
--with-rpm \
|
| 118 |
|
|
--with-bzip2 \
|
| 119 |
|
|
--with-zlib"
|
| 120 |
|
|
else
|
| 121 |
|
|
myconf="${myconf} \
|
| 122 |
|
|
--without-rpm \
|
| 123 |
|
|
$(use_with bzip2) \
|
| 124 |
|
|
$(use_with zlib)"
|
| 125 |
|
|
fi
|
| 126 |
|
|
|
| 127 |
|
|
econf \
|
| 128 |
|
|
--with-install-prefix="${D}" \
|
| 129 |
|
|
--with-sys-location="Unknown" \
|
| 130 |
|
|
--with-sys-contact="root@Unknown" \
|
| 131 |
|
|
--with-default-snmp-version="3" \
|
| 132 |
|
|
--with-mib-modules="${mibs}" \
|
| 133 |
|
|
--with-logfile="/var/log/net-snmpd.log" \
|
| 134 |
|
|
--with-persistent-directory="/var/lib/net-snmp" \
|
| 135 |
|
|
--enable-ucd-snmp-compatibility \
|
| 136 |
|
|
--enable-shared \
|
| 137 |
|
|
--with-ldflags="${LDFLAGS}" \
|
| 138 |
|
|
--enable-as-needed \
|
| 139 |
|
|
${myconf}
|
| 140 |
|
|
}
|
| 141 |
|
|
|
| 142 |
|
|
src_compile() {
|
| 143 |
|
|
emake -j1 OTHERLDFLAGS="${LDFLAGS}" || die "emake failed"
|
| 144 |
|
|
|
| 145 |
|
|
if use doc ; then
|
| 146 |
|
|
einfo "Building HTML Documentation"
|
| 147 |
|
|
make docsdox || die "failed to build docs"
|
| 148 |
|
|
fi
|
| 149 |
|
|
}
|
| 150 |
|
|
|
| 151 |
|
|
src_test() {
|
| 152 |
|
|
cd testing
|
| 153 |
|
|
if ! make test ; then
|
| 154 |
|
|
echo
|
| 155 |
|
|
einfo "Don't be alarmed if a few tests FAIL."
|
| 156 |
|
|
einfo "This could happen for several reasons:"
|
| 157 |
|
|
einfo " - You don't already have a working configuration."
|
| 158 |
|
|
einfo " - Your ethernet interface isn't properly configured."
|
| 159 |
|
|
echo
|
| 160 |
|
|
fi
|
| 161 |
|
|
}
|
| 162 |
|
|
|
| 163 |
|
|
src_install () {
|
| 164 |
|
|
# bug #317965
|
| 165 |
|
|
emake -j1 DESTDIR="${D}" install || die "make install failed"
|
| 166 |
|
|
|
| 167 |
|
|
if use perl ; then
|
| 168 |
|
|
fixlocalpod
|
| 169 |
|
|
use X || rm -f "${D}"/usr/bin/tkmib
|
| 170 |
|
|
else
|
| 171 |
|
|
rm -f "${D}"/usr/bin/mib2c "${D}"/usr/bin/snmpcheck "${D}"/usr/bin/tkmib
|
| 172 |
|
|
fi
|
| 173 |
|
|
|
| 174 |
|
|
dodoc AGENT.txt ChangeLog FAQ INSTALL NEWS PORTING README* TODO || die
|
| 175 |
|
|
newdoc EXAMPLE.conf.def EXAMPLE.conf || die
|
| 176 |
|
|
|
| 177 |
|
|
use doc && { dohtml docs/html/* || die ; }
|
| 178 |
|
|
|
| 179 |
|
|
keepdir /etc/snmp /var/lib/net-snmp
|
| 180 |
|
|
|
| 181 |
|
|
newinitd "${FILESDIR}"/snmpd.init snmpd || die
|
| 182 |
|
|
newconfd "${FILESDIR}"/snmpd.conf snmpd || die
|
| 183 |
|
|
|
| 184 |
|
|
newinitd "${FILESDIR}"/snmptrapd.init snmptrapd || die
|
| 185 |
|
|
newconfd "${FILESDIR}"/snmptrapd.conf snmptrapd || die
|
| 186 |
|
|
|
| 187 |
|
|
# Remove everything not required for an agent.
|
| 188 |
|
|
# Keep only the snmpd, snmptrapd, MIBs, headers and libraries.
|
| 189 |
|
|
if use minimal; then
|
| 190 |
|
|
elog "USE='minimal' is set. Removing excess/non-minimal components."
|
| 191 |
|
|
rm -rf
|
| 192 |
|
|
"${D}"/usr/bin/{encode_keychange,snmp{get,getnext,set,usm,walk,bulkwalk,table,trap,bulkget,translate,status,delta,test,df,vacm,netstat,inform,snmpcheck}}
|
| 193 |
|
|
rm -rf "${D}"/usr/share/snmp/snmpconf-data "${D}"/usr/share/snmp/*.conf
|
| 194 |
|
|
rm -rf "${D}"/usr/bin/{fixproc,traptoemail} "${D}"/usr/bin/snmpc{heck,onf}
|
| 195 |
|
|
find "${D}" -name '*.pl' -exec rm -f '{}' \;
|
| 196 |
|
|
use ipv6 || rm -rf "${D}"/usr/share/snmp/mibs/IPV6*
|
| 197 |
|
|
fi
|
| 198 |
|
|
|
| 199 |
|
|
# bug 113788, install example config
|
| 200 |
|
|
insinto /etc/snmp
|
| 201 |
|
|
newins "${S}"/EXAMPLE.conf snmpd.conf.example || die
|
| 202 |
|
|
}
|
| 203 |
|
|
|
| 204 |
|
|
pkg_postinst() {
|
| 205 |
|
|
if use python; then
|
| 206 |
|
|
python_mod_optimize netsnmp
|
| 207 |
|
|
fi
|
| 208 |
|
|
|
| 209 |
|
|
elog "An example configuration file has been installed in"
|
| 210 |
|
|
elog "/etc/snmp/snmpd.conf.example."
|
| 211 |
|
|
}
|
| 212 |
|
|
|
| 213 |
|
|
pkg_postrm() {
|
| 214 |
|
|
if use python; then
|
| 215 |
|
|
python_mod_cleanup netsnmp
|
| 216 |
|
|
fi
|
| 217 |
|
|
}
|