1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
5 PYTHON_COMPAT=( python2_7 )
6 DISTUTILS_SINGLE_IMPL=yesplz
7 DISTUTILS_OPTIONAL=yesplz
10 GENTOO_DEPEND_ON_PERL=no
12 inherit autotools distutils-r1 perl-module systemd
14 DESCRIPTION="Software for generating and retrieving SNMP data"
15 HOMEPAGE="http://www.net-snmp.org/"
17 mirror://sourceforge/project/${PN}/${PN}/${PV/_p*/}-pre-releases/${P/_pre/.pre}.tar.gz
18 https://dev.gentoo.org/~jer/${PN}-5.7.3-patches-3.tar.xz
23 # GPL-2 for the init scripts
24 LICENSE="HPND BSD GPL-2"
26 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86"
28 X bzip2 doc elf kmem ipv6 libressl lm-sensors mfd-rewrites minimal mysql
29 netlink pcap pci perl python rpm selinux smux ssl tcpd ucd-compat zlib
32 python? ( ${PYTHON_REQUIRED_USE} )
37 bzip2? ( app-arch/bzip2 )
38 elf? ( dev-libs/elfutils )
39 lm-sensors? ( sys-apps/lm-sensors )
40 mysql? ( dev-db/mysql-connector-c:0= )
41 netlink? ( dev-libs/libnl:3 )
42 pcap? ( net-libs/libpcap )
43 pci? ( sys-apps/pciutils )
44 perl? ( dev-lang/perl:= )
46 $(python_gen_cond_dep '
47 dev-python/setuptools[${PYTHON_MULTI_USEDEP}]
56 !libressl? ( >=dev-libs/openssl-0.9.6d:0= )
57 libressl? ( dev-libs/libressl:= )
59 tcpd? ( >=sys-apps/tcp-wrappers-7.6 )
60 zlib? ( >=sys-libs/zlib-1.1.4 )
64 doc? ( app-doc/doxygen )
70 !minimal? ( dev-perl/TermReadKey )
72 selinux? ( sec-policy/selinux-snmp )
74 S=${WORKDIR}/${P/_pre/.pre}
77 "${FILESDIR}"/${PN}-5.7.3-include-limits.patch
78 "${FILESDIR}"/${PN}-5.8-do-not-conflate-LDFLAGS-and-LIBS.patch
79 "${FILESDIR}"/${PN}-5.8-pcap.patch
80 "${FILESDIR}"/${PN}-5.8-tinfo.patch
81 "${FILESDIR}"/${PN}-5.8.1-pkg-config.patch
85 use python && python-single-r1_pkg_setup
89 # snmpconf generates config files with proper selinux context
90 use selinux && eapply "${FILESDIR}"/${PN}-5.1.2-snmpconf-selinux.patch
92 mv "${WORKDIR}"/patches/0002-Respect-DESTDIR-for-pythoninstall.patch{,.disabled} || die
93 mv "${WORKDIR}"/patches/0004-Don-t-report-CFLAGS-and-LDFLAGS-in-net-snmp-config.patch{,.disabled} || die
94 eapply "${WORKDIR}"/patches/*.patch
102 # keep this in the same line, configure.ac arguments are passed down to config.h
103 local mibs="host ucd-snmp/dlmod ucd-snmp/diskio ucd-snmp/extensible mibII/mta_sendmail etherlike-mib/dot3StatsTable"
104 use lm-sensors && mibs="${mibs} ucd-snmp/lmsensorsMib"
105 use smux && mibs="${mibs} smux"
107 # Assume /etc/mtab is not present with a recent baselayout/openrc (bug #565136)
108 use kernel_linux && export ac_cv_ETC_MNTTAB=/etc/mtab
111 $(use_enable !ssl internal-md5) \
113 $(use_enable mfd-rewrites) \
114 $(use_enable perl embedded-perl) \
115 $(use_enable ucd-compat ucd-snmp-compatibility) \
118 $(use_with kmem kmem-usage) \
120 $(use_with netlink nl) \
123 $(use_with perl perl-modules INSTALLDIRS=vendor) \
124 $(use_with python python-modules) \
126 $(use_with ssl openssl) \
127 $(use_with tcpd libwrap) \
129 --enable-shared --disable-static \
130 --with-default-snmp-version="3" \
131 --with-install-prefix="${D}" \
132 --with-ldflags="${LDFLAGS}" \
133 --with-logfile="/var/log/net-snmpd.log" \
134 --with-mib-modules="${mibs}" \
135 --with-persistent-directory="/var/lib/net-snmp" \
136 --with-sys-contact="root@Unknown" \
137 --with-sys-location="Unknown"
141 for target in snmplib agent sedscript all; do
142 emake OTHERLDFLAGS="${LDFLAGS}" ${target}
145 use doc && emake docsdox
150 emake -j1 DESTDIR="${D}" install
152 use python && python_optimize
157 rm "${D}"/usr/bin/tkmib || die
161 "${D}"/usr/bin/fixproc \
162 "${D}"/usr/bin/ipf-mod.pl \
163 "${D}"/usr/bin/mib2c \
164 "${D}"/usr/bin/net-snmp-cert \
165 "${D}"/usr/bin/snmp-bridge-mib \
166 "${D}"/usr/bin/snmpcheck \
167 "${D}"/usr/bin/snmpconf \
168 "${D}"/usr/bin/tkmib \
169 "${D}"/usr/bin/traptoemail \
170 "${D}"/usr/share/snmp/mib2c.perl.conf \
171 "${D}"/usr/share/snmp/snmp_perl_trapd.pl \
175 dodoc AGENT.txt ChangeLog FAQ INSTALL NEWS PORTING README* TODO
176 newdoc EXAMPLE.conf.def EXAMPLE.conf
183 keepdir /var/lib/net-snmp
185 newinitd "${FILESDIR}"/snmpd.init.2 snmpd
186 newconfd "${FILESDIR}"/snmpd.conf snmpd
188 newinitd "${FILESDIR}"/snmptrapd.init.2 snmptrapd
189 newconfd "${FILESDIR}"/snmptrapd.conf snmptrapd
191 systemd_dounit "${FILESDIR}"/snmpd.service
192 systemd_dounit "${FILESDIR}"/snmptrapd.service
195 newins "${S}"/EXAMPLE.conf snmpd.conf.example
197 # Remove everything not required for an agent.
198 # Keep only the snmpd, snmptrapd, MIBs, headers and libraries.
202 "${D}"/usr/bin/{encode_keychange,snmp{get,getnext,set,usm,walk,bulkwalk,table,trap,bulkget,translate,status,delta,test,df,vacm,netstat,inform,check,conf},fixproc,traptoemail} \
203 "${D}"/usr/share/snmp/*.conf \
204 "${D}"/usr/share/snmp/snmpconf-data \
208 find "${ED}" -name '*.la' -delete || die