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