xref: /aosp_15_r20/external/pytorch/.ci/docker/common/install_gcc.sh (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1#!/bin/bash
2
3set -ex
4
5if [ -n "$GCC_VERSION" ]; then
6
7  # Need the official toolchain repo to get alternate packages
8  add-apt-repository ppa:ubuntu-toolchain-r/test
9  apt-get update
10  apt-get install -y g++-$GCC_VERSION
11  update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-"$GCC_VERSION" 50
12  update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-"$GCC_VERSION" 50
13  update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-"$GCC_VERSION" 50
14
15
16  # Cleanup package manager
17  apt-get autoclean && apt-get clean
18  rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
19
20fi
21