-
Notifications
You must be signed in to change notification settings - Fork 26
/
install.sh
executable file
·56 lines (47 loc) · 1.79 KB
/
install.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
#! /usr/bin/env bash
set -e
# Ensure we're in this feature's directory during build
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )";
# install global/common scripts
. ./common/install.sh;
check_packages \
gpg \
dirmngr \
gpg-agent \
apt-utils \
gettext-base \
ca-certificates \
bash-completion \
gcc g++ gfortran \
apt-transport-https \
software-properties-common \
;
GCC_VERSION_DEFAULT="$(gcc -dumpversion)";
GCC_VERSION="${VERSION:-${GCC_VERSION_DEFAULT}}";
if [[ "${GCC_VERSION}" != "${GCC_VERSION_DEFAULT}" ]]; then
apt-add-repository -y ppa:ubuntu-toolchain-r/test;
apt-add-repository -y ppa:ubuntu-toolchain-r/ppa;
# Install gcc-${GCC_VERSION}
DEBIAN_FRONTEND=noninteractive \
apt-get install -y --no-install-recommends \
{gcc,g++,gfortran}-${GCC_VERSION} \
;
# Install gcc/g++ alternatives
update-alternatives \
--install /usr/bin/gcc gcc $(which gcc-${GCC_VERSION}) 30 \
--slave /usr/bin/g++ g++ $(which g++-${GCC_VERSION}) \
--slave /usr/bin/gcov gcov $(which gcov-${GCC_VERSION}) \
--slave /usr/bin/gfortran gfortran $(which gfortran-${GCC_VERSION}) \
;
fi
export GCC_VERSION;
# export envvars in bashrc files
append_to_etc_bashrc "$(cat .bashrc | envsubst)";
append_to_all_bashrcs "$(cat .bashrc | envsubst)";
# export envvars in /etc/profile.d
add_etc_profile_d_script gcc "$(cat .bashrc | envsubst)";
# Clean up
# rm -rf /tmp/*;
rm -rf /var/tmp/*;
rm -rf /var/cache/apt/*;
rm -rf /var/lib/apt/lists/*;