]> git.ipfire.org Git - thirdparty/systemd.git/blob - .github/workflows/ubuntu-build-check.sh
Merge pull request #17185 from yuwata/ethtool-update
[thirdparty/systemd.git] / .github / workflows / ubuntu-build-check.sh
1 #!/bin/bash
2
3 set -ex
4
5 info() { echo -e "\033[33;1m$1\033[0m"; }
6 fatal() { echo >&2 -e "\033[31;1m$1\033[0m"; exit 1; }
7 success() { echo >&2 -e "\033[32;1m$1\033[0m"; }
8
9 ARGS=(
10 "--optimization=0"
11 "--optimization=2"
12 "--optimization=s"
13 "--optimization=3 -Db_lto=true"
14 "--optimization=3 -Db_lto=false"
15 "-Db_ndebug=true"
16 )
17 PACKAGES=(
18 cryptsetup-bin
19 expect
20 fdisk
21 gettext
22 iputils-ping
23 isc-dhcp-client
24 itstool
25 kbd
26 libblkid-dev
27 libcap-dev
28 libcurl4-gnutls-dev
29 libfdisk-dev
30 libfido2-dev
31 libgpg-error-dev
32 liblz4-dev
33 liblzma-dev
34 libmicrohttpd-dev
35 libmount-dev
36 libp11-kit-dev
37 libpwquality-dev
38 libqrencode-dev
39 libssl-dev
40 libxkbcommon-dev
41 libxtables-dev
42 libzstd-dev
43 mount
44 net-tools
45 perl
46 python-lxml
47 python3-evdev
48 python3-lxml
49 python3-pip
50 python3-pyparsing
51 python3-setuptools
52 quota
53 strace
54 unifont
55 util-linux
56 zstd
57 )
58 COMPILER="${COMPILER:?}"
59 COMPILER_VERSION="${COMPILER_VERSION:?}"
60 RELEASE="$(lsb_release -cs)"
61
62 bash -c "echo 'deb-src http://archive.ubuntu.com/ubuntu/ $RELEASE main restricted universe multiverse' >>/etc/apt/sources.list"
63
64 # Note: As we use postfixed clang/gcc binaries, we need to override $AR
65 # as well, otherwise meson falls back to ar from binutils which
66 # doesn't work with LTO
67 if [[ "$COMPILER" == clang ]]; then
68 CC="clang-$COMPILER_VERSION"
69 CXX="clang++-$COMPILER_VERSION"
70 AR="llvm-ar-$COMPILER_VERSION"
71 # Latest LLVM stack deb packages provided by https://apt.llvm.org/
72 # Following snippet was borrowed from https://apt.llvm.org/llvm.sh
73 wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
74 add-apt-repository -y "deb http://apt.llvm.org/$RELEASE/ llvm-toolchain-$RELEASE-$COMPILER_VERSION main"
75 PACKAGES+=(clang-$COMPILER_VERSION lldb-$COMPILER_VERSION lld-$COMPILER_VERSION clangd-$COMPILER_VERSION)
76 elif [[ "$COMPILER" == gcc ]]; then
77 CC="gcc-$COMPILER_VERSION"
78 CXX="g++-$COMPILER_VERSION"
79 AR="gcc-ar-$COMPILER_VERSION"
80 # Latest gcc stack deb packages provided by
81 # https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test
82 sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
83 PACKAGES+=(gcc-$COMPILER_VERSION)
84 else
85 fatal "Unknown compiler: $COMPILER"
86 fi
87
88 # PPA with some newer build dependencies (like zstd)
89 add-apt-repository -y ppa:upstream-systemd-ci/systemd-ci
90 apt-get -y update
91 apt-get -y build-dep systemd
92 apt-get -y install "${PACKAGES[@]}"
93 # Install the latest meson and ninja form pip, since the distro versions don't
94 # support all the features we need (like --optimization=). Since the build-dep
95 # command above installs the distro versions, let's install the pip ones just
96 # locally and add the local bin directory to the $PATH.
97 pip3 install --user -U meson ninja
98 export PATH="$HOME/.local/bin:$PATH"
99
100 $CC --version
101
102 for args in "${ARGS[@]}"; do
103 SECONDS=0
104
105 info "Checking build with $args"
106 if ! AR="$AR" CC="$CC" CXX="$CXX" CFLAGS="-Werror" CXXFLAGS="-Werror" meson -Dtests=unsafe -Dslow-tests=true --werror $args build; then
107 fatal "meson failed with $args"
108 fi
109
110 ninja --version
111 if ! ninja -C build; then
112 fatal "ninja failed with $args"
113 fi
114
115 git clean -dxf
116
117 success "Build with $args passed in $SECONDS seconds"
118 done