-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdependencies.sh
More file actions
executable file
·72 lines (54 loc) · 1.28 KB
/
dependencies.sh
File metadata and controls
executable file
·72 lines (54 loc) · 1.28 KB
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
68
69
70
71
72
#!/bin/bash
set -e
self=${0##*/}
USER=$( id -u -n )
SUDO=
[ $USER = root ] || SUDO=sudo
die() { echo >&2 "ERROR: $*" ; exit 1 ; }
YES=
show_help() {
cat <<END
$self ...
-h this help
-y answer yes to package manager questions
gcc use gcc as the compiler
clang use clang as the compiler
END
}
while [ -n "$1" ] ; do
case "$1" in
-h|--help)
show_help
exit 0
;;
-y|--yes)
YES=-y
;;
gcc|clang)
CC=$1
;;
*)
die "invalid option $1"
;;
esac
shift
done
run() { echo >&2 "# $@" ; $SUDO "$@" ; }
say() { echo >&2 "$@" ; }
die() { echo >&2 "$@" ; exit 1 ; }
if [ -s /etc/redhat-release ]; then
die "RHEL/CentOS not yet supported"
elif [ -f /etc/SuSE-release ] || [ -f /etc/SUSE-brand ]; then
die "SuSE not yet supported"
elif [ -f /etc/debian_version ]; then
say "Installing Debian/Ubuntu dependencies"
compiler=()
case "$CC" in
*gcc*) compiler=( gcc g++ ) ;;
*clang*) compiler=( clang ) ;;
*) compiler=( gcc g++ clang ) ;;
esac
run apt install $YES make ninja-build cmake libglib2.0-dev git libgtest-dev "${compiler[@]}"
else
die "Distribution is not handled"
fi