]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
travis: make it easier to switch to the next clang/gcc
authorEvgeny Vereshchagin <evvers@ya.ru>
Tue, 30 Jun 2020 16:43:49 +0000 (16:43 +0000)
committerEvgeny Vereshchagin <evvers@ya.ru>
Tue, 30 Jun 2020 18:11:30 +0000 (18:11 +0000)
by just changing the compiler option in .travis.yml

In https://travis-ci.org/github/karelzak/util-linux/builds/703664282 I switched
to gcc-9/clang-9 by simply applying the following patch:
```
diff --git a/.travis.yml b/.travis.yml
index ec1284717..12a247d91 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -7,8 +7,8 @@ git:
   depth: 1500

 compiler:
-  - gcc-10
-  - clang-10
+  - gcc-9
+  - clang-9

 env:
   - MAKE_CHECK="nonroot"
```

.travis-functions.sh

index 99ab4288c6822883db10c94cb4a3d0b62875be5e..805a5104ffd1c13e5826829a7567de3c081e8907 100755 (executable)
@@ -125,19 +125,30 @@ function check_dist
 
 function travis_install_script
 {
+       local ubuntu_release=$(lsb_release -cs)
+       local additional_packages=()
+       local clang_version gcc_version
+
        if [ "$TRAVIS_OS_NAME" = "osx" ]; then
                osx_install_script
                return
        fi
 
        # install required packages
-       sudo bash -c "echo 'deb-src http://archive.ubuntu.com/ubuntu/ $(lsb_release -cs) main restricted universe multiverse' >>/etc/apt/sources.list"
-
-       # the following snippet was borrowed from https://apt.llvm.org/llvm.sh
-       wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
-       add-apt-repository -y "deb http://apt.llvm.org/$(lsb_release -cs)/   llvm-toolchain-$(lsb_release -cs)-10  main"
+       sudo bash -c "echo 'deb-src http://archive.ubuntu.com/ubuntu/ $ubuntu_release main restricted universe multiverse' >>/etc/apt/sources.list"
+
+       if [[ "$CC" =~ ^clang-([0-9]+)$ ]]; then
+               clang_version=${BASH_REMATCH[1]}
+               # the following snippet was borrowed from https://apt.llvm.org/llvm.sh
+               wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
+               sudo add-apt-repository -y "deb http://apt.llvm.org/$ubuntu_release/   llvm-toolchain-$ubuntu_release-$clang_version  main"
+               additional_packages+=(clang-$clang_version)
+       elif [[ "$CC" =~ ^gcc-([0-9]+)$ ]]; then
+               gcc_version=${BASH_REMATCH[1]}
+               sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
+               additional_packages+=(gcc-$gcc_version)
+       fi
 
-       sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
        sudo apt-get -qq update --fix-missing
        sudo apt-get build-dep -y util-linux
        sudo apt-get install -qq >/dev/null \
@@ -152,11 +163,9 @@ function travis_install_script
                mdadm \
                ntp \
                socat \
+               "${additional_packages[@]}" \
                || return
 
-       sudo apt-get install -y gcc-10
-       sudo apt-get install -y clang-10
-
        # install only if available (e.g. Ubuntu Trusty)
        sudo apt-get install -qq >/dev/null \
                libsystemd-daemon-dev \