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 eutils ltprune 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*/}/${P/_p*/}.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"
27 IUSE="X bzip2 doc elf kmem ipv6 libressl lm-sensors mfd-rewrites minimal mysql netlink pci perl python rpm selinux smux ssl tcpd ucd-compat zlib"
31 !libressl? ( >=dev-libs/openssl-0.9.6d:0= )
32 libressl? ( dev-libs/libressl:= )
34 tcpd? ( >=sys-apps/tcp-wrappers-7.6 )
39 bzip2? ( app-arch/bzip2 )
40 zlib? ( >=sys-libs/zlib-1.1.4 )
41 elf? ( dev-libs/elfutils )
43 $(python_gen_cond_dep '
44 dev-python/setuptools[${PYTHON_MULTI_USEDEP}]
48 pci? ( sys-apps/pciutils )
49 lm-sensors? ( sys-apps/lm-sensors )
50 netlink? ( dev-libs/libnl:3 )
51 mysql? ( dev-db/mysql-connector-c:0= )
52 perl? ( dev-lang/perl:= )
56 doc? ( app-doc/doxygen )
62 !minimal? ( dev-perl/TermReadKey )
64 selinux? ( sec-policy/selinux-snmp )
68 python? ( ${PYTHON_REQUIRED_USE} )
71 S=${WORKDIR}/${P/_p*/}
76 use python && python-single-r1_pkg_setup
80 # snmpconf generates config files with proper selinux context
81 use selinux && eapply "${FILESDIR}"/${PN}-5.1.2-snmpconf-selinux.patch
83 eapply "${FILESDIR}"/${PN}-5.7.3-include-limits.patch
84 eapply "${FILESDIR}"/${PN}-5.8-tinfo.patch
86 mv "${WORKDIR}"/patches/0002-Respect-DESTDIR-for-pythoninstall.patch{,.disabled} || die
87 mv "${WORKDIR}"/patches/0004-Don-t-report-CFLAGS-and-LDFLAGS-in-net-snmp-config.patch{,.disabled} || die
88 eapply "${WORKDIR}"/patches/*.patch
96 # keep this in the same line, configure.ac arguments are passed down to config.h
97 local mibs="host ucd-snmp/dlmod ucd-snmp/diskio ucd-snmp/extensible mibII/mta_sendmail etherlike-mib/dot3StatsTable"
98 use lm-sensors && mibs="${mibs} ucd-snmp/lmsensorsMib"
99 use smux && mibs="${mibs} smux"
101 # Assume /etc/mtab is not present with a recent baselayout/openrc (bug #565136)
102 use kernel_linux && export ac_cv_ETC_MNTTAB=/etc/mtab
105 $(use_enable !ssl internal-md5) \
107 $(use_enable mfd-rewrites) \
108 $(use_enable perl embedded-perl) \
109 $(use_enable ucd-compat ucd-snmp-compatibility) \
112 $(use_with kmem kmem-usage) \
114 $(use_with netlink nl) \
116 $(use_with perl perl-modules INSTALLDIRS=vendor) \
117 $(use_with python python-modules) \
119 $(use_with ssl openssl) \
120 $(use_with tcpd libwrap) \
122 --enable-shared --disable-static \
123 --with-default-snmp-version="3" \
124 --with-install-prefix="${D}" \
125 --with-ldflags="${LDFLAGS}" \
126 --with-logfile="/var/log/net-snmpd.log" \
127 --with-mib-modules="${mibs}" \
128 --with-persistent-directory="/var/lib/net-snmp" \
129 --with-sys-contact="root@Unknown" \
130 --with-sys-location="Unknown"
134 for target in snmplib agent sedscript all; do
135 emake OTHERLDFLAGS="${LDFLAGS}" ${target}
138 use doc && emake docsdox
143 emake -j1 DESTDIR="${D}" install
148 rm "${D}"/usr/bin/tkmib || die
152 "${D}"/usr/bin/fixproc \
153 "${D}"/usr/bin/ipf-mod.pl \
154 "${D}"/usr/bin/mib2c \
155 "${D}"/usr/bin/net-snmp-cert \
156 "${D}"/usr/bin/snmp-bridge-mib \
157 "${D}"/usr/bin/snmpcheck \
158 "${D}"/usr/bin/snmpconf \
159 "${D}"/usr/bin/tkmib \
160 "${D}"/usr/bin/traptoemail \
161 "${D}"/usr/share/snmp/mib2c.perl.conf \
162 "${D}"/usr/share/snmp/snmp_perl_trapd.pl \
166 dodoc AGENT.txt ChangeLog FAQ INSTALL NEWS PORTING README* TODO
167 newdoc EXAMPLE.conf.def EXAMPLE.conf
174 keepdir /var/lib/net-snmp
176 newinitd "${FILESDIR}"/snmpd.init.2 snmpd
177 newconfd "${FILESDIR}"/snmpd.conf snmpd
179 newinitd "${FILESDIR}"/snmptrapd.init.2 snmptrapd
180 newconfd "${FILESDIR}"/snmptrapd.conf snmptrapd
182 systemd_dounit "${FILESDIR}"/snmpd.service
183 systemd_dounit "${FILESDIR}"/snmptrapd.service
186 newins "${S}"/EXAMPLE.conf snmpd.conf.example
188 # Remove everything not required for an agent.
189 # Keep only the snmpd, snmptrapd, MIBs, headers and libraries.
193 "${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} \
194 "${D}"/usr/share/snmp/*.conf \
195 "${D}"/usr/share/snmp/snmpconf-data \