Use https by default
[gentoo.git] / net-analyzer / net-snmp / net-snmp-5.7.3_pre5-r1.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6 PYTHON_COMPAT=( python2_7 )
7 DISTUTILS_SINGLE_IMPL=yesplz
8 DISTUTILS_OPTIONAL=yesplz
9 WANT_AUTOMAKE=none
10 PATCHSET=1
11
12 inherit autotools distutils-r1 eutils perl-module systemd
13
14 DESCRIPTION="Software for generating and retrieving SNMP data"
15 HOMEPAGE="http://net-snmp.sourceforge.net/"
16 SRC_URI="
17         mirror://sourceforge/${PN}/${PN}/${PV/_pre*/}-pre-releases/${P/_pre*/}.${PV/*_}.tar.gz
18         https://dev.gentoo.org/~jer/${PN}-5.7.3-patches-${PATCHSET}.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"
26 KEYWORDS="alpha amd64 arm arm64 hppa ia64 ~mips ppc ppc64 s390 sh sparc x86"
27 IUSE="bzip2 doc elf ipv6 mfd-rewrites minimal perl python rpm selinux ssl tcpd X zlib lm_sensors ucd-compat pci netlink mysql"
28
29 COMMON="ssl? ( >=dev-libs/openssl-0.9.6d )
30         tcpd? ( >=sys-apps/tcp-wrappers-7.6 )
31         rpm? (
32                 app-arch/rpm
33                 dev-libs/popt
34         )
35         bzip2? ( app-arch/bzip2 )
36         zlib? ( >=sys-libs/zlib-1.1.4 )
37         elf? ( dev-libs/elfutils )
38         python? (
39                 dev-python/setuptools[${PYTHON_USEDEP}]
40                 ${PYTHON_DEPS}
41         )
42         pci? ( sys-apps/pciutils )
43         lm_sensors? ( sys-apps/lm_sensors )
44         netlink? ( dev-libs/libnl:3 )
45         mysql? ( virtual/mysql )"
46
47 RDEPEND="${COMMON}
48         perl? (
49                 X? ( dev-perl/perl-tk )
50                 !minimal? ( dev-perl/TermReadKey )
51         )
52         selinux? ( sec-policy/selinux-snmp )
53 "
54
55 # Dependency on autoconf due to bug #225893
56 DEPEND="${COMMON}
57         >=sys-apps/sed-4
58         doc? ( app-doc/doxygen )"
59
60 REQUIRED_USE="
61         python? ( ${PYTHON_REQUIRED_USE} )
62         rpm? ( bzip2 zlib )
63 "
64
65 RESTRICT=test
66
67 pkg_setup() {
68         use python && python-single-r1_pkg_setup
69 }
70
71 src_prepare() {
72         # snmpconf generates config files with proper selinux context
73         use selinux && epatch "${FILESDIR}"/${PN}-5.1.2-snmpconf-selinux.patch
74
75         epatch "${WORKDIR}"/patches/*.patch
76
77         epatch_user
78
79         eautoconf
80 }
81
82 src_configure() {
83         # keep this in the same line, configure.ac arguments are passed down to config.h
84         local mibs="host ucd-snmp/dlmod ucd-snmp/diskio ucd-snmp/extensible mibII/mta_sendmail smux"
85         use lm_sensors && mibs="${mibs} ucd-snmp/lmsensorsMib"
86
87         econf \
88                 $(use_enable !ssl internal-md5) \
89                 $(use_enable ipv6) \
90                 $(use_enable mfd-rewrites) \
91                 $(use_enable perl embedded-perl) \
92                 $(use_enable ucd-compat ucd-snmp-compatibility) \
93                 $(use_with bzip2) \
94                 $(use_with elf) \
95                 $(use_with mysql) \
96                 $(use_with netlink nl) \
97                 $(use_with pci) \
98                 $(use_with perl perl-modules INSTALLDIRS=vendor) \
99                 $(use_with python python-modules) \
100                 $(use_with rpm) \
101                 $(use_with ssl openssl) \
102                 $(use_with tcpd libwrap) \
103                 $(use_with zlib) \
104                 --enable-shared --disable-static \
105                 --with-default-snmp-version="3" \
106                 --with-install-prefix="${D}" \
107                 --with-ldflags="${LDFLAGS}" \
108                 --with-logfile="/var/log/net-snmpd.log" \
109                 --with-mib-modules="${mibs}" \
110                 --with-persistent-directory="/var/lib/net-snmp" \
111                 --with-sys-contact="root@Unknown" \
112                 --with-sys-location="Unknown"
113 }
114
115 src_compile() {
116         emake \
117                 OTHERLDFLAGS="${LDFLAGS}" \
118                 sedscript all
119
120         use doc && emake docsdox
121 }
122
123 src_install () {
124         # bug #317965
125         emake -j1 DESTDIR="${D}" install
126
127         if use perl ; then
128                 perl_delete_localpod
129                 use X || rm -f "${D}"/usr/bin/tkmib
130         else
131                 rm -f "${D}"/usr/bin/mib2c "${D}"/usr/bin/snmpcheck "${D}"/usr/bin/tkmib
132         fi
133
134         dodoc AGENT.txt ChangeLog FAQ INSTALL NEWS PORTING README* TODO
135         newdoc EXAMPLE.conf.def EXAMPLE.conf
136
137         use doc && dohtml docs/html/*
138
139         keepdir /var/lib/net-snmp
140
141         newinitd "${FILESDIR}"/snmpd.init.2 snmpd
142         newconfd "${FILESDIR}"/snmpd.conf snmpd
143
144         newinitd "${FILESDIR}"/snmptrapd.init.2 snmptrapd
145         newconfd "${FILESDIR}"/snmptrapd.conf snmptrapd
146
147         systemd_dounit "${FILESDIR}"/snmpd.service
148         systemd_dounit "${FILESDIR}"/snmptrapd.service
149
150         insinto /etc/snmp
151         newins "${S}"/EXAMPLE.conf snmpd.conf.example
152
153         # Remove everything not required for an agent.
154         # Keep only the snmpd, snmptrapd, MIBs, headers and libraries.
155         if use minimal; then
156                 rm -rf \
157                         "${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} \
158                         "${D}"/usr/share/snmp/snmpconf-data \
159                         "${D}"/usr/share/snmp/*.conf \
160                         "${D}"/**/*.pl
161         fi
162 }