]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
install-deps.sh: install proper compiler version on Debian/Ubuntu 65990/head
authorDan Mick <dan.mick@redhat.com>
Sun, 19 Oct 2025 00:45:31 +0000 (17:45 -0700)
committerDan Mick <dan.mick@redhat.com>
Sun, 19 Oct 2025 00:47:32 +0000 (17:47 -0700)
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 <dan.mick@redhat.com>
install-deps.sh

index af060baab9621e7a2203a55dbb9d8aa4819048b7..0038673513301633d540f7a57f2dbb5ad1585bb3 100755 (executable)
@@ -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
 }