1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
|
#!/bin/bash
# Setup development environment for RPM based systems such as Red Hat, Centos, Fedora, openSUSE
#
# Wireshark - Network traffic analyzer
# By Gerald Combs <gerald@wireshark.org>
# Copyright 1998 Gerald Combs
#
# SPDX-License-Identifier: GPL-2.0-or-later
#
# We drag in tools that might not be needed by all users; it's easier
# that way.
#
set -e -u -o pipefail
function print_usage() {
printf "\nUtility to setup a rpm-based system for Wireshark Development.\n"
printf "The basic usage installs the needed software\n\n"
printf "Usage: $0 [--install-optional] [...other options...]\n"
printf "\t--install-optional: install optional software as well\n"
printf "\t--install-rpm-deps: install packages required to build the .rpm file\n"
printf "\\t--install-qt5-deps: force installation of packages required to use Qt5\\n"
printf "\\t--install-qt6-deps: force installation of packages required to use Qt6\\n"
printf "\\t--install-all: install everything\\n"
printf "\t[other]: other options are passed as-is to the package manager\n"
}
ADDITIONAL=0
RPMDEPS=0
ADD_QT5=0
ADD_QT6=0
HAVE_ADD_QT=0
OPTIONS=
for arg; do
case $arg in
--help|-h)
print_usage
exit 0
;;
--install-optional)
ADDITIONAL=1
;;
--install-rpm-deps)
RPMDEPS=1
;;
--install-qt5-deps)
ADD_QT5=1
HAVE_ADD_QT=1
;;
--install-qt6-deps)
ADD_QT6=1
HAVE_ADD_QT=1
;;
--install-all)
ADDITIONAL=1
RPMDEPS=1
ADD_QT5=1
ADD_QT6=1
HAVE_ADD_QT=1
;;
*)
OPTIONS="$OPTIONS $arg"
;;
esac
done
# Check if the user is root
if [ $(id -u) -ne 0 ]
then
echo "You must be root."
exit 1
fi
BASIC_LIST="cmake \
gcc \
gcc-c++ \
flex \
python3 \
desktop-file-utils \
git \
glib2-devel \
libpcap-devel \
pcre2-devel \
zlib-devel \
libgcrypt-devel"
ADDITIONAL_LIST="libcap-devel \
libssh-devel \
krb5-devel \
perl-Parse-Yapp \
snappy-devel \
minizip-devel \
lz4 \
libxml2-devel \
perl \
spandsp-devel \
systemd-devel \
python3-pytest \
python3-pytest-xdist"
# Uncomment to add PNG compression utilities used by compress-pngs:
# ADDITIONAL_LIST="$ADDITIONAL_LIST \
# advancecomp \
# optipng \
# oxipng \
# pngcrush"
# XXX
RPMDEPS_LIST="rpm-build"
# Guess which package manager we will use
for PM in zypper dnf yum ''; do
if type "$PM" >/dev/null 2>&1; then
break
fi
done
if [ -z $PM ]
then
echo "No package managers found, exiting"
exit 1
fi
PM_OPT=
case $PM in
zypper)
PM_OPT="--non-interactive"
PM_SEARCH="search -x --provides"
;;
dnf)
PM_SEARCH="info"
;;
yum)
PM_SEARCH="info"
;;
esac
echo "Using $PM ($PM_SEARCH)"
# Adds package $2 to list variable $1 if the package is found
add_package() {
local list="$1" pkgname="$2"
# fail if the package is not known
$PM $PM_SEARCH "$pkgname" &> /dev/null || return 1
# package is found, append it to list
eval "${list}=\"\${${list}} \${pkgname}\""
}
# Adds packages $2-$n to list variable $1 if all the packages are found
add_packages() {
local list="$1" pkgnames="${@:2}"
# fail if any package is not known
for pkgname in $pkgnames; do
$PM $PM_SEARCH "$pkgname" &> /dev/null || return 1
done
# all packages are found, append it to list
eval "${list}=\"\${${list}} \${pkgnames}\""
}
add_package BASIC_LIST glib2 || add_package BASIC_LIST libglib-2_0-0 ||
echo "Required package glib2|libglib-2_0-0 is unavailable" >&2
# lua51, lua51-devel: OpenSUSE Leap 42.3 (lua would be fine too, as it installs lua52), OpenSUSE Leap 15.0 (lua installs lua53, so it wouldn't work)
# compat-lua, compat-lua-devel: Fedora 28, Fedora 29, CentOS 8
# lua, lua-devel: CentOS 7
add_package BASIC_LIST lua51-devel || add_package BASIC_LIST compat-lua-devel || add_package BASIC_LIST lua-devel ||
echo "Required package lua51-devel|compat-lua-devel|lua-devel is unavailable" >&2
add_package BASIC_LIST lua51 || add_package BASIC_LIST compat-lua || add_package BASIC_LIST lua ||
echo "Required package lua51|compat-lua|lua is unavailable" >&2
add_package BASIC_LIST libpcap || add_package BASIC_LIST libpcap1 ||
echo "Required package libpcap|libpcap1 is unavailable" >&2
add_package BASIC_LIST zlib || add_package BASIC_LIST libz1 ||
echo "Required package zlib|libz1 is unavailable" >&2
add_package BASIC_LIST c-ares-devel || add_package BASIC_LIST libcares-devel ||
echo "Required package c-ares-devel|libcares-devel is unavailable" >&2
add_package BASIC_LIST speexdsp-devel || add_package BASIC_LIST speex-devel ||
echo "Required package speexdsp-devel|speex-devel is unavailable" >&2
if [ $HAVE_ADD_QT -eq 0 ]
then
# Try to select Qt version from distro
test -e /etc/os-release && os_release='/etc/os-release' || os_release='/usr/lib/os-release'
# shellcheck disable=SC1090
. "${os_release}"
# Fedora 35 or later
if [ "${ID:-linux}" = "fedora" ] && [ "${VERSION_ID:-0}" -ge "35" ]; then
echo "Installing Qt6."
ADD_QT6=1
else
echo "Installing Qt5."
ADD_QT5=1
fi
fi
if [ $ADD_QT5 -ne 0 ]
then
# qt5-linguist: CentOS, Fedora
# libqt5-linguist-devel: OpenSUSE
add_package BASIC_LIST qt5-linguist ||
add_package BASIC_LIST libqt5-linguist-devel ||
echo "Required package qt5-linguist|libqt5-linguist-devel is unavailable" >&2
# qt5-qtmultimedia: CentOS, Fedora, pulls in qt5-qtbase-devel (big dependency list!)
# libqt5-qtmultimedia-devel: OpenSUSE, pulls in Core, Gui, Multimedia, Network, Widgets
# OpenSUSE additionally has a separate Qt5PrintSupport package.
add_package BASIC_LIST qt5-qtmultimedia-devel ||
add_packages BASIC_LIST libqt5-qtmultimedia-devel libQt5PrintSupport-devel ||
echo "Required Qt5 Mutlimedia and/or Qt5 Print Support is unavailable" >&2
# This in only required on OpenSUSE
add_package BASIC_LIST libqt5-qtsvg-devel ||
echo "Required OpenSUSE package libqt5-qtsvg-devel is unavailable. Not required for other distributions." >&2
# This in only required on OpenSUSE
add_package BASIC_LIST libQt5Concurrent-devel ||
echo "Required OpenSUSE package libQt5Concurrent-devel is unavailable. Not required for other distributions." >&2
add_package ADDITIONAL_LIST qt5-qtimageformats ||
add_package ADDITIONAL_LIST libqt5-qtimageformats ||
echo "Optional Qt5 Image Formats is unavailable" >&2
fi
if [ $ADD_QT6 -ne 0 ]
then
# Fedora Qt6 packages required from a minimal installation
QT6_LIST=(qt6-qtbase-devel
qt6-qttools-devel
qt6-qt5compat-devel
qt6-qtmultimedia-devel
libxkbcommon-devel)
for pkg in ${QT6_LIST[@]}
do
add_package BASIC_LIST "$pkg" ||
echo "Qt6 dependency $pkg is unavailable" >&2
done
add_package ADDITIONAL_LIST qt6-qtimageformats ||
echo "Optional Qt6 Image Formats is unavailable" >&2
fi
# This in only required on OpenSUSE
add_packages BASIC_LIST hicolor-icon-theme xdg-utils ||
echo "Required OpenSUSE packages hicolor-icon-theme and xdg-utils are unavailable. Not required for other distirbutions." >&2
# This in only required (and available) on OpenSUSE
add_package BASIC_LIST update-desktop-files ||
echo "Required OpenSUSE package update-desktop-files is unavailable. Not required for other distributions." >&2
# rubygem-asciidoctor.noarch: Centos, Fedora
# (Added to RHEL/Centos 8: https://bugzilla.redhat.com/show_bug.cgi?id=1820896 )
# ruby2.5-rubygem-asciidoctor: openSUSE 15.2
add_package RPMDEPS_LIST rubygem-asciidoctor.noarch || add_package RPMDEPS_LIST ruby2.5-rubygem-asciidoctor ||
echo "RPM dependency asciidoctor is unavailable" >&2
# libcap: CentOS 7, Fedora 28, Fedora 29
# libcap2: OpenSUSE Leap 42.3, OpenSUSE Leap 15.0
add_package ADDITIONAL_LIST libcap || add_package ADDITIONAL_LIST libcap2 ||
echo "Optional package libcap|libcap2 is unavailable" >&2
add_package ADDITIONAL_LIST nghttp2-devel || add_package ADDITIONAL_LIST libnghttp2-devel ||
echo "Optional package nghttp2-devel|libnghttp2-devel is unavailable" >&2
add_package ADDITIONAL_LIST snappy || add_package ADDITIONAL_LIST libsnappy1 ||
echo "Optional package snappy|libsnappy1 is unavailable" >&2
add_package ADDITIONAL_LIST libzstd-devel || echo "Optional package lbzstd-devel is unavailable" >&2
add_package ADDITIONAL_LIST lz4-devel || add_package ADDITIONAL_LIST liblz4-devel ||
echo "Optional package lz4-devel|liblz4-devel is unavailable" >&2
add_package ADDITIONAL_LIST libcap-progs || echo "Optional package libcap-progs is unavailable" >&2
add_package ADDITIONAL_LIST libmaxminddb-devel ||
echo "Optional package libmaxminddb-devel is unavailable" >&2
add_package ADDITIONAL_LIST gnutls-devel || add_package ADDITIONAL_LIST libgnutls-devel ||
echo "Optional package gnutls-devel|libgnutls-devel is unavailable" >&2
add_package ADDITIONAL_LIST gettext-devel || add_package ADDITIONAL_LIST gettext-tools ||
echo "Optional package gettext-devel|gettext-tools is unavailable" >&2
add_package ADDITIONAL_LIST ninja || add_package ADDITIONAL_LIST ninja-build ||
echo "Optional package ninja|ninja-build is unavailable" >&2
add_package ADDITIONAL_LIST libxslt || add_package ADDITIONAL_LIST libxslt1 ||
echo "Optional package libxslt|libxslt1 is unavailable" >&2
add_package ADDITIONAL_LIST docbook-style-xsl || add_package ADDITIONAL_LIST docbook-xsl-stylesheets ||
echo "Optional package docbook-style-xsl|docbook-xsl-stylesheets is unavailable" >&2
add_package ADDITIONAL_LIST brotli-devel || add_packages ADDITIONAL_LIST libbrotli-devel libbrotlidec1 ||
echo "Optional packages brotli-devel|libbrotli-devel is unavailable" >&2
add_package ADDITIONAL_LIST libnl3-devel || add_package ADDITIONAL_LIST libnl-devel ||
echo "Optional package libnl3-devel|libnl-devel are unavailable" >&2
add_package ADDITIONAL_LIST ilbc-devel ||
echo "Optional package ilbc-devel is unavailable" >&2
# opus-devel: RHEL/CentOS, Fedora
# libopus-devel: OpenSUSE
add_package ADDITIONAL_LIST opus-devel || add_package ADDITIONAL_LIST libopus-devel ||
echo "Optional package opus-devel|libopus-devel is unavailable" >&2
add_package ADDITIONAL_LIST bcg729-devel ||
echo "Optional package bcg729-devel is unavailable" >&2
# RHEL 8 / CentOS 8 are missing the -devel packages for sbc and libsmi due to
# RH deciding not to ship all -devel packages.
# https://wiki.centos.org/FAQ/CentOS8/UnshippedPackages
# There are CentOS bugs filed to add them to the Devel repository and eventually
# RHEL 8 CRB / CentOS PowerTools, but make them optional for now.
# https://bugs.centos.org/view.php?id=16504
# https://bugs.centos.org/view.php?id=17824
add_package ADDITIONAL_LIST sbc-devel ||
echo "Optional package sbc-devel is unavailable"
add_package ADDITIONAL_LIST libsmi-devel ||
echo "Optional package libsmi-devel is unavailable"
add_package ADDITIONAL_LIST opencore-amr-devel ||
echo "Optional package opencore-amr-devel is unavailable" >&2
ACTUAL_LIST=$BASIC_LIST
# Now arrange for optional support libraries
if [ $ADDITIONAL -ne 0 ]
then
ACTUAL_LIST="$ACTUAL_LIST $ADDITIONAL_LIST"
fi
if [ $RPMDEPS -ne 0 ]
then
ACTUAL_LIST="$ACTUAL_LIST $RPMDEPS_LIST"
fi
$PM $PM_OPT install $ACTUAL_LIST $OPTIONS
if [ $ADDITIONAL -eq 0 ]
then
echo -e "\n*** Optional packages not installed. Rerun with --install-optional to have them.\n"
fi
if [ $RPMDEPS -eq 0 ]
then
printf "\n*** RPM packages build deps not installed. Rerun with --install-rpm-deps to have them.\n"
fi
|