-
Notifications
You must be signed in to change notification settings - Fork 612
Expand file tree
/
Copy pathlinux.bash
More file actions
executable file
·134 lines (118 loc) · 4.6 KB
/
Copy pathlinux.bash
File metadata and controls
executable file
·134 lines (118 loc) · 4.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/bash
set -exo pipefail
export PATH="/usr/lib/ccache/bin:/usr/lib/ccache:/usr/lib64/ccache:$PATH"
export CCACHE_DIR=/icinga2/ccache
export CTEST_OUTPUT_ON_FAILURE=1
CMAKE_OPTS=()
SCL_ENABLE_GCC=()
# -Wstringop-overflow is notorious for false positives and has been a problem for years.
# See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88443
# -Wtemplate-id-cdtor leaks from using the generated headers. We should reenable this once
# we're considering moving to C++20 and/or the -ti.hpp files are generated differently.
WARN_FLAGS="-Wall -Wextra -Wno-template-id-cdtor -Wno-stringop-overflow"
case "$DISTRO" in
alpine:*)
# Packages inspired by the Alpine package, just
# - LibreSSL instead of OpenSSL 3 and
# - no MariaDB or libpq as they depend on OpenSSL.
# https://gitlab.alpinelinux.org/alpine/aports/-/blob/master/community/icinga2/APKBUILD
apk add bison boost-dev ccache cmake flex g++ libedit-dev libressl-dev ninja-build tzdata protobuf-dev
ln -vs /usr/lib/ninja-build/bin/ninja /usr/local/bin/ninja
;;
amazonlinux:20*)
dnf install -y amazon-rpm-config bison cmake flex gcc-c++ ninja-build \
{boost,libedit,mariadb-connector-c,ncurses,openssl,postgresql,systemd,protobuf-lite}-devel
;;
debian:*|ubuntu:*)
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-{recommends,suggests} -y \
bison ccache cmake dpkg-dev flex g++ ninja-build tzdata protobuf-compiler \
lib{boost-all,edit,mariadb,ncurses,pq,ssl,systemd,protobuf}-dev
;;
fedora:*)
dnf install -y bison ccache cmake flex gcc-c++ ninja-build redhat-rpm-config \
{boost,libedit,mariadb,ncurses,openssl,postgresql,systemd,protobuf-lite}-devel
;;
*suse*)
zypper in -y --allow-downgrade bison ccache cmake flex gcc-c++ ninja rpm-config-SUSE \
{lib{edit,mariadb,openssl},ncurses,postgresql,systemd,protobuf}-devel \
libboost_{context,coroutine,filesystem,iostreams,program_options,regex,system,test,thread}-devel
;;
*rockylinux:*)
dnf install -y 'dnf-command(config-manager)' epel-release
case "$DISTRO" in
*:8)
dnf config-manager --enable powertools
# Our Protobuf package on RHEL 8 is built with GCC 13, and since the ABI is not compatible with GCC 8,
# we need to enable the SCL repository and install the GCC 13 packages to be able to link against it.
SCL_ENABLE_GCC=(scl enable gcc-toolset-13 --)
dnf install -y gcc-toolset-13-gcc-c++ gcc-toolset-13-annobin-plugin-gcc
;;
*)
dnf config-manager --enable crb
;;
esac
dnf install -y bison ccache cmake gcc-c++ flex ninja-build redhat-rpm-config \
{boost,bzip2,libedit,mariadb,ncurses,openssl,postgresql,systemd,xz,libzstd}-devel
# Rocky Linux 8 and 9 don't have a recent enough Protobuf compiler for OTel, so we need to add
# our repository to install the pre-built Protobuf devel package.
case "$DISTRO" in
*:[8-9])
rpm --import https://packages.icinga.com/icinga.key
cat > /etc/yum.repos.d/icinga-build-deps.repo <<'EOF'
[icinga-build-deps]
name=Icinga Build Dependencies
baseurl=https://packages.icinga.com/build-dependencies/rhel/$releasever/release
enabled=1
gpgcheck=1
gpgkey=https://packages.icinga.com/icinga.key
EOF
dnf install -y icinga-protobuf
# Tell CMake where to find our own Protobuf CMake config files.
CMAKE_OPTS+=(-DCMAKE_PREFIX_PATH="$(rpm -E '%{_libdir}')/icinga-protobuf/cmake")
;;
*)
dnf install -y protobuf-lite-devel
esac
;;
esac
case "$DISTRO" in
alpine:*)
CMAKE_OPTS+=(
-DUSE_SYSTEMD=OFF
-DICINGA2_WITH_MYSQL=OFF
-DICINGA2_WITH_PGSQL=OFF
-DCMAKE_{C,CXX}_FLAGS="${WARN_FLAGS}"
)
;;
debian:*|ubuntu:*)
CMAKE_OPTS+=(-DICINGA2_LTO_BUILD=ON)
source <(dpkg-buildflags --export=sh)
export CFLAGS="${CFLAGS} ${WARN_FLAGS}"
export CXXFLAGS="${CXXFLAGS} ${WARN_FLAGS}"
# The default Protobuf compiler is too old for OTel, so we need to turn it off on Debian 11 and Ubuntu 22.04.
case "$DISTRO" in
debian:11|ubuntu:22.04)
CMAKE_OPTS+=(-DICINGA2_WITH_OPENTELEMETRY=OFF)
;;
esac
;;
*)
CMAKE_OPTS+=(-DCMAKE_{C,CXX}_FLAGS="$(rpm -E '%{optflags} %{?march_flag}') ${WARN_FLAGS}")
export LDFLAGS="$(rpm -E '%{?build_ldflags}')"
;;
esac
mkdir /icinga2/build
cd /icinga2/build
"${SCL_ENABLE_GCC[@]}" cmake \
-GNinja \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DICINGA2_UNITY_BUILD=ON \
-DUSE_SYSTEMD=ON \
-DICINGA2_USER=$(id -un) \
-DICINGA2_GROUP=$(id -gn) \
"${CMAKE_OPTS[@]}" ..
ninja -v
ninja test
ninja install
icinga2 daemon -C