File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -45,14 +45,23 @@ install_gcc_brew()
4545
4646install_gcc_apt ()
4747{
48- # check if gcc preinstalled via apt
48+ # Check whether the system gcc version is the version we are after.
4949 cur=$( apt show gcc | grep " Version" | cut -d' :' -f3 | cut -d' -' -f1)
5050 maj=$( echo $cur | cut -d' .' -f1)
51+ needs_install=1
5152 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
5358 else
59+ # Install the PPA for installing other versions of gcc.
5460 sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test
5561 sudo apt-get update
62+ fi
63+
64+ if [ " ${needs_install} " == " 1" ]; then
5665 sudo apt-get install -y gcc-${version} gfortran-${version} g++-${version}
5766 fi
5867
You can’t perform that action at this time.
0 commit comments