2021-11-14 19:31:25 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# Setup development environment on Arch Linux
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
|
2022-04-17 18:04:02 +00:00
|
|
|
set -e -u -o pipefail
|
|
|
|
|
Fix tools/*-setup.sh to work with no arguments
They were checking for --help in an unusual manner that failed when
run with no arguments.
I've checked that --help works for each script, and that debian-setup.sh
actually works.
NOTE: bsd-setup.sh and rpm-setup.sh seem to have sometimes-broken
formatting, because they try to pass escape sequences to echo, which
POSIX says is implementation-defined (except on XSI-conformant systems).
These changes were mostly made using the following script, with a
manual fix in bsd-setup.sh because it isn't using "switch case".
```python
#!/bin/env python3
import sys
import re
usage_p = re.compile(r'^if \[ "\$1" = "--help" \]\nthen\n((?:\t(?:printf|echo) .*\n)*)\texit 1\nfi$',
re.MULTILINE)
case_p = re.compile(r'(^\tcase \$arg in$)',
re.MULTILINE)
root_check_p = re.compile(r'(\n# Check if the user is root(?:\n|.)*?fi\n)',
re.MULTILINE)
done_p = re.compile(r'(^done\n)',
re.MULTILINE)
def fix_setup(name: str):
assert name.endswith('-setup.sh')
with open(name, 'r') as fin:
s = fin.read()
s = usage_p.sub(r'function print_usage() {\n\1}', s)
s = case_p.sub(r'''\1
\t\t--help)
\t\t\tprint_usage
\t\t\texit 0
\t\t\t;;''', s)
m1 = root_check_p.search(s)
if m1:
root_check = m1[0]
s = root_check_p.sub('', s)
pos = done_p.search(s).end() # type: ignore[union-attr]
s = s[:pos] + root_check + s[pos:]
with open(name, 'w') as fout:
fout.write(s)
if __name__ == '__main__':
for name in sys.argv[1:]:
fix_setup(name)
```
2022-04-17 22:25:57 +00:00
|
|
|
function print_usage() {
|
2021-11-14 19:31:25 +00:00
|
|
|
printf "\\nUtility to setup a pacman-based system for Wireshark development.\\n"
|
|
|
|
printf "The basic usage installs the needed software\\n\\n"
|
|
|
|
printf "Usage: %s [--install-optional] [...other options...]\\n" "$0"
|
|
|
|
printf "\\t--install-optional: install optional software as well\\n"
|
|
|
|
printf "\\t--install-test-deps: install packages required to run all tests\\n"
|
|
|
|
printf "\\t--install-all: install everything\\n"
|
|
|
|
printf "\\t[other]: other options are passed as-is to pacman\\n"
|
|
|
|
printf "\\tPass --noconfirm to bypass any \"are you sure?\" messages.\\n"
|
Fix tools/*-setup.sh to work with no arguments
They were checking for --help in an unusual manner that failed when
run with no arguments.
I've checked that --help works for each script, and that debian-setup.sh
actually works.
NOTE: bsd-setup.sh and rpm-setup.sh seem to have sometimes-broken
formatting, because they try to pass escape sequences to echo, which
POSIX says is implementation-defined (except on XSI-conformant systems).
These changes were mostly made using the following script, with a
manual fix in bsd-setup.sh because it isn't using "switch case".
```python
#!/bin/env python3
import sys
import re
usage_p = re.compile(r'^if \[ "\$1" = "--help" \]\nthen\n((?:\t(?:printf|echo) .*\n)*)\texit 1\nfi$',
re.MULTILINE)
case_p = re.compile(r'(^\tcase \$arg in$)',
re.MULTILINE)
root_check_p = re.compile(r'(\n# Check if the user is root(?:\n|.)*?fi\n)',
re.MULTILINE)
done_p = re.compile(r'(^done\n)',
re.MULTILINE)
def fix_setup(name: str):
assert name.endswith('-setup.sh')
with open(name, 'r') as fin:
s = fin.read()
s = usage_p.sub(r'function print_usage() {\n\1}', s)
s = case_p.sub(r'''\1
\t\t--help)
\t\t\tprint_usage
\t\t\texit 0
\t\t\t;;''', s)
m1 = root_check_p.search(s)
if m1:
root_check = m1[0]
s = root_check_p.sub('', s)
pos = done_p.search(s).end() # type: ignore[union-attr]
s = s[:pos] + root_check + s[pos:]
with open(name, 'w') as fout:
fout.write(s)
if __name__ == '__main__':
for name in sys.argv[1:]:
fix_setup(name)
```
2022-04-17 22:25:57 +00:00
|
|
|
}
|
2021-11-14 19:31:25 +00:00
|
|
|
|
|
|
|
ADDITIONAL=0
|
|
|
|
TESTDEPS=0
|
|
|
|
AUR=0
|
2022-04-10 22:40:36 +00:00
|
|
|
OPTIONS=
|
2021-11-14 19:31:25 +00:00
|
|
|
for arg; do
|
|
|
|
case $arg in
|
Fix tools/*-setup.sh to work with no arguments
They were checking for --help in an unusual manner that failed when
run with no arguments.
I've checked that --help works for each script, and that debian-setup.sh
actually works.
NOTE: bsd-setup.sh and rpm-setup.sh seem to have sometimes-broken
formatting, because they try to pass escape sequences to echo, which
POSIX says is implementation-defined (except on XSI-conformant systems).
These changes were mostly made using the following script, with a
manual fix in bsd-setup.sh because it isn't using "switch case".
```python
#!/bin/env python3
import sys
import re
usage_p = re.compile(r'^if \[ "\$1" = "--help" \]\nthen\n((?:\t(?:printf|echo) .*\n)*)\texit 1\nfi$',
re.MULTILINE)
case_p = re.compile(r'(^\tcase \$arg in$)',
re.MULTILINE)
root_check_p = re.compile(r'(\n# Check if the user is root(?:\n|.)*?fi\n)',
re.MULTILINE)
done_p = re.compile(r'(^done\n)',
re.MULTILINE)
def fix_setup(name: str):
assert name.endswith('-setup.sh')
with open(name, 'r') as fin:
s = fin.read()
s = usage_p.sub(r'function print_usage() {\n\1}', s)
s = case_p.sub(r'''\1
\t\t--help)
\t\t\tprint_usage
\t\t\texit 0
\t\t\t;;''', s)
m1 = root_check_p.search(s)
if m1:
root_check = m1[0]
s = root_check_p.sub('', s)
pos = done_p.search(s).end() # type: ignore[union-attr]
s = s[:pos] + root_check + s[pos:]
with open(name, 'w') as fout:
fout.write(s)
if __name__ == '__main__':
for name in sys.argv[1:]:
fix_setup(name)
```
2022-04-17 22:25:57 +00:00
|
|
|
--help)
|
|
|
|
print_usage
|
|
|
|
exit 0
|
|
|
|
;;
|
2021-11-14 19:31:25 +00:00
|
|
|
--install-optional)
|
|
|
|
ADDITIONAL=1
|
|
|
|
;;
|
|
|
|
--install-test-deps)
|
|
|
|
TESTDEPS=1
|
|
|
|
;;
|
|
|
|
--install-all)
|
|
|
|
ADDITIONAL=1
|
|
|
|
TESTDEPS=1
|
|
|
|
AUR=1
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
OPTIONS="$OPTIONS $arg"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
Fix tools/*-setup.sh to work with no arguments
They were checking for --help in an unusual manner that failed when
run with no arguments.
I've checked that --help works for each script, and that debian-setup.sh
actually works.
NOTE: bsd-setup.sh and rpm-setup.sh seem to have sometimes-broken
formatting, because they try to pass escape sequences to echo, which
POSIX says is implementation-defined (except on XSI-conformant systems).
These changes were mostly made using the following script, with a
manual fix in bsd-setup.sh because it isn't using "switch case".
```python
#!/bin/env python3
import sys
import re
usage_p = re.compile(r'^if \[ "\$1" = "--help" \]\nthen\n((?:\t(?:printf|echo) .*\n)*)\texit 1\nfi$',
re.MULTILINE)
case_p = re.compile(r'(^\tcase \$arg in$)',
re.MULTILINE)
root_check_p = re.compile(r'(\n# Check if the user is root(?:\n|.)*?fi\n)',
re.MULTILINE)
done_p = re.compile(r'(^done\n)',
re.MULTILINE)
def fix_setup(name: str):
assert name.endswith('-setup.sh')
with open(name, 'r') as fin:
s = fin.read()
s = usage_p.sub(r'function print_usage() {\n\1}', s)
s = case_p.sub(r'''\1
\t\t--help)
\t\t\tprint_usage
\t\t\texit 0
\t\t\t;;''', s)
m1 = root_check_p.search(s)
if m1:
root_check = m1[0]
s = root_check_p.sub('', s)
pos = done_p.search(s).end() # type: ignore[union-attr]
s = s[:pos] + root_check + s[pos:]
with open(name, 'w') as fout:
fout.write(s)
if __name__ == '__main__':
for name in sys.argv[1:]:
fix_setup(name)
```
2022-04-17 22:25:57 +00:00
|
|
|
# Check if the user is root
|
|
|
|
if [ "$(id -u)" -ne 0 ]
|
|
|
|
then
|
|
|
|
echo "You must be root."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-11-14 19:31:25 +00:00
|
|
|
BASIC_LIST="base-devel \
|
|
|
|
bcg729 \
|
|
|
|
brotli \
|
|
|
|
c-ares \
|
|
|
|
cmake \
|
|
|
|
git \
|
|
|
|
glib2 \
|
|
|
|
gnutls \
|
|
|
|
krb5 \
|
|
|
|
libcap \
|
|
|
|
libgcrypt \
|
|
|
|
libilbc \
|
|
|
|
libmaxminddb \
|
|
|
|
libnghttp2 \
|
|
|
|
libnl \
|
|
|
|
libpcap \
|
|
|
|
libssh \
|
|
|
|
libxml2 \
|
|
|
|
lua52 \
|
|
|
|
lz4 \
|
|
|
|
minizip \
|
|
|
|
ninja \
|
|
|
|
pcre2 \
|
|
|
|
python \
|
|
|
|
qt5-base \
|
|
|
|
qt5-multimedia \
|
|
|
|
qt5-tools \
|
|
|
|
sbc \
|
|
|
|
snappy \
|
|
|
|
spandsp \
|
|
|
|
speexdsp \
|
|
|
|
zlib \
|
|
|
|
zstd"
|
|
|
|
|
|
|
|
ADDITIONAL_LIST="asciidoctor \
|
|
|
|
ccache \
|
2021-12-31 02:08:44 +00:00
|
|
|
docbook-xml \
|
|
|
|
docbook-xsl \
|
2021-11-14 19:31:25 +00:00
|
|
|
doxygen \
|
2022-07-22 20:47:59 +00:00
|
|
|
libxslt \
|
|
|
|
perl"
|
2021-11-14 19:31:25 +00:00
|
|
|
|
|
|
|
TESTDEPS_LIST="python-pytest \
|
|
|
|
python-pytest-xdist"
|
|
|
|
|
|
|
|
ACTUAL_LIST=$BASIC_LIST
|
|
|
|
|
|
|
|
if [ $ADDITIONAL -ne 0 ]
|
|
|
|
then
|
|
|
|
ACTUAL_LIST="$ACTUAL_LIST $ADDITIONAL_LIST"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $TESTDEPS -ne 0 ]
|
|
|
|
then
|
|
|
|
ACTUAL_LIST="$ACTUAL_LIST $TESTDEPS_LIST"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Partial upgrades are unsupported.
|
2022-04-19 17:52:23 +00:00
|
|
|
pacman --sync --refresh --sysupgrade --needed $ACTUAL_LIST $OPTIONS || exit 2
|
2021-11-14 19:31:25 +00:00
|
|
|
|
|
|
|
if [ $ADDITIONAL -eq 0 ]
|
|
|
|
then
|
|
|
|
printf "\n*** Optional packages not installed. Rerun with --install-optional to have them.\n"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $TESTDEPS -eq 0 ]
|
|
|
|
then
|
|
|
|
printf "\n*** Test deps not installed. Rerun with --install-test-deps to have them.\n"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $AUR -ne 0 ]
|
|
|
|
then
|
|
|
|
printf "\n*** These and other packages may also be found in the AUR: libsmi.\n"
|
|
|
|
fi
|