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
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.
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"
41 OPTIONS
="$OPTIONS $arg"
46 # Check if the user is root
47 if [ "$(id -u)" -ne 0 ]
49 echo "You must be root."
71 # Uncomment to add PNG compression utilities used by compress-pngs:
72 # ADDITIONAL_LIST="$ADDITIONAL_LIST \
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
)
83 PM_SEARCH
="pkgin search"
88 PM_SEARCH
="pkg search"
99 echo "Using $PM ($PM_SEARCH)"
101 # Adds package $2 to list variable $1 if the package is found
103 # shellcheck disable=SC3043
104 local list
="$1" pkgname
="$2"
106 # fail if the package is not known
107 if [ "$PM_MUST_GLOB" = yes ]
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
122 $PM_SEARCH "$pkgname" > /dev
/null
2>&1 ||
return 1
125 # package is found, append it to list
126 eval "${list}=\"\${${list}} \${pkgname}\""
131 add_package BASIC_LIST pkg-config ||
132 add_package BASIC_LIST pkgconf ||
133 echo "pkg-config is unavailable"
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"
147 add_package ADDITIONAL_LIST liblz4 ||
148 add_package ADDITIONAL_LIST lz4 ||
149 echo "lz4 is unavailable"
151 # libnghttp2: FreeBSD
153 add_package ADDITIONAL_LIST libnghttp2 ||
154 add_package ADDITIONAL_LIST nghttp2 ||
155 echo "nghttp2 is unavailable"
157 # libnghttp3: FreeBSD
159 add_package ADDITIONAL_LIST libnghttp3 ||
160 add_package ADDITIONAL_LIST nghttp3 ||
161 echo "nghttp3 is unavailable"
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"
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.
189 add_package ADDITIONAL_LIST libgcrypt ||
echo "libgcrypt is unavailable"
193 ACTUAL_LIST
=$BASIC_LIST
195 # Now arrange for optional support libraries
196 if [ $ADDITIONAL -ne 0 ]
198 ACTUAL_LIST
="$ACTUAL_LIST $ADDITIONAL_LIST"
201 # shellcheck disable=SC2086
202 $PM $PM_OPTIONS $ACTUAL_LIST $OPTIONS
208 if [ $ADDITIONAL -eq 0 ]
210 printf "\\n*** Optional packages not installed. Rerun with --install-optional to have them.\\n"