Skip installing 'clang' if 'clang' binary already exists (#32242)

Simply installing 'clang' installs the default version of Clang for
Linux. For instance, the command: 'apt install clang' installs
'clang-14' in Ubuntu 22.04.

It might be possible that a more recent version of clang is
already installed in the system. For instance, package 'clang-17'.

In the case a 'clang' binary is already installed in the system, skip
the installation of 'clang'.
This commit is contained in:
Diego Pino 2024-05-08 06:13:24 +02:00 committed by GitHub
parent 6a2e4a61f7
commit 5298ccb0eb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -164,6 +164,11 @@ class Linux(Base):
command = ['apt-get', 'install', "-m"]
pkgs = APT_PKGS
# Skip 'clang' if 'clang' binary already exists.
result = subprocess.run(['which', 'clang'], capture_output=True)
if result and result.returncode == 0:
pkgs.remove('clang')
# Try to filter out unknown packages from the list. This is important for Debian
# as it does not ship all of the packages we want.
installable = subprocess.check_output(['apt-cache', '--generate', 'pkgnames'])