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