Revert "drsuapi_dissect_element_DsGetNCChangesCtr6TS_ctr6 dissect_krb5_PAC_NDRHEADERBLOB"
[wireshark-sm.git] / tools / bsd-setup.sh
blob2a48b28d8ab97e57af16cedc201a07582b1a2e98
1 #!/usr/bin/env sh
2 # Setup development environment on BSD-like platforms.
4 # Tested on: FreeBSD, OpenBSD, NetBSD.
6 # Wireshark - Network traffic analyzer
7 # By Gerald Combs <gerald@wireshark.org>
8 # Copyright 1998 Gerald Combs
10 # SPDX-License-Identifier: GPL-2.0-or-later
12 # We drag in tools that might not be needed by all users; it's easier
13 # that way.
15 # We do not use Bash as the shell for this script, and use the POSIX
16 # syntax for function definition rather than the
17 # "function <name>() { ... }" syntax, as FreeBSD 13, at least, does
18 # not have Bash, and its /bin/sh doesn't support the other syntax.
21 print_usage() {
22 printf "\\nUtility to setup a bsd-based system for Wireshark Development.\\n"
23 printf "The basic usage installs the needed software\\n\\n"
24 printf "Usage: %s [--install-optional] [...other options...]\\n" "$0"
25 printf "\\t--install-optional: install optional software as well\\n"
26 printf "\\t[other]: other options are passed as-is to pkg manager.\\n"
29 ADDITIONAL=0
30 OPTIONS=
31 for arg; do
32 case $arg in
33 --help)
34 print_usage
35 exit 0
37 --install-optional)
38 ADDITIONAL=1
41 OPTIONS="$OPTIONS $arg"
43 esac
44 done
46 # Check if the user is root
47 if [ "$(id -u)" -ne 0 ]
48 then
49 echo "You must be root."
50 exit 1
53 BASIC_LIST="\
54 cmake \
55 qt6 \
56 git \
57 pcre2 \
58 speexdsp"
60 ADDITIONAL_LIST="\
61 gettext-tools \
62 snappy \
63 bcg729 \
64 libssh \
65 libmaxminddb \
66 libsmi \
67 brotli \
68 zstd \
71 # Uncomment to add PNG compression utilities used by compress-pngs:
72 # ADDITIONAL_LIST="$ADDITIONAL_LIST \
73 # advancecomp \
74 # optipng \
75 # pngcrush"
77 # Guess which package manager we will use
78 PM=$( which pkgin 2> /dev/null || which pkg 2> /dev/null || which pkg_add 2> /dev/null )
80 case $PM in
81 */pkgin)
82 PM_OPTIONS="install"
83 PM_SEARCH="pkgin search"
84 PM_MUST_GLOB=no
86 */pkg)
87 PM_OPTIONS="install"
88 PM_SEARCH="pkg search"
89 PM_MUST_GLOB=yes
91 */pkg_add)
92 PM_OPTIONS=""
93 PM_SEARCH="pkg_info"
94 PM_MUST_GLOB=no
96 esac
99 echo "Using $PM ($PM_SEARCH)"
101 # Adds package $2 to list variable $1 if the package is found
102 add_package() {
103 # shellcheck disable=SC3043
104 local list="$1" pkgname="$2"
106 # fail if the package is not known
107 if [ "$PM_MUST_GLOB" = yes ]
108 then
110 # We need to do a glob search, with a "*" at the
111 # end, so we only find packages that *begin* with
112 # the name; otherwise, searching for pkg-config
113 # could find packages that *don't* begin with
114 # pkg-config, but have it later in the name
115 # (FreeBSD 11 has one such package), so when
116 # we then try to install it, that fails. Doing
117 # an *exact* search fails, as that requires that
118 # the package name include the version number.
120 $PM_SEARCH -g "$pkgname*" > /dev/null 2>&1 || return 1
121 else
122 $PM_SEARCH "$pkgname" > /dev/null 2>&1 || return 1
125 # package is found, append it to list
126 eval "${list}=\"\${${list}} \${pkgname}\""
129 # pkg-config: NetBSD
130 # pkgconf: FreeBSD
131 add_package BASIC_LIST pkg-config ||
132 add_package BASIC_LIST pkgconf ||
133 echo "pkg-config is unavailable"
135 # c-ares: FreeBSD
136 # libcares: OpenBSD
137 add_package BASIC_LIST c-ares ||
138 add_package BASIC_LIST libcares ||
139 echo "c-ares is unavailable"
141 # rubygem-asciidoctor: FreeBSD
142 add_package ADDITIONAL_LIST rubygem-asciidoctor ||
143 echo "asciidoctor is unavailable"
145 # liblz4: FreeBSD
146 # lz4: NetBSD
147 add_package ADDITIONAL_LIST liblz4 ||
148 add_package ADDITIONAL_LIST lz4 ||
149 echo "lz4 is unavailable"
151 # libnghttp2: FreeBSD
152 # nghttp2: NetBSD
153 add_package ADDITIONAL_LIST libnghttp2 ||
154 add_package ADDITIONAL_LIST nghttp2 ||
155 echo "nghttp2 is unavailable"
157 # libnghttp3: FreeBSD
158 # nghttp3: NetBSD
159 add_package ADDITIONAL_LIST libnghttp3 ||
160 add_package ADDITIONAL_LIST nghttp3 ||
161 echo "nghttp3 is unavailable"
163 # spandsp: NetBSD
164 add_package ADDITIONAL_LIST spandsp ||
165 echo "spandsp is unavailable"
167 # ninja: FreeBSD, OpenBSD
168 # ninja-build: NetBSD
169 add_package ADDITIONAL_LIST ninja-build ||
170 add_package ADDITIONAL_LIST ninja ||
171 echo "ninja is unavailable"
173 # libilbc: FreeBSD
174 add_package ADDITIONAL_LIST libilbc ||
175 echo "libilbc is unavailable"
177 # lua: OpenBSD latest (current 5.4)
178 # lua54: FreeBSD, NetBSD 5.4.x
179 # lua53 is also acceptable
180 add_package ADDITIONAL_LIST lua ||
181 add_package ADDITIONAL_LIST lua54 ||
182 add_package ADDITIONAL_LIST lua53 ||
183 echo "lua >= 5.3 is unavailable"
185 # Add OS-specific required/optional packages
186 # Those not listed don't require additions.
187 case $( uname ) in
188 FreeBSD | NetBSD)
189 add_package ADDITIONAL_LIST libgcrypt || echo "libgcrypt is unavailable"
191 esac
193 ACTUAL_LIST=$BASIC_LIST
195 # Now arrange for optional support libraries
196 if [ $ADDITIONAL -ne 0 ]
197 then
198 ACTUAL_LIST="$ACTUAL_LIST $ADDITIONAL_LIST"
201 # shellcheck disable=SC2086
202 $PM $PM_OPTIONS $ACTUAL_LIST $OPTIONS
203 if [ ! $? ]
204 then
205 exit 2
208 if [ $ADDITIONAL -eq 0 ]
209 then
210 printf "\\n*** Optional packages not installed. Rerun with --install-optional to have them.\\n"