1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
5 PYTHON_COMPAT=( python3_{6,7,8} )
6 DISTUTILS_SINGLE_IMPL=yesplz
7 DISTUTILS_OPTIONAL=yesplz
10 GENTOO_DEPEND_ON_PERL=no
12 inherit autotools distutils-r1 git-r3 perl-module systemd
14 DESCRIPTION="Software for generating and retrieving SNMP data"
15 HOMEPAGE="http://www.net-snmp.org/"
16 EGIT_REPO_URI="https://github.com/net-snmp/net-snmp"
18 https://dev.gentoo.org/~jer/${PN}-5.7.3-patches-3.tar.xz
21 # GPL-2 for the init scripts
22 LICENSE="HPND BSD GPL-2"
26 X bzip2 doc elf kmem ipv6 libressl lm-sensors mfd-rewrites minimal mysql
27 netlink pcap pci perl python rpm selinux smux ssl tcpd ucd-compat zlib
30 python? ( ${PYTHON_REQUIRED_USE} )
35 bzip2? ( app-arch/bzip2 )
36 elf? ( dev-libs/elfutils )
37 lm-sensors? ( sys-apps/lm-sensors )
38 mysql? ( dev-db/mysql-connector-c:0= )
39 netlink? ( dev-libs/libnl:3 )
40 pcap? ( net-libs/libpcap )
41 pci? ( sys-apps/pciutils )
42 perl? ( dev-lang/perl:= )
44 $(python_gen_cond_dep '
45 dev-python/setuptools[${PYTHON_MULTI_USEDEP}]
54 !libressl? ( >=dev-libs/openssl-0.9.6d:0= )
55 libressl? ( dev-libs/libressl:= )
57 tcpd? ( >=sys-apps/tcp-wrappers-7.6 )
58 zlib? ( >=sys-libs/zlib-1.1.4 )
62 doc? ( app-doc/doxygen )
68 !minimal? ( dev-perl/TermReadKey )
70 selinux? ( sec-policy/selinux-snmp )
73 S=${WORKDIR}/${P/_p*/}
76 "${FILESDIR}"/${PN}-5.7.3-include-limits.patch
77 "${FILESDIR}"/${PN}-5.8-do-not-conflate-LDFLAGS-and-LIBS.patch
78 "${FILESDIR}"/${PN}-5.8-pcap.patch
79 "${FILESDIR}"/${PN}-5.8.1-pkg-config.patch
80 "${FILESDIR}"/${PN}-99999999-tinfo.patch
84 use python && python-single-r1_pkg_setup
93 # snmpconf generates config files with proper selinux context
94 use selinux && eapply "${FILESDIR}"/${PN}-5.1.2-snmpconf-selinux.patch
96 mv "${WORKDIR}"/patches/0002-Respect-DESTDIR-for-pythoninstall.patch{,.disabled} || die
97 mv "${WORKDIR}"/patches/0004-Don-t-report-CFLAGS-and-LDFLAGS-in-net-snmp-config.patch{,.disabled} || die
98 eapply "${WORKDIR}"/patches/*.patch
106 # keep this in the same line, configure.ac arguments are passed down to config.h
107 local mibs="host ucd-snmp/dlmod ucd-snmp/diskio ucd-snmp/extensible mibII/mta_sendmail etherlike-mib/dot3StatsTable"
108 use lm-sensors && mibs="${mibs} ucd-snmp/lmsensorsMib"
109 use smux && mibs="${mibs} smux"
111 # Assume /etc/mtab is not present with a recent baselayout/openrc (bug #565136)
112 use kernel_linux && export ac_cv_ETC_MNTTAB=/etc/mtab
115 $(use_enable !ssl internal-md5) \
117 $(use_enable mfd-rewrites) \
118 $(use_enable perl embedded-perl) \
119 $(use_enable ucd-compat ucd-snmp-compatibility) \
122 $(use_with kmem kmem-usage) \
124 $(use_with netlink nl) \
127 $(use_with perl perl-modules INSTALLDIRS=vendor) \
128 $(use_with python python-modules) \
130 $(use_with ssl openssl) \
131 $(use_with tcpd libwrap) \
133 --enable-shared --disable-static \
134 --with-default-snmp-version="3" \
135 --with-install-prefix="${D}" \
136 --with-ldflags="${LDFLAGS}" \
137 --with-logfile="/var/log/net-snmpd.log" \
138 --with-mib-modules="${mibs}" \
139 --with-persistent-directory="/var/lib/net-snmp" \
140 --with-sys-contact="root@Unknown" \
141 --with-sys-location="Unknown"
145 for target in snmplib agent sedscript all; do
146 emake OTHERLDFLAGS="${LDFLAGS}" ${target}
149 use doc && emake docsdox
154 emake -j1 DESTDIR="${D}" install
156 use python && python_optimize
161 rm "${D}"/usr/bin/tkmib || die
165 "${D}"/usr/bin/fixproc \
166 "${D}"/usr/bin/ipf-mod.pl \
167 "${D}"/usr/bin/mib2c \
168 "${D}"/usr/bin/net-snmp-cert \
169 "${D}"/usr/bin/snmp-bridge-mib \
170 "${D}"/usr/bin/snmpcheck \
171 "${D}"/usr/bin/snmpconf \
172 "${D}"/usr/bin/tkmib \
173 "${D}"/usr/bin/traptoemail \
174 "${D}"/usr/share/snmp/mib2c.perl.conf \
175 "${D}"/usr/share/snmp/snmp_perl_trapd.pl \
179 dodoc AGENT.txt ChangeLog FAQ INSTALL NEWS PORTING README* TODO
180 newdoc EXAMPLE.conf.def EXAMPLE.conf
187 keepdir /var/lib/net-snmp
189 newinitd "${FILESDIR}"/snmpd.init.2 snmpd
190 newconfd "${FILESDIR}"/snmpd.conf snmpd
192 newinitd "${FILESDIR}"/snmptrapd.init.2 snmptrapd
193 newconfd "${FILESDIR}"/snmptrapd.conf snmptrapd
195 systemd_dounit "${FILESDIR}"/snmpd.service
196 systemd_dounit "${FILESDIR}"/snmptrapd.service
199 newins "${S}"/EXAMPLE.conf snmpd.conf.example
201 # Remove everything not required for an agent.
202 # Keep only the snmpd, snmptrapd, MIBs, headers and libraries.
206 "${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} \
207 "${D}"/usr/share/snmp/*.conf \
208 "${D}"/usr/share/snmp/snmpconf-data \
212 find "${ED}" -name '*.la' -delete || die