net-analyzer/etherape: Old
[gentoo.git] / net-analyzer / net-snmp / net-snmp-5.8.1_pre1-r1.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=( 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 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*/}-pre-releases/${P/_pre/.pre}.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="
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
30 "
31 REQUIRED_USE="
32         python? ( ${PYTHON_REQUIRED_USE} )
33         rpm? ( bzip2 zlib )
34 "
35
36 COMMON_DEPEND="
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:= )
45         python? (
46                 $(python_gen_cond_dep '
47                         dev-python/setuptools[${PYTHON_MULTI_USEDEP}]
48                 ')
49                 ${PYTHON_DEPS}
50         )
51         rpm? (
52                 app-arch/rpm
53                 dev-libs/popt
54         )
55         ssl? (
56                 !libressl? ( >=dev-libs/openssl-0.9.6d:0= )
57                 libressl? ( dev-libs/libressl:= )
58         )
59         tcpd? ( >=sys-apps/tcp-wrappers-7.6 )
60         zlib? ( >=sys-libs/zlib-1.1.4 )
61 "
62 DEPEND="
63         ${COMMON_DEPEND}
64         doc? ( app-doc/doxygen )
65 "
66 RDEPEND="
67         ${COMMON_DEPEND}
68         perl? (
69                 X? ( dev-perl/Tk )
70                 !minimal? ( dev-perl/TermReadKey )
71         )
72         selinux? ( sec-policy/selinux-snmp )
73 "
74 S=${WORKDIR}/${P/_pre/.pre}
75 RESTRICT=test
76 PATCHES=(
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
82 )
83
84 pkg_setup() {
85         use python && python-single-r1_pkg_setup
86 }
87
88 src_prepare() {
89         # snmpconf generates config files with proper selinux context
90         use selinux && eapply "${FILESDIR}"/${PN}-5.1.2-snmpconf-selinux.patch
91
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
95
96         default
97
98         eautoconf
99 }
100
101 src_configure() {
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"
106
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
109
110         econf \
111                 $(use_enable !ssl internal-md5) \
112                 $(use_enable ipv6) \
113                 $(use_enable mfd-rewrites) \
114                 $(use_enable perl embedded-perl) \
115                 $(use_enable ucd-compat ucd-snmp-compatibility) \
116                 $(use_with bzip2) \
117                 $(use_with elf) \
118                 $(use_with kmem kmem-usage) \
119                 $(use_with mysql) \
120                 $(use_with netlink nl) \
121                 $(use_with pcap) \
122                 $(use_with pci) \
123                 $(use_with perl perl-modules INSTALLDIRS=vendor) \
124                 $(use_with python python-modules) \
125                 $(use_with rpm) \
126                 $(use_with ssl openssl) \
127                 $(use_with tcpd libwrap) \
128                 $(use_with zlib) \
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"
138 }
139
140 src_compile() {
141         for target in snmplib agent sedscript all; do
142                 emake OTHERLDFLAGS="${LDFLAGS}" ${target}
143         done
144
145         use doc && emake docsdox
146 }
147
148 src_install() {
149         # bug #317965
150         emake -j1 DESTDIR="${D}" install
151
152         use python && python_optimize
153
154         if use perl ; then
155                 perl_delete_localpod
156                 if ! use X; then
157                         rm "${D}"/usr/bin/tkmib || die
158                 fi
159         else
160                 rm -f \
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 \
172                         || die
173         fi
174
175         dodoc AGENT.txt ChangeLog FAQ INSTALL NEWS PORTING README* TODO
176         newdoc EXAMPLE.conf.def EXAMPLE.conf
177
178         if use doc; then
179                 docinto html
180                 dodoc -r docs/html/*
181         fi
182
183         keepdir /var/lib/net-snmp
184
185         newinitd "${FILESDIR}"/snmpd.init.2 snmpd
186         newconfd "${FILESDIR}"/snmpd.conf snmpd
187
188         newinitd "${FILESDIR}"/snmptrapd.init.2 snmptrapd
189         newconfd "${FILESDIR}"/snmptrapd.conf snmptrapd
190
191         systemd_dounit "${FILESDIR}"/snmpd.service
192         systemd_dounit "${FILESDIR}"/snmptrapd.service
193
194         insinto /etc/snmp
195         newins "${S}"/EXAMPLE.conf snmpd.conf.example
196
197         # Remove everything not required for an agent.
198         # Keep only the snmpd, snmptrapd, MIBs, headers and libraries.
199         if use minimal; then
200                 rm -rf \
201                         "${D}"/**/*.pl \
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 \
205                         || die
206         fi
207
208         find "${ED}" -name '*.la' -delete || die
209 }