File tree 1 file changed +11
-2
lines changed
1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -45,14 +45,23 @@ install_gcc_brew()
45
45
46
46
install_gcc_apt ()
47
47
{
48
- # check if gcc preinstalled via apt
48
+ # Check whether the system gcc version is the version we are after.
49
49
cur=$( apt show gcc | grep " Version" | cut -d' :' -f3 | cut -d' -' -f1)
50
50
maj=$( echo $cur | cut -d' .' -f1)
51
+ needs_install=1
51
52
if [ " $maj " == " $version " ]; then
52
- echo " GCC $version already installed"
53
+ # Check whether that version is installed.
54
+ if apt list --installed gcc-${version} | grep -q " gcc-${version} /" ; then
55
+ echo " GCC $version already installed"
56
+ needs_install=0
57
+ fi
53
58
else
59
+ # Install the PPA for installing other versions of gcc.
54
60
sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test
55
61
sudo apt-get update
62
+ fi
63
+
64
+ if [ " ${needs_install} " == " 1" ]; then
56
65
sudo apt-get install -y gcc-${version} gfortran-${version} g++-${version}
57
66
fi
58
67
You can’t perform that action at this time.
0 commit comments