net-analyzer/fail2ban: amd64 stable wrt bug #719458
[gentoo.git] / net-analyzer / net-snmp / net-snmp-99999999.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5 PYTHON_COMPAT=( python3_{6,7,8} )
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 git-r3 perl-module systemd
13
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"
17 SRC_URI="
18         https://dev.gentoo.org/~jer/${PN}-5.7.3-patches-3.tar.xz
19 "
20
21 # GPL-2 for the init scripts
22 LICENSE="HPND BSD GPL-2"
23 SLOT="0/35"
24 KEYWORDS=""
25 IUSE="
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
28 "
29 REQUIRED_USE="
30         python? ( ${PYTHON_REQUIRED_USE} )
31         rpm? ( bzip2 zlib )
32 "
33
34 COMMON_DEPEND="
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:= )
43         python? (
44                 $(python_gen_cond_dep '
45                         dev-python/setuptools[${PYTHON_MULTI_USEDEP}]
46                 ')
47                 ${PYTHON_DEPS}
48         )
49         rpm? (
50                 app-arch/rpm
51                 dev-libs/popt
52         )
53         ssl? (
54                 !libressl? ( >=dev-libs/openssl-0.9.6d:0= )
55                 libressl? ( dev-libs/libressl:= )
56         )
57         tcpd? ( >=sys-apps/tcp-wrappers-7.6 )
58         zlib? ( >=sys-libs/zlib-1.1.4 )
59 "
60 DEPEND="
61         ${COMMON_DEPEND}
62         doc? ( app-doc/doxygen )
63 "
64 RDEPEND="
65         ${COMMON_DEPEND}
66         perl? (
67                 X? ( dev-perl/Tk )
68                 !minimal? ( dev-perl/TermReadKey )
69         )
70         selinux? ( sec-policy/selinux-snmp )
71 "
72 S=${WORKDIR}/${P/_/.}
73 S=${WORKDIR}/${P/_p*/}
74 RESTRICT=test
75 PATCHES=(
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
81 )
82
83 pkg_setup() {
84         use python && python-single-r1_pkg_setup
85 }
86
87 src_unpack() {
88         default
89         git-r3_src_unpack
90 }
91
92 src_prepare() {
93         # snmpconf generates config files with proper selinux context
94         use selinux && eapply "${FILESDIR}"/${PN}-5.1.2-snmpconf-selinux.patch
95
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
99
100         default
101
102         eautoconf
103 }
104
105 src_configure() {
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"
110
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
113
114         econf \
115                 $(use_enable !ssl internal-md5) \
116                 $(use_enable ipv6) \
117                 $(use_enable mfd-rewrites) \
118                 $(use_enable perl embedded-perl) \
119                 $(use_enable ucd-compat ucd-snmp-compatibility) \
120                 $(use_with bzip2) \
121                 $(use_with elf) \
122                 $(use_with kmem kmem-usage) \
123                 $(use_with mysql) \
124                 $(use_with netlink nl) \
125                 $(use_with pcap) \
126                 $(use_with pci) \
127                 $(use_with perl perl-modules INSTALLDIRS=vendor) \
128                 $(use_with python python-modules) \
129                 $(use_with rpm) \
130                 $(use_with ssl openssl) \
131                 $(use_with tcpd libwrap) \
132                 $(use_with zlib) \
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"
142 }
143
144 src_compile() {
145         for target in snmplib agent sedscript all; do
146                 emake OTHERLDFLAGS="${LDFLAGS}" ${target}
147         done
148
149         use doc && emake docsdox
150 }
151
152 src_install() {
153         # bug #317965
154         emake -j1 DESTDIR="${D}" install
155
156         use python && python_optimize
157
158         if use perl ; then
159                 perl_delete_localpod
160                 if ! use X; then
161                         rm "${D}"/usr/bin/tkmib || die
162                 fi
163         else
164                 rm -f \
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 \
176                         || die
177         fi
178
179         dodoc AGENT.txt ChangeLog FAQ INSTALL NEWS PORTING README* TODO
180         newdoc EXAMPLE.conf.def EXAMPLE.conf
181
182         if use doc; then
183                 docinto html
184                 dodoc -r docs/html/*
185         fi
186
187         keepdir /var/lib/net-snmp
188
189         newinitd "${FILESDIR}"/snmpd.init.2 snmpd
190         newconfd "${FILESDIR}"/snmpd.conf snmpd
191
192         newinitd "${FILESDIR}"/snmptrapd.init.2 snmptrapd
193         newconfd "${FILESDIR}"/snmptrapd.conf snmptrapd
194
195         systemd_dounit "${FILESDIR}"/snmpd.service
196         systemd_dounit "${FILESDIR}"/snmptrapd.service
197
198         insinto /etc/snmp
199         newins "${S}"/EXAMPLE.conf snmpd.conf.example
200
201         # Remove everything not required for an agent.
202         # Keep only the snmpd, snmptrapd, MIBs, headers and libraries.
203         if use minimal; then
204                 rm -rf \
205                         "${D}"/**/*.pl \
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 \
209                         || die
210         fi
211
212         find "${ED}" -name '*.la' -delete || die
213 }