]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
install-deps.sh: use gcc-7 on trusty
authorKefu Chai <kchai@redhat.com>
Sun, 12 Nov 2017 05:07:35 +0000 (13:07 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 5 Dec 2017 02:29:49 +0000 (10:29 +0800)
* always install gcc-7 on trusty
* point g++ to g++-7 if not yet

Signed-off-by: Kefu Chai <kchai@redhat.com>
install-deps.sh

index 0c3e9b09c8b55d34f088cb8d31167527dcdb62d7..871a9f81a0e914f7ae18afa618e68fee80c727cf 100755 (executable)
@@ -26,6 +26,30 @@ function munge_ceph_spec_in {
     sed -e 's/@//g' -e 's/%bcond_with make_check/%bcond_without make_check/g' < ceph.spec.in > $OUTFILE
 }
 
+function ensure_decent_gcc {
+    # point gcc to the one offered by g++-7 if the used one is not
+    # new enough
+    old=$(gcc -dumpversion)
+    new=$1
+    if dpkg --compare-versions $old ge 5.1; then
+       return
+    fi
+
+    $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/x86_64-linux-gnu-gcc
+    $SUDO ln -nsf /usr/bin/g++ /usr/bin/x86_64-linux-gnu-g++
+}
+
 if [ x`uname`x = xFreeBSDx ]; then
     $SUDO pkg install -yq \
         devel/babeltrace \
@@ -81,7 +105,18 @@ else
     debian|ubuntu|devuan)
         echo "Using apt-get to install dependencies"
         $SUDO apt-get install -y lsb-release devscripts equivs
-        $SUDO apt-get install -y dpkg-dev gcc
+        $SUDO apt-get install -y dpkg-dev
+        case "$VERSION" in
+            *Trusty*)
+                $SUDO add-apt-repository ppa:ubuntu-toolchain-r/test
+                $SUDO apt-get update
+                $SUDO apt-get install -y gcc-7
+                ensure_decent_gcc 7
+                ;;
+            *)
+                $SUDO apt-get install -y gcc
+                ;;
+        esac
         if ! test -r debian/control ; then
             echo debian/control is not a readable file
             exit 1