-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepare.sh
executable file
·67 lines (63 loc) · 1.6 KB
/
prepare.sh
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
#!/bin/bash
set -o nounset -o pipefail -o errexit
SUDO=${SUDO-}
DISTRO=${DISTRO-}
UPDATE=${UPDATE-}
TESTS=${TESTS-}
while getopts "ud:sS:t-" OPT; do
case $OPT in
d) DISTRO=$OPTARG ;;
u) UPDATE=1 ;;
s) SUDO=sudo ;;
S) SUDO=$OPTARG ;;
t) TESTS=1 ;;
-) break ;;
?) usage 2 ;;
esac
done
shift $((OPTIND-1))
if [ -z "$DISTRO" ]; then
if command -v lsb_release >/dev/null; then
DISTRO=$(lsb_release -is)
elif command -v pacman >/dev/null; then
DISTRO="Arch"
elif command -v apt-get >/dev/null; then
# TODO: debian
DISTRO="Ubuntu"
else
echo "unable to figure out distribution: $DISTRO" 1>&2
exit 1
fi
fi
echo "distro: $DISTRO" 1>&2
if [ "$DISTRO" = "Arch" ] || command -v pacman >/dev/null; then
if [ -n "$UPDATE" ]; then
$SUDO pacman -Sy 1>&2
fi
PKGs=(git)
PKGs+=(make gcc pkgconf)
PKGs+=(python gawk)
PKGs+=(lua libxrandr)
if [ -n "$TESTS" ]; then
PKGs+=(xorg-server-xvfb)
fi
$SUDO pacman -S --noconfirm "${PKGs[@]}" 1>&2
elif [ "$DISTRO" = "Ubuntu" ] || command -v apt-get >/dev/null; then
if [ -n "$UPDATE" ]; then
$SUDO apt-get update 1>&2
fi
PKGs=(git ca-certificates)
PKGs+=(make gcc pkg-config)
PKGs+=(python3 gawk)
PKGs+=(liblua5.4-dev libxrandr-dev)
if [ -n "$TESTS" ]; then
PKGs+=(xvfb)
fi
$SUDO apt-get install --yes \
--no-install-recommends --no-install-suggests \
1>&2 "${PKGs[@]}"
echo "LUA_PKG=lua54"
else
echo "unconfigured distribution: $DISTRO" 1>&2
exit 1
fi