-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall_dependencies.sh
executable file
·97 lines (84 loc) · 2.91 KB
/
install_dependencies.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
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
#!/bin/bash
# This script installs all necessary apt, llvm, and cmake dependencies required for any daemon/non-daemon x86/aarch64 build configuration
# Lots of neat version checking tricks stolen from llvm.sh
# -e: exit early on any failure
# -u: treat unset shell variables as an error when substituting
# -x: echo commands as they're executed
set -eux
# Funny enough we have the same required binaries as LLVM
needed_binaries=(lsb_release wget add-apt-repository)
missing_binaries=()
for binary in "${needed_binaries[@]}"; do
if ! which $binary &>/dev/null ; then
missing_binaries+=($binary)
fi
done
if [[ ${#missing_binaries[@]} -gt 0 ]] ; then
echo "You are missing some tools this script requires: ${missing_binaries[@]}"
echo "I'm going to install them now..."
apt update
apt install -y lsb-release wget software-properties-common
fi
DISTRO=$(lsb_release -is)
VERSION=$(lsb_release -sr)
DIST_VERSION="${DISTRO}_${VERSION}"
DIST_CODENAME=$(lsb_release -sc)
GCC_VERSION=7
GSL_VERSION=23
case "${DIST_VERSION}" in
Ubuntu_16.04 ) GCC_VERSION=5; GSL_VERSION=23 ;;
Ubuntu_18.04 ) GCC_VERSION=7; GSL_VERSION=23 ;;
Ubuntu_20.04 ) GCC_VERSION=10; GSL_VERSION=23 ;;
Ubuntu_22.04 ) GCC_VERSION=11; GSL_VERSION=27 ;;
* )
echo "[WARNING] - this installation script has not been tested with this particular distro/version (${DIST_VERSION})"
# https://stackoverflow.com/a/1885534
read -p "Do you want to continue? (y/n) " -n 1 -r REPLY
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 0
fi
;;
esac
if [ "$EUID" -ne 0 ]; then
echo "Please run as root to enable package installation"
exit 1
fi
install_apt_development_dependencies() {
echo "Installing general development dependencies"
echo "Using GCC version: ${GCC_VERSION}"
apt update
apt install -y \
apt-transport-https \
gnupg2 \
curl \
unzip \
build-essential \
libpapi-dev \
tar \
vim \
gdb \
git \
g++-${GCC_VERSION} \
g++-${GCC_VERSION}-aarch64-linux-gnu \
gcc-${GCC_VERSION}-arm-linux-gnueabi \
libstdc++6-${GCC_VERSION}-dbg-arm64-cross \
zlib1g-dev
update-alternatives --install /usr/bin/aarch64-linux-gnu-g++ aarch64-linux-gnu-g++ /usr/bin/aarch64-linux-gnu-g++-${GCC_VERSION} 10
update-alternatives --install /usr/bin/aarch64-linux-gnu-gcc aarch64-linux-gnu-gcc /usr/bin/aarch64-linux-gnu-gcc-${GCC_VERSION} 10
}
install_updated_cmake() {
echo "Installing updated cmake"
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null
chmod 644 /etc/apt/trusted.gpg.d/kitware.gpg
apt-add-repository "deb https://apt.kitware.com/ubuntu/ ${DIST_CODENAME} main"
apt update
apt install -y cmake
}
install_libgsl() {
echo "Installing libgsl-dev"
apt install -y libgsl-dev libgsl${GSL_VERSION} libgslcblas0
}
install_apt_development_dependencies
install_updated_cmake
install_libgsl