-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathDEPENDENCIES
executable file
·137 lines (114 loc) · 5.24 KB
/
DEPENDENCIES
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/bash
# Dependencies installation script for Goby
if [[ $UID -ne 0 ]]; then printf "You must run this script as root. Use 'sudo' in Ubuntu. \n" 1>&2; exit 1; fi
usage()
{
echo -e "Usage: DEPENDENCIES script"
echo -e "\t$0 [options]"
echo -e ""
echo -e "Purpose: this script installs dependencies for building Goby3 using the Debian and Ubuntu packages provided in packages.gobysoft.org"
echo -e ""
echo -e "Example (without arguments, this script installs the minimum dependencies required for building the core Goby3 code from packages.gobysoft.org/{ubuntu|debian}/release):"
echo -e "\t$0"
echo -e ""
echo -e ""
echo -e "Options:"
echo -e "\t-h\t\tShow help."
echo -e "\t-g\t\tAlso install GUI-related dependencies"
echo -e "\t-m\t\tAlso install MOOS-related dependencies"
echo -e "\t-a\t\tAlso install all dependencies used to build the code in the Debian package (apt-get build-dep goby3 --arch-only)."
echo -e "\t-d\t\tAlso install dependencies for building documentation (apt-get build-dep goby3 --indep-only)"
echo -e "\t-c\t\tUse 'continuous' series on packages.gobysoft.org instead of 'release' when resolving and installing dependencies"
}
fail()
{
echo "Your operating system and/or release version is not supported by this script."
echo -e "Please read the 'Build-Depends:' list from\n\thttps://github.com/GobySoft/goby-debian/blob/3.0/control\nto access the current list of Goby3 build dependences for Debian/Ubuntu. You can use this list to help find the correct dependencies for your operating system"
exit 1
}
validate_url()
{
if [[ `wget -S --spider $1 2>&1 | grep 'HTTP/1.1 200 OK'` ]];
then return 0;
else return 1;
fi
}
# sets list of dependencies for the package in $DEPENDS_RETVAL
DEPENDS_RETVAL=
depends()
{
DEPENDS_RETVAL=$(apt-cache depends $1 | egrep "Depends|Recommends" | egrep --invert-match libgoby3-dev | egrep --invert-match "<.*>|dccl3" | sed 's/.*: //' | tr '\r\n' ' ')
}
PACKAGE_SERIES=release
INSTALL_ALL_DEPENDS=false
INSTALL_DOC_DEPENDS=false
INSTALL_MOOS_DEPENDS=false
INSTALL_GUI_DEPENDS=false
while getopts ":hdcgma" opt; do
case $opt in
h) usage; exit 1 ;;
c) PACKAGE_SERIES=continuous ;;
g) INSTALL_GUI_DEPENDS=true ;;
m) INSTALL_MOOS_DEPENDS=true ;;
a) INSTALL_ALL_DEPENDS=true ;;
d) INSTALL_DOC_DEPENDS=true ;;
\?)
echo "Invalid option: -$OPTARG. For help use -h."
exit 1
;;
:)
echo "Option -$OPTARG requires an argument. For help use -h."
exit 1
esac
done
echo "==== Determining Operating System and Release ===="
OS_RELEASE_FILE=/etc/os-release
[ -z ${OS_RELEASE_FILE} ] && echo "Could not find ${OS_RELEASE_FILE} file to auto-detect operating system ID and version" && fail
# detect distro ID (e.g. "debian")
OS_ID=$(egrep "^ID=" ${OS_RELEASE_FILE} | cut -d = -f 2)
if [[ "$OS_ID" == raspbian ]]; then
OS_ID=debian
fi
case $OS_ID in
ubuntu)
RELEASE_CODENAME=$(egrep "^VERSION_CODENAME=" ${OS_RELEASE_FILE} | cut -d = -f 2)
;;
debian)
RELEASE_CODENAME=$(egrep "^VERSION=" ${OS_RELEASE_FILE} | sed 's/^.*(\([a-z]*\)).*$/\1/')
;;
*)
fail
;;
esac
case $OS_ID in
ubuntu|debian)
echo "Operating System: $OS_ID"
echo "Release: $RELEASE_CODENAME"
echo "==== Installing packages required to run this script ==="
(set -x; apt-get update -qq && apt-get -y install wget dirmngr apt-transport-https)
PACKAGES_URL_BASE="https://packages.gobysoft.org/${OS_ID}/${PACKAGE_SERIES}/"
echo "==== Checking dependencies for your OS (${OS_ID}) and release (${RELEASE_CODENAME}) on packages.gobysoft.org ===="
if validate_url ${PACKAGES_URL_BASE}/${RELEASE_CODENAME}/Release; then
echo "Release codename found"
echo "==== Adding packages.gobysoft.org Debian repository ===="
(set -x; echo -e "deb ${PACKAGES_URL_BASE} ${RELEASE_CODENAME}/\ndeb-src ${PACKAGES_URL_BASE} ${RELEASE_CODENAME}/" > /etc/apt/sources.list.d/gobysoft_${PACKAGE_SERIES}.list && \
apt-key adv --recv-key --keyserver keyserver.ubuntu.com 19478082E2F8D3FE &&
apt-get update -qq)
else
echo "Release codename not found on packages.gobysoft.org."
fail
fi
echo "==== Installing dependencies ===="
depends "libgoby3-dev"
(set -x; apt-get install --install-recommends -y cmake build-essential $DEPENDS_RETVAL)
# install clang if GCC is less than 7.2
dpkg --compare-versions `dpkg-query --showformat='${Version}' --show gcc` ">=" 4:7.2~ || (set -x; echo "Installing clang as your GCC version is less than 7.2"; apt-get install clang)
[[ "${INSTALL_MOOS_DEPENDS}" == "true" ]] && (depends "libgoby3-moos-dev"; set -x; apt-get install $DEPENDS_RETVAL)
[[ "${INSTALL_GUI_DEPENDS}" == "true" ]] && (depends "libgoby3-gui-dev"; set -x; apt-get install $DEPENDS_RETVAL)
[[ "${INSTALL_DOC_DEPENDS}" == "true" ]] && (set -x; apt-get build-dep goby3 --indep-only)
[[ "${INSTALL_ALL_DEPENDS}" == "true" ]] && (set -x; apt-get build-dep goby3 --arch-only)
;;
*)
fail
;;
esac