net-analyzer/scapy: Version 2.4.0_rc4.
[gentoo.git] / net-analyzer / nmap / nmap-7.40.ebuild
1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 PYTHON_COMPAT=( python2_7 )
7 PYTHON_REQ_USE="sqlite,xml"
8 inherit autotools flag-o-matic python-single-r1 toolchain-funcs
9
10 MY_P=${P/_beta/BETA}
11
12 DESCRIPTION="A utility for network discovery and security auditing"
13 HOMEPAGE="http://nmap.org/"
14 SRC_URI="
15         http://nmap.org/dist/${MY_P}.tar.bz2
16         https://dev.gentoo.org/~jer/nmap-logo-64.png
17 "
18
19 LICENSE="GPL-2"
20 SLOT="0"
21 KEYWORDS="alpha amd64 arm ~arm64 hppa ia64 ~mips ppc ppc64 ~s390 ~sh sparc x86 ~x86-fbsd ~amd64-linux ~arm-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~x86-solaris"
22
23 IUSE="ipv6 libressl +nse system-lua ncat ndiff nls nmap-update nping ssl zenmap"
24 NMAP_LINGUAS=( de fr hi hr it ja pl pt_BR ru zh )
25
26 REQUIRED_USE="
27         system-lua? ( nse )
28         ndiff? ( ${PYTHON_REQUIRED_USE} )
29         zenmap? ( ${PYTHON_REQUIRED_USE} )
30 "
31
32 RDEPEND="
33         dev-libs/liblinear:=
34         dev-libs/libpcre
35         net-libs/libpcap
36         zenmap? (
37                 dev-python/pygtk:2[${PYTHON_USEDEP}]
38                 ${PYTHON_DEPS}
39         )
40         system-lua? ( >=dev-lang/lua-5.2:*[deprecated] )
41         ndiff? ( ${PYTHON_DEPS} )
42         nls? ( virtual/libintl )
43         nmap-update? ( dev-libs/apr dev-vcs/subversion )
44         ssl? (
45                 !libressl? ( dev-libs/openssl:0= )
46                 libressl? ( dev-libs/libressl:= )
47         )
48 "
49 DEPEND="
50         ${RDEPEND}
51         nls? ( sys-devel/gettext )
52 "
53
54 S="${WORKDIR}/${MY_P}"
55 PATCHES=(
56         "${FILESDIR}"/${PN}-5.10_beta1-string.patch
57         "${FILESDIR}"/${PN}-5.21-python.patch
58         "${FILESDIR}"/${PN}-6.46-uninstaller.patch
59         "${FILESDIR}"/${PN}-6.25-liblua-ar.patch
60         "${FILESDIR}"/${PN}-7.25-no-FORTIFY_SOURCE.patch
61         "${FILESDIR}"/${PN}-7.25-CXXFLAGS.patch
62         "${FILESDIR}"/${PN}-7.25-libpcre.patch
63         "${FILESDIR}"/${PN}-7.31-libnl.patch
64 )
65
66 pkg_setup() {
67         if use ndiff || use zenmap; then
68                 python-single-r1_pkg_setup
69         fi
70 }
71
72 src_unpack() {
73         # prevent unpacking the logo
74         unpack ${MY_P}.tar.bz2
75 }
76
77 src_prepare() {
78         rm -r libpcap/ || die
79
80         cat "${FILESDIR}"/nls.m4 >> "${S}"/acinclude.m4 || die
81
82         default
83
84         local lingua
85         if use nls; then
86                 for lingua in ${NMAP_LINGUAS[@]}; do
87                         if ! has ${lingua} ${LINGUAS-${lingua}}; then
88                                 rm -r zenmap/share/zenmap/locale/${lingua} || die
89                                 rm zenmap/share/zenmap/locale/${lingua}.po || die
90                         fi
91                 done
92         else
93                 # configure/make ignores --disable-nls
94                 for lingua in ${NMAP_LINGUAS[@]}; do
95                         rm -r zenmap/share/zenmap/locale/${lingua} || die
96                         rm zenmap/share/zenmap/locale/${lingua}.po || die
97                 done
98         fi
99
100         sed -i \
101                 -e '/^ALL_LINGUAS =/{s|$| id|g;s|jp|ja|g}' \
102                 Makefile.in || die
103
104         sed -i \
105                 -e '/rm -f $@/d' \
106                 $(find . -name Makefile.in) \
107                 || die
108
109         # Fix desktop files wrt bug #432714
110         sed -i \
111                 -e '/^Encoding/d' \
112                 -e 's|^Categories=.*|Categories=Network;System;Security;|g' \
113                 zenmap/install_scripts/unix/zenmap-root.desktop \
114                 zenmap/install_scripts/unix/zenmap.desktop || die
115
116         cp libdnet-stripped/include/config.h.in{,.nmap-orig} || die
117         eautoreconf
118         if [[ ${CHOST} == *-darwin* ]] ; then
119                 # we need the original for a Darwin-specific fix, bug #604432
120                 mv libdnet-stripped/include/config.h.in{.nmap-orig,} || die
121         fi
122 }
123
124 src_configure() {
125         # The bundled libdnet is incompatible with the version available in the
126         # tree, so we cannot use the system library here.
127         econf \
128                 $(use_enable ipv6) \
129                 $(use_enable nls) \
130                 $(use_with zenmap) \
131                 $(usex nse --with-liblua=$(usex system-lua /usr included '' '') --without-liblua) \
132                 $(use_with ncat) \
133                 $(use_with ndiff) \
134                 $(use_with nmap-update) \
135                 $(use_with nping) \
136                 $(use_with ssl openssl) \
137                 --with-libdnet=included \
138                 --with-pcre=/usr
139         #       --with-liblinear=/usr \
140         #       Commented because configure does weird things, while autodetection works
141 }
142
143 src_compile() {
144         local directory
145         for directory in . libnetutil nsock/src \
146                 $(usex ncat ncat '') \
147                 $(usex nmap-update nmap-update '') \
148                 $(usex nping nping '')
149         do
150                 emake -C "${directory}" makefile.dep
151         done
152
153         emake \
154                 AR=$(tc-getAR) \
155                 RANLIB=$(tc-getRANLIB)
156 }
157
158 src_install() {
159         LC_ALL=C emake -j1 \
160                 DESTDIR="${D}" \
161                 STRIP=: \
162                 nmapdatadir="${EPREFIX}"/usr/share/nmap \
163                 install
164         if use nmap-update;then
165                 LC_ALL=C emake -j1 \
166                         -C nmap-update \
167                         DESTDIR="${D}" \
168                         STRIP=: \
169                         nmapdatadir="${EPREFIX}"/usr/share/nmap \
170                         install
171         fi
172
173         dodoc CHANGELOG HACKING docs/README docs/*.txt
174
175         if use zenmap; then
176                 doicon "${DISTDIR}/nmap-logo-64.png"
177                 python_optimize
178         fi
179 }