From 829426a17dd6244c6098576fd39c6343633a48a6 Mon Sep 17 00:00:00 2001 From: Dan Mick Date: Sat, 18 Oct 2025 17:45:31 -0700 Subject: [PATCH] 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 (cherry picked from commit fd19a09e02b4506d40b24c5044224747f6a49bf3) --- install-deps.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/install-deps.sh b/install-deps.sh index b5813d4d38d..c0117175711 100755 --- a/install-deps.sh +++ b/install-deps.sh @@ -99,6 +99,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 } -- 2.39.5