From: Dan Mick Date: Sun, 19 Oct 2025 00:45:31 +0000 (-0700) Subject: install-deps.sh: install proper compiler version on Debian/Ubuntu X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fd19a09e02b4506d40b24c5044224747f6a49bf3;p=ceph.git install-deps.sh: install proper compiler version on Debian/Ubuntu This code used to run in a pbuilder hook (because it needed to run inside the build environment chroot). When building in a container, you also want the right compiler installed. This is necessary at least to build reef on ubuntu focal. Fixes: https://tracker.ceph.com/issues/73585 Signed-off-by: Dan Mick --- diff --git a/install-deps.sh b/install-deps.sh index af060baab962..003867351330 100755 --- a/install-deps.sh +++ b/install-deps.sh @@ -94,6 +94,28 @@ msyaQpNl/m/lNtOLhR64v5ZybofB2EWkMxUzX8D/FQ== ENDOFKEY $SUDO env DEBIAN_FRONTEND=noninteractive apt-get update -y || true $SUDO env DEBIAN_FRONTEND=noninteractive apt-get install -y g++-${new} + + # From ceph-build.git:src/scripts/build_utils.sh:setup_gcc_hook. + # Do this here instead of in the hook when running in a container + # (like build-with-container.py). Test if pid1 is init or systemd. + + if ! ps -p 1 -o comm= | grep -qE "init|systemd"; then + $SUDO update-alternatives --remove-all gcc + + $SUDO update-alternatives \ + --install /usr/bin/gcc gcc /usr/bin/gcc-${new} 20 \ + --slave /usr/bin/g++ g++ /usr/bin/g++-${new} + + $SUDO update-alternatives \ + --install /usr/bin/gcc gcc /usr/bin/gcc-\${old} 10 \ + --slave /usr/bin/g++ g++ /usr/bin/g++-\${old} + + $SUDO update-alternatives --auto gcc + + # cmake uses the latter by default + $SUDO ln -nsf /usr/bin/gcc /usr/bin/\${ARCH}-linux-gnu-gcc + $SUDO ln -nsf /usr/bin/g++ /usr/bin/\${ARCH}-linux-gnu-g++ + fi fi }