*/*: Clean PYTHON_COMPAT of obsolete impls
[gentoo.git] / net-analyzer / wireshark / wireshark-3.2.0.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=( python3_{6,7} )
6 inherit fcaps flag-o-matic multilib python-any-r1 qmake-utils user xdg-utils cmake-utils
7
8 DESCRIPTION="A network protocol analyzer formerly known as ethereal"
9 HOMEPAGE="https://www.wireshark.org/"
10 SRC_URI="https://www.wireshark.org/download/src/all-versions/${P/_/}.tar.xz"
11 LICENSE="GPL-2"
12
13 SLOT="0/${PV}"
14 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~ppc64 ~x86"
15 IUSE="
16         androiddump bcg729 brotli +capinfos +captype ciscodump +dftest doc dpauxmon
17         +dumpcap +editcap http2 kerberos libxml2 lua lz4 maxminddb +mergecap
18         +minizip +netlink +plugins plugin-ifdemo +pcap +qt5 +randpkt +randpktdump
19         +reordercap sbc selinux +sharkd smi snappy spandsp sshdump ssl sdjournal
20         +text2pcap tfshark +tshark +udpdump zlib
21 "
22 S=${WORKDIR}/${P/_/}
23
24 CDEPEND="
25         >=dev-libs/glib-2.32:2
26         >=net-dns/c-ares-1.5
27         dev-libs/libgcrypt:0
28         bcg729? ( media-libs/bcg729 )
29         brotli? ( app-arch/brotli )
30         ciscodump? ( >=net-libs/libssh-0.6 )
31         filecaps? ( sys-libs/libcap )
32         http2? ( net-libs/nghttp2 )
33         kerberos? ( virtual/krb5 )
34         libxml2? ( dev-libs/libxml2 )
35         lua? ( >=dev-lang/lua-5.1:* )
36         lz4? ( app-arch/lz4 )
37         maxminddb? ( dev-libs/libmaxminddb )
38         minizip? ( sys-libs/zlib[minizip] )
39         netlink? ( dev-libs/libnl:3 )
40         pcap? ( net-libs/libpcap )
41         qt5? (
42                 dev-qt/qtcore:5
43                 dev-qt/qtgui:5
44                 dev-qt/qtmultimedia:5
45                 dev-qt/qtprintsupport:5
46                 dev-qt/qtwidgets:5
47                 x11-misc/xdg-utils
48         )
49         sbc? ( media-libs/sbc )
50         sdjournal? ( sys-apps/systemd )
51         smi? ( net-libs/libsmi )
52         snappy? ( app-arch/snappy )
53         spandsp? ( media-libs/spandsp )
54         sshdump? ( >=net-libs/libssh-0.6 )
55         ssl? ( net-libs/gnutls:= )
56         zlib? ( sys-libs/zlib )
57 "
58 # We need perl for `pod2html`. The rest of the perl stuff is to block older
59 # and broken installs. #455122
60 DEPEND="
61         ${CDEPEND}
62         ${PYTHON_DEPS}
63 "
64 BDEPEND="
65         dev-lang/perl
66         sys-devel/bison
67         sys-devel/flex
68         virtual/pkgconfig
69         doc? (
70                 app-doc/doxygen
71                 dev-ruby/asciidoctor
72         )
73         qt5? (
74                 dev-qt/linguist-tools:5
75         )
76 "
77 RDEPEND="
78         ${CDEPEND}
79         qt5? ( virtual/freedesktop-icon-theme )
80         selinux? ( sec-policy/selinux-wireshark )
81 "
82 REQUIRED_USE="
83         plugin-ifdemo? ( plugins )
84 "
85 PATCHES=(
86         "${FILESDIR}"/${PN}-2.4-androiddump.patch
87         "${FILESDIR}"/${PN}-2.6.0-redhat.patch
88         "${FILESDIR}"/${PN}-2.9.0-tfshark-libm.patch
89         "${FILESDIR}"/${PN}-99999999-androiddump-wsutil.patch
90         "${FILESDIR}"/${PN}-99999999-qtsvg.patch
91         "${FILESDIR}"/${PN}-99999999-ui-needs-wiretap.patch
92 )
93
94 pkg_setup() {
95         enewgroup wireshark
96 }
97
98 src_configure() {
99         local mycmakeargs
100
101         # Workaround bug #213705. If krb5-config --libs has -lcrypto then pass
102         # --with-ssl to ./configure. (Mimics code from acinclude.m4).
103         if use kerberos; then
104                 case $(krb5-config --libs) in
105                         *-lcrypto*)
106                                 ewarn "Kerberos was built with ssl support: linkage with openssl is enabled."
107                                 ewarn "Note there are annoying license incompatibilities between the OpenSSL"
108                                 ewarn "license and the GPL, so do your check before distributing such package."
109                                 mycmakeargs+=( -DENABLE_GNUTLS=$(usex ssl) )
110                                 ;;
111                 esac
112         fi
113
114         if use qt5; then
115                 export QT_MIN_VERSION=5.3.0
116                 append-cxxflags -fPIC -DPIC
117         fi
118
119         python_setup
120
121         mycmakeargs+=(
122                 $(use androiddump && use pcap && echo -DEXTCAP_ANDROIDDUMP_LIBPCAP=yes)
123                 $(usex qt5 LRELEASE=$(qt5_get_bindir)/lrelease '')
124                 $(usex qt5 MOC=$(qt5_get_bindir)/moc '')
125                 $(usex qt5 RCC=$(qt5_get_bindir)/rcc '')
126                 $(usex qt5 UIC=$(qt5_get_bindir)/uic '')
127                 -DBUILD_androiddump=$(usex androiddump)
128                 -DBUILD_capinfos=$(usex capinfos)
129                 -DBUILD_captype=$(usex captype)
130                 -DBUILD_ciscodump=$(usex ciscodump)
131                 -DBUILD_dftest=$(usex dftest)
132                 -DBUILD_dpauxmon=$(usex dpauxmon)
133                 -DBUILD_dumpcap=$(usex dumpcap)
134                 -DBUILD_editcap=$(usex editcap)
135                 -DBUILD_mergecap=$(usex mergecap)
136                 -DBUILD_mmdbresolve=$(usex maxminddb)
137                 -DBUILD_randpkt=$(usex randpkt)
138                 -DBUILD_randpktdump=$(usex randpktdump)
139                 -DBUILD_reordercap=$(usex reordercap)
140                 -DBUILD_sdjournal=$(usex sdjournal)
141                 -DBUILD_sharkd=$(usex sharkd)
142                 -DBUILD_sshdump=$(usex sshdump)
143                 -DBUILD_text2pcap=$(usex text2pcap)
144                 -DBUILD_tfshark=$(usex tfshark)
145                 -DBUILD_tshark=$(usex tshark)
146                 -DBUILD_udpdump=$(usex udpdump)
147                 -DBUILD_wireshark=$(usex qt5)
148                 -DCMAKE_INSTALL_DOCDIR="${EROOT}/usr/share/doc/${PF}"
149                 -DDISABLE_WERROR=yes
150                 -DENABLE_BCG729=$(usex bcg729)
151                 -DENABLE_BROTLI=$(usex brotli)
152                 -DENABLE_CAP=$(usex filecaps caps)
153                 -DENABLE_GNUTLS=$(usex ssl)
154                 -DENABLE_KERBEROS=$(usex kerberos)
155                 -DENABLE_LIBXML2=$(usex libxml2)
156                 -DENABLE_LUA=$(usex lua)
157                 -DENABLE_LZ4=$(usex lz4)
158                 -DENABLE_MINIZIP=$(usex minizip)
159                 -DENABLE_NETLINK=$(usex netlink)
160                 -DENABLE_NGHTTP2=$(usex http2)
161                 -DENABLE_PCAP=$(usex pcap)
162                 -DENABLE_PLUGINS=$(usex plugins)
163                 -DENABLE_PLUGIN_IFDEMO=$(usex plugin-ifdemo)
164                 -DENABLE_SBC=$(usex sbc)
165                 -DENABLE_SMI=$(usex smi)
166                 -DENABLE_SNAPPY=$(usex snappy)
167                 -DENABLE_SPANDSP=$(usex spandsp)
168                 -DENABLE_ZLIB=$(usex zlib)
169         )
170
171         cmake-utils_src_configure
172 }
173
174 src_test() {
175         cmake-utils_src_test
176 }
177
178 src_install() {
179         cmake-utils_src_install
180
181         # FAQ is not required as is installed from help/faq.txt
182         dodoc AUTHORS ChangeLog NEWS README* doc/randpkt.txt doc/README*
183
184         # install headers
185         insinto /usr/include/wireshark
186         doins ws_diag_control.h ws_symbol_export.h \
187                 "${BUILD_DIR}"/config.h "${BUILD_DIR}"/version.h
188
189         local dir dirs=(
190                 epan
191                 epan/crypt
192                 epan/dfilter
193                 epan/dissectors
194                 epan/ftypes
195                 epan/wmem
196                 wiretap
197                 wsutil
198         )
199         for dir in "${dirs[@]}"
200         do
201                 insinto /usr/include/wireshark/${dir}
202                 doins ${dir}/*.h
203         done
204
205         #with the above this really shouldn't be needed, but things may be looking
206         # in wiretap/ instead of wireshark/wiretap/
207         insinto /usr/include/wiretap
208         doins wiretap/wtap.h
209
210         if use qt5; then
211                 local s
212                 for s in 16 32 48 64 128 256 512 1024; do
213                         insinto /usr/share/icons/hicolor/${s}x${s}/apps
214                         newins image/wsicon${s}.png wireshark.png
215                 done
216                 for s in 16 24 32 48 64 128 256 ; do
217                         insinto /usr/share/icons/hicolor/${s}x${s}/mimetypes
218                         newins image/WiresharkDoc-${s}.png application-vnd.tcpdump.pcap.png
219                 done
220         fi
221 }
222
223 pkg_postinst() {
224         xdg_desktop_database_update
225         xdg_icon_cache_update
226         xdg_mimeinfo_database_update
227
228         # Add group for users allowed to sniff.
229         enewgroup wireshark
230         chgrp wireshark "${EROOT}"/usr/bin/dumpcap
231
232         if use dumpcap && use pcap; then
233                 fcaps -o 0 -g wireshark -m 4710 -M 0710 \
234                         cap_dac_read_search,cap_net_raw,cap_net_admin \
235                         "${EROOT}"/usr/bin/dumpcap
236         fi
237
238         ewarn "NOTE: To capture traffic with wireshark as normal user you have to"
239         ewarn "add yourself to the wireshark group. This security measure ensures"
240         ewarn "that only trusted users are allowed to sniff your traffic."
241 }
242
243 pkg_postrm() {
244         xdg_desktop_database_update
245         xdg_icon_cache_update
246         xdg_mimeinfo_database_update
247 }