decryption works, but addid doesn't because of unique pointer layers
[wireshark-sm.git] / tools / debian-setup.sh
blob8fade5ac403be28361fd54e0fd76f4b6c618bf2e
1 #!/bin/bash
2 # Setup development environment on Debian and derivatives such as Ubuntu
4 # Wireshark - Network traffic analyzer
5 # By Gerald Combs <gerald@wireshark.org>
6 # Copyright 1998 Gerald Combs
8 # SPDX-License-Identifier: GPL-2.0-or-later
10 # We drag in tools that might not be needed by all users; it's easier
11 # that way.
14 set -e -u -o pipefail
16 function print_usage() {
17 printf "\\nUtility to setup a debian-based system for Wireshark Development.\\n"
18 printf "The basic usage installs the needed software\\n\\n"
19 printf "Usage: %s [--install-optional] [--install-deb-deps] [...other options...]\\n" "$0"
20 printf "\\t--install-optional: install optional software as well\\n"
21 printf "\\t--install-deb-deps: install packages required to build the .deb file\\n"
22 printf "\\t--install-test-deps: install packages required to run all tests\\n"
23 printf "\\t--install-qt5-deps: force installation of packages required to use Qt5\\n"
24 printf "\\t--install-qt6-deps: force installation of packages required to use Qt6\\n"
25 printf "\\t--install-all: install everything\\n"
26 printf "\\t[other]: other options are passed as-is to apt\\n"
29 # Adds package $2 to list variable $1 if the package is found.
30 # If $3 is given, then this version requirement must be satisfied.
31 function add_package() {
32 local list="$1" pkgname="$2" versionreq="${3:-}" version
34 version=$(apt-cache show "$pkgname" 2>/dev/null |
35 awk '/^Version:/{ print $2; exit}')
36 # fail if the package is not known
37 if [ -z "$version" ]; then
38 return 1
39 elif [ -n "$versionreq" ]; then
40 # Require minimum version or fail.
41 # shellcheck disable=SC2086
42 dpkg --compare-versions $version $versionreq || return 1
45 # package is found, append it to list
46 eval "${list}=\"\${${list}} \${pkgname}\""
49 ADDITIONAL=0
50 DEBDEPS=0
51 TESTDEPS=0
52 ADD_QT5=0
53 ADD_QT6=0
54 HAVE_ADD_QT=0
55 OPTIONS=
56 for arg; do
57 case $arg in
58 --help)
59 print_usage
60 exit 0
62 --install-optional)
63 ADDITIONAL=1
65 --install-deb-deps)
66 DEBDEPS=1
68 --install-test-deps)
69 TESTDEPS=1
71 --install-qt5-deps)
72 ADD_QT5=1
74 --install-qt6-deps)
75 ADD_QT6=1
77 --install-all)
78 ADDITIONAL=1
79 DEBDEPS=1
80 TESTDEPS=1
81 ADD_QT5=1
82 ADD_QT6=1
83 HAVE_ADD_QT=1
86 OPTIONS="$OPTIONS $arg"
88 esac
89 done
91 # Check if the user is root
92 if [ "$(id -u)" -ne 0 ]
93 then
94 echo "You must be root."
95 exit 1
98 BASIC_LIST="
99 cmake
100 flex
103 libc-ares-dev
104 libgcrypt-dev
105 libglib2.0-dev
106 libpcap-dev
107 libpcre2-dev
108 libspeexdsp-dev
109 make
110 python3
113 QT5_LIST="
114 libqt5svg5-dev
115 qt5-qmake
116 qtbase5-dev
117 qtbase5-dev-tools
118 qtchooser
119 qtmultimedia5-dev
120 qttools5-dev
121 qttools5-dev-tools
124 QT6_LIST="
125 freeglut3-dev
126 libqt6svg6-dev
127 libvulkan-dev
128 libxkbcommon-dev
129 qt6-base-dev
130 qt6-l10n-tools
131 qt6-multimedia-dev
132 qt6-tools-dev
133 qt6-tools-dev-tools
136 # qt6-5compat-dev: Debian >= bookworm, Ubuntu >= 23.04
137 # libqt6core5compat6-dev: Ubuntu 22.04
138 add_package QT6_LIST qt6-5compat-dev ||
139 QT6_LIST="$QT6_LIST libqt6core5compat6-dev"
141 if [ $ADD_QT5 -ne 0 ]
142 then
143 BASIC_LIST="$BASIC_LIST $QT5_LIST"
144 HAVE_ADD_QT=1
147 if [ $ADD_QT6 -ne 0 ]
148 then
149 BASIC_LIST="$BASIC_LIST $QT6_LIST"
150 HAVE_ADD_QT=1
153 if [ $HAVE_ADD_QT -eq 0 ]
154 then
155 # Try to select Qt version from distro
156 test -e /etc/os-release && os_release='/etc/os-release' || os_release='/usr/lib/os-release'
157 # shellcheck disable=SC1090
158 . "${os_release}"
160 # Ubuntu 22.04 (jammy) / Debian 12 (bookworm) or later
161 MAJOR=$(echo "$VERSION_ID" | cut -f1 -d.)
162 if [ "${ID:-linux}" = "ubuntu" ] && [ "${MAJOR:-0}" -ge "22" ]; then
163 echo "Installing Qt6."
164 BASIC_LIST="$BASIC_LIST $QT6_LIST"
165 elif [ "${ID:-linux}" = "debian" ] && [ "${MAJOR:-0}" -ge "12" ]; then
166 echo "Installing Qt6."
167 BASIC_LIST="$BASIC_LIST $QT6_LIST"
168 else
169 echo "Installing Qt5."
170 BASIC_LIST="$BASIC_LIST $QT5_LIST"
174 ADDITIONAL_LIST="
175 ccache
176 doxygen
178 libbrotli-dev
179 libcap-dev
180 libgnutls28-dev
181 libkrb5-dev
182 liblz4-dev
183 libmaxminddb-dev
184 libminizip-dev
185 libnghttp2-dev
186 libnl-3-dev
187 libnl-cli-3-dev
188 libopencore-amrnb-dev
189 libopus-dev
190 libparse-yapp-perl
191 libsbc-dev
192 libssh-gcrypt-dev
193 libsmi2-dev
194 libsnappy-dev
195 libspandsp-dev
196 libsystemd-dev
197 libxml2-dev
198 libzstd-dev
199 ninja-build
200 perl
201 xsltproc
204 # Uncomment to add PNG compression utilities used by compress-pngs:
205 # ADDITIONAL_LIST="
206 # $ADDITIONAL_LIST
207 # advancecomp
208 # optipng
209 # pngcrush
212 DEBDEPS_LIST="
213 asciidoctor
214 debhelper
215 dh-python
216 docbook-xml
217 docbook-xsl
218 libxml2-utils
219 lintian
220 lsb-release
221 po-debconf
222 python3-ply
223 quilt
226 TESTDEPS_LIST="
228 python3-pytest
229 python3-pytest-xdist
230 softhsm2
233 # apt-get update must be called before calling add_package
234 # otherwise available packages appear as unavailable
235 apt-get update || exit 2
237 # Lua 5.4: Debian >= bullseye, Ubuntu >= 22.04 (jammy)
238 # Lua 5.3: Debian >= buster, Ubuntu >= 20.04 (focal)
239 add_package ADDITIONAL_LIST liblua5.4-dev ||
240 ADDITIONAL_LIST="$ADDITIONAL_LIST liblua5.3-dev"
242 # Debian >= bookworm, Ubuntu >= 22.04
243 add_package ADDITIONAL_LIST libnghttp3-dev ||
244 echo "libnghttp3-dev is unavailable" >&2
246 # ilbc library from http://www.deb-multimedia.org
247 add_package ADDITIONAL_LIST libilbc-dev ||
248 echo "libilbc-dev is unavailable"
250 # Debian >= bullseye, Ubuntu >= 22.04 (jammy)
251 # bcg729 library libbcg729-dev
252 add_package ADDITIONAL_LIST libbcg729-dev ||
253 echo "libbcg729-dev is unavailable"
255 ACTUAL_LIST=$BASIC_LIST
257 # Now arrange for optional support libraries
258 if [ $ADDITIONAL -ne 0 ]
259 then
260 ACTUAL_LIST="$ACTUAL_LIST $ADDITIONAL_LIST"
263 if [ $DEBDEPS -ne 0 ]
264 then
265 ACTUAL_LIST="$ACTUAL_LIST $DEBDEPS_LIST"
268 if [ $TESTDEPS -ne 0 ]
269 then
270 ACTUAL_LIST="$ACTUAL_LIST $TESTDEPS_LIST"
273 # shellcheck disable=SC2086
274 apt-get install $ACTUAL_LIST $OPTIONS || exit 2
276 if [ $ADDITIONAL -eq 0 ]
277 then
278 printf "\n*** Optional packages not installed. Rerun with --install-optional to have them.\n"
281 if [ $DEBDEPS -eq 0 ]
282 then
283 printf "\n*** Debian packages build deps not installed. Rerun with --install-deb-deps to have them.\n"
286 if [ $TESTDEPS -eq 0 ]
287 then
288 printf "\n*** Test deps not installed. Rerun with --install-test-deps to have them.\n"