net-analyzer/zabbix: removed obsolete 4.0.18 and 4.4.6
[gentoo.git] / net-analyzer / net-snmp / net-snmp-5.8-r3.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5 PYTHON_COMPAT=( python2_7 )
6 DISTUTILS_SINGLE_IMPL=yesplz
7 DISTUTILS_OPTIONAL=yesplz
8 WANT_AUTOMAKE=none
9 PATCHSET=3
10 GENTOO_DEPEND_ON_PERL=no
11
12 inherit autotools distutils-r1 eutils ltprune perl-module systemd
13
14 DESCRIPTION="Software for generating and retrieving SNMP data"
15 HOMEPAGE="http://www.net-snmp.org/"
16 SRC_URI="
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
19 "
20
21 S=${WORKDIR}/${P/_/.}
22
23 # GPL-2 for the init scripts
24 LICENSE="HPND BSD GPL-2"
25 SLOT="0/35"
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"
28
29 COMMON_DEPEND="
30         ssl? (
31                 !libressl? ( >=dev-libs/openssl-0.9.6d:0= )
32                 libressl? ( dev-libs/libressl:= )
33         )
34         tcpd? ( >=sys-apps/tcp-wrappers-7.6 )
35         rpm? (
36                 app-arch/rpm
37                 dev-libs/popt
38         )
39         bzip2? ( app-arch/bzip2 )
40         zlib? ( >=sys-libs/zlib-1.1.4 )
41         elf? ( dev-libs/elfutils )
42         python? (
43                 $(python_gen_cond_dep '
44                         dev-python/setuptools[${PYTHON_MULTI_USEDEP}]
45                 ')
46                 ${PYTHON_DEPS}
47         )
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:= )
53 "
54 DEPEND="
55         ${COMMON_DEPEND}
56         doc? ( app-doc/doxygen )
57 "
58 RDEPEND="
59         ${COMMON_DEPEND}
60         perl? (
61                 X? ( dev-perl/Tk )
62                 !minimal? ( dev-perl/TermReadKey )
63         )
64         selinux? ( sec-policy/selinux-snmp )
65 "
66
67 REQUIRED_USE="
68         python? ( ${PYTHON_REQUIRED_USE} )
69         rpm? ( bzip2 zlib )
70 "
71 S=${WORKDIR}/${P/_p*/}
72
73 RESTRICT=test
74
75 pkg_setup() {
76         use python && python-single-r1_pkg_setup
77 }
78
79 src_prepare() {
80         # snmpconf generates config files with proper selinux context
81         use selinux && eapply "${FILESDIR}"/${PN}-5.1.2-snmpconf-selinux.patch
82
83         eapply "${FILESDIR}"/${PN}-5.7.3-include-limits.patch
84         eapply "${FILESDIR}"/${PN}-5.8-tinfo.patch
85
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
89
90         eapply_user
91
92         eautoconf
93 }
94
95 src_configure() {
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"
100
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
103
104         econf \
105                 $(use_enable !ssl internal-md5) \
106                 $(use_enable ipv6) \
107                 $(use_enable mfd-rewrites) \
108                 $(use_enable perl embedded-perl) \
109                 $(use_enable ucd-compat ucd-snmp-compatibility) \
110                 $(use_with bzip2) \
111                 $(use_with elf) \
112                 $(use_with kmem kmem-usage) \
113                 $(use_with mysql) \
114                 $(use_with netlink nl) \
115                 $(use_with pci) \
116                 $(use_with perl perl-modules INSTALLDIRS=vendor) \
117                 $(use_with python python-modules) \
118                 $(use_with rpm) \
119                 $(use_with ssl openssl) \
120                 $(use_with tcpd libwrap) \
121                 $(use_with zlib) \
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"
131 }
132
133 src_compile() {
134         for target in snmplib agent sedscript all; do
135                 emake OTHERLDFLAGS="${LDFLAGS}" ${target}
136         done
137
138         use doc && emake docsdox
139 }
140
141 src_install() {
142         # bug #317965
143         emake -j1 DESTDIR="${D}" install
144
145         if use perl ; then
146                 perl_delete_localpod
147                 if ! use X; then
148                         rm "${D}"/usr/bin/tkmib || die
149                 fi
150         else
151                 rm -f \
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 \
163                         || die
164         fi
165
166         dodoc AGENT.txt ChangeLog FAQ INSTALL NEWS PORTING README* TODO
167         newdoc EXAMPLE.conf.def EXAMPLE.conf
168
169         if use doc; then
170                 docinto html
171                 dodoc -r docs/html/*
172         fi
173
174         keepdir /var/lib/net-snmp
175
176         newinitd "${FILESDIR}"/snmpd.init.2 snmpd
177         newconfd "${FILESDIR}"/snmpd.conf snmpd
178
179         newinitd "${FILESDIR}"/snmptrapd.init.2 snmptrapd
180         newconfd "${FILESDIR}"/snmptrapd.conf snmptrapd
181
182         systemd_dounit "${FILESDIR}"/snmpd.service
183         systemd_dounit "${FILESDIR}"/snmptrapd.service
184
185         insinto /etc/snmp
186         newins "${S}"/EXAMPLE.conf snmpd.conf.example
187
188         # Remove everything not required for an agent.
189         # Keep only the snmpd, snmptrapd, MIBs, headers and libraries.
190         if use minimal; then
191                 rm -rf \
192                         "${D}"/**/*.pl \
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 \
196                         || die
197         fi
198
199         prune_libtool_files
200 }