net-analyzer/wireshark: 2.0.1 stable on x86, see bug 570564
[gentoo.git] / net-analyzer / wireshark / wireshark-2.0.1.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 inherit autotools eutils fcaps flag-o-matic multilib qmake-utils qt4-r2 user
7
8 DESCRIPTION="A network protocol analyzer formerly known as ethereal"
9 HOMEPAGE="http://www.wireshark.org/"
10 SRC_URI="${HOMEPAGE}download/src/all-versions/${P/_/}.tar.bz2"
11
12 LICENSE="GPL-2"
13 SLOT="0/${PV}"
14 KEYWORDS="alpha amd64 ~arm hppa ia64 ppc ppc64 sparc x86 ~x86-fbsd"
15 IUSE="
16         adns androiddump +caps crypt doc doc-pdf geoip +gtk3 ipv6 kerberos lua
17         +netlink +pcap portaudio +qt4 qt5 selinux sbc smi tfshark
18         cpu_flags_x86_sse4_2 ssl zlib
19 "
20 REQUIRED_USE="
21         ssl? ( crypt )
22         ?? ( qt4 qt5 )
23 "
24
25 S=${WORKDIR}/${P/_/}
26
27 GTK_COMMON_DEPEND="
28         x11-libs/gdk-pixbuf
29         x11-libs/pango
30         x11-misc/xdg-utils
31 "
32 CDEPEND="
33         >=dev-libs/glib-2.14:2
34         netlink? ( dev-libs/libnl:3 )
35         adns? ( >=net-dns/c-ares-1.5 )
36         crypt? ( dev-libs/libgcrypt:0 )
37         caps? ( sys-libs/libcap )
38         geoip? ( dev-libs/geoip )
39         gtk3? (
40                 ${GTK_COMMON_DEPEND}
41                 x11-libs/gtk+:3
42         )
43         kerberos? ( virtual/krb5 )
44         lua? ( >=dev-lang/lua-5.1:* )
45         pcap? ( net-libs/libpcap )
46         portaudio? ( media-libs/portaudio )
47         qt4? (
48                 dev-qt/qtcore:4
49                 dev-qt/qtgui:4[accessibility]
50                 x11-misc/xdg-utils
51                 )
52         qt5? (
53                 dev-qt/qtcore:5
54                 dev-qt/qtgui:5
55                 dev-qt/qtmultimedia:5
56                 dev-qt/qtprintsupport:5
57                 dev-qt/qtwidgets:5
58                 x11-misc/xdg-utils
59         )
60         sbc? ( media-libs/sbc )
61         smi? ( net-libs/libsmi )
62         ssl? ( net-libs/gnutls )
63         zlib? ( sys-libs/zlib !=sys-libs/zlib-1.2.4 )
64 "
65 # We need perl for `pod2html`.  The rest of the perl stuff is to block older
66 # and broken installs. #455122
67 DEPEND="
68         ${CDEPEND}
69         dev-lang/perl
70         !<virtual/perl-Pod-Simple-3.170
71         !<perl-core/Pod-Simple-3.170
72         doc? (
73                 app-doc/doxygen
74                 app-text/asciidoc
75                 dev-libs/libxml2
76                 dev-libs/libxslt
77                 doc-pdf? ( dev-java/fop )
78                 www-client/lynx
79         )
80         sys-devel/bison
81         sys-devel/flex
82         virtual/pkgconfig
83 "
84 RDEPEND="
85         ${CDEPEND}
86         gtk3? ( virtual/freedesktop-icon-theme )
87         qt4? ( virtual/freedesktop-icon-theme )
88         qt5? ( virtual/freedesktop-icon-theme )
89         selinux? ( sec-policy/selinux-wireshark )
90 "
91
92 pkg_setup() {
93         enewgroup wireshark
94 }
95
96 src_prepare() {
97         epatch \
98                 "${FILESDIR}"/${PN}-1.6.13-ldflags.patch \
99                 "${FILESDIR}"/${PN}-1.11.0-oldlibs.patch \
100                 "${FILESDIR}"/${PN}-99999999-pkgconfig.patch \
101                 "${FILESDIR}"/${PN}-1.99.8-qtchooser.patch \
102                 "${FILESDIR}"/${PN}-2.0.0-androiddump-pcap.patch \
103                 "${FILESDIR}"/${PN}-2.1.0-sse4_2.patch
104
105         epatch_user
106
107         eautoreconf
108 }
109
110 src_configure() {
111         local myconf
112
113         # Workaround bug #213705. If krb5-config --libs has -lcrypto then pass
114         # --with-ssl to ./configure. (Mimics code from acinclude.m4).
115         if use kerberos; then
116                 case $(krb5-config --libs) in
117                         *-lcrypto*)
118                                 ewarn "Kerberos was built with ssl support: linkage with openssl is enabled."
119                                 ewarn "Note there are annoying license incompatibilities between the OpenSSL"
120                                 ewarn "license and the GPL, so do your check before distributing such package."
121                                 myconf+=( "--with-ssl" )
122                                 ;;
123                 esac
124         fi
125
126         # Enable wireshark binary with any supported GUI toolkit (bug #473188)
127         if use gtk3 || use qt4 || use qt5; then
128                 myconf+=( "--enable-wireshark" )
129         else
130                 myconf+=( "--disable-wireshark" )
131         fi
132
133         if ! use qt4 && ! use qt5; then
134                 myconf+=( "--with-qt=no" )
135         fi
136
137         if use qt4; then
138                 export QT_MIN_VERSION=4.6.0
139         fi
140
141         if use qt5; then
142                 export QT_MIN_VERSION=5.3.0
143                 append-cxxflags -fPIC -DPIC
144         fi
145
146         # Hack around inability to disable doxygen/fop doc generation
147         use doc || export ac_cv_prog_HAVE_DOXYGEN=false
148         use doc-pdf || export ac_cv_prog_HAVE_FOP=false
149
150         # dumpcap requires libcap
151         # --disable-profile-build bugs #215806, #292991, #479602
152         econf \
153                 $(use androiddump && use pcap && echo --enable-androiddump-use-libpcap=yes) \
154                 $(use_enable androiddump) \
155                 $(use_enable ipv6) \
156                 $(use_enable tfshark) \
157                 $(use_with adns c-ares) \
158                 $(use_with caps libcap) \
159                 $(use_with crypt gcrypt) \
160                 $(use_with geoip) \
161                 $(use_with gtk3) \
162                 $(use_with kerberos krb5) \
163                 $(use_with lua) \
164                 $(use_with pcap dumpcap-group wireshark) \
165                 $(use_with pcap) \
166                 $(use_with portaudio) \
167                 $(usex qt4 --with-qt=4 '') \
168                 $(usex qt5 --with-qt=5 '') \
169                 $(usex qt4 MOC=$(qt4_get_bindir)/moc '') \
170                 $(usex qt4 RCC=$(qt4_get_bindir)/rcc '') \
171                 $(usex qt4 UIC=$(qt4_get_bindir)/uic '') \
172                 $(usex qt5 MOC=$(qt5_get_bindir)/moc '') \
173                 $(usex qt5 RCC=$(qt5_get_bindir)/rcc '') \
174                 $(usex qt5 UIC=$(qt5_get_bindir)/uic '') \
175                 $(use_with sbc) \
176                 $(use_with smi libsmi) \
177                 $(use_with ssl gnutls) \
178                 $(use_with zlib) \
179                 $(usex netlink --with-libnl=3 --without-libnl) \
180                 $(usex cpu_flags_x86_sse4_2 --enable-sse4_2 '') \
181                 --disable-profile-build \
182                 --disable-usr-local \
183                 --disable-warnings-as-errors \
184                 --sysconfdir="${EPREFIX}"/etc/wireshark \
185                 --without-adns \
186                 ${myconf[@]}
187 }
188
189 src_compile() {
190         default
191         if use doc; then
192                 use doc-pdf && addpredict "/root/.java"
193                 emake -j1 -C docbook
194         fi
195 }
196
197 src_install() {
198         default
199
200         if use doc; then
201                 dohtml -r docbook/{release-notes.html,ws{d,u}g_html{,_chunked}}
202                 if use doc-pdf; then
203                         insinto /usr/share/doc/${PF}/pdf/
204                         doins docbook/{developer,user}-guide-{a4,us}.pdf docbook/release-notes.pdf
205                 fi
206         fi
207
208         # FAQ is not required as is installed from help/faq.txt
209         dodoc AUTHORS ChangeLog NEWS README{,.bsd,.linux,.macos,.vmware} \
210                 doc/{randpkt.txt,README*}
211
212         # install headers
213         local wsheader
214         for wsheader in \
215                 color.h \
216                 config.h \
217                 epan/*.h \
218                 epan/crypt/*.h \
219                 epan/dfilter/*.h \
220                 epan/dissectors/*.h \
221                 epan/ftypes/*.h \
222                 epan/wmem/*.h \
223                 register.h \
224                 wiretap/*.h \
225                 ws_symbol_export.h \
226                 wsutil/*.h
227         do
228                 insinto /usr/include/wireshark/$( dirname ${wsheader} )
229                 doins ${wsheader}
230         done
231
232         #with the above this really shouldn't be needed, but things may be looking in wiretap/ instead of wireshark/wiretap/
233         insinto /usr/include/wiretap
234         doins wiretap/wtap.h
235
236         if use gtk3 || use qt4 || use qt5; then
237                 local c d
238                 for c in hi lo; do
239                         for d in 16 32 48; do
240                                 insinto /usr/share/icons/${c}color/${d}x${d}/apps
241                                 newins image/${c}${d}-app-wireshark.png wireshark.png
242                         done
243                 done
244                 for d in 16 24 32 48 64 128 256 ; do
245                         insinto /usr/share/icons/hicolor/${d}x${d}/mimetypes
246                         newins image/WiresharkDoc-${d}.png application-vnd.tcpdump.pcap.png
247                 done
248         fi
249
250         if use gtk3; then
251                 domenu wireshark.desktop
252         fi
253
254         if use qt4 || use qt5; then
255                 sed \
256                         -e '/Exec=/s|wireshark|&-qt|g' \
257                         -e 's|^Name.*=Wireshark|& (Qt)|g' \
258                         wireshark.desktop > wireshark-qt.desktop \
259                         || die
260                 domenu wireshark-qt.desktop
261         fi
262
263         prune_libtool_files
264 }
265
266 pkg_postinst() {
267         # Add group for users allowed to sniff.
268         enewgroup wireshark
269
270         if use pcap; then
271                 fcaps -o 0 -g wireshark -m 4710 -M 0710 \
272                         cap_dac_read_search,cap_net_raw,cap_net_admin \
273                         "${EROOT}"/usr/bin/dumpcap
274         fi
275
276         ewarn "NOTE: To capture traffic with wireshark as normal user you have to"
277         ewarn "add yourself to the wireshark group. This security measure ensures"
278         ewarn "that only trusted users are allowed to sniff your traffic."
279 }