Skip to content

Commit f33d0d4

Browse files
authored
Fix gcc install check. (#122)
1 parent e15cd28 commit f33d0d4

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Diff for: setup-fortran.sh

+11-2
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,23 @@ install_gcc_brew()
4545

4646
install_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

0 commit comments

Comments
 (0)