Adjust CI to new integration tests
[tinc] / .ci / deps.sh
1 #!/bin/sh
2
3 set -eu
4
5 deps_linux_alpine() {
6   apk upgrade
7
8   apk add \
9     git binutils meson pkgconf gcc linux-headers shadow sudo libgcrypt-dev texinfo gzip \
10     openssl-dev zlib-dev lzo-dev ncurses-dev readline-dev musl-dev lz4-dev vde2-dev cmocka-dev
11 }
12
13 deps_linux_debian_mingw() {
14   apt-get install -y \
15     mingw-w64 mingw-w64-tools \
16     wine wine-binfmt \
17     libgcrypt-mingw-w64-dev \
18     "$@"
19 }
20
21 deps_linux_debian_linux() {
22   if [ -n "$HOST" ]; then
23     dpkg --add-architecture "$HOST"
24   fi
25
26   apt-get update
27
28   apt-get install -y \
29     binutils make gcc \
30     zlib1g-dev:"$HOST" \
31     libssl-dev:"$HOST" \
32     liblzo2-dev:"$HOST" \
33     liblz4-dev:"$HOST" \
34     libncurses-dev:"$HOST" \
35     libreadline-dev:"$HOST" \
36     libgcrypt-dev:"$HOST" \
37     libminiupnpc-dev:"$HOST" \
38     libvdeplug-dev:"$HOST" \
39     libcmocka-dev:"$HOST" \
40     "$@"
41
42   if [ -n "$HOST" ]; then
43     apt-get install -y crossbuild-essential-"$HOST" qemu-user
44   else
45     linux_openssl3
46   fi
47 }
48
49 deps_linux_debian() {
50   export DEBIAN_FRONTEND=noninteractive
51
52   apt-get update
53   apt-get upgrade -y
54   apt-get install -y git pkgconf sudo texinfo
55
56   HOST=${HOST:-}
57   if [ "$HOST" = mingw ]; then
58     deps_linux_debian_mingw "$@"
59   else
60     deps_linux_debian_linux "$@"
61   fi
62
63   . /etc/os-release
64
65   # Debian Buster ships an old version of meson (0.49).
66   # MinGW cross-compilation requires something newer than 0.55 that ships in Bullseye,
67   # or it fails when looking for dependencies in the OpenSSL wrap.
68   if [ "${ID:-}/${VERSION_CODENAME:-}" = debian/buster ] || [ "$HOST" = mingw ]; then
69     apt-get install -y python3 python3-pip ninja-build
70     pip3 install meson
71   else
72     apt-get install -y meson
73   fi
74 }
75
76 deps_linux_rhel() {
77   if [ "$ID" != fedora ]; then
78     yum install -y epel-release
79
80     if type dnf; then
81       dnf install -y 'dnf-command(config-manager)'
82       dnf config-manager --enable powertools
83     fi
84   fi
85
86   yum upgrade -y
87
88   yum install -y \
89     git binutils make meson pkgconf gcc sudo texinfo-tex systemd perl-IPC-Cmd \
90     lzo-devel zlib-devel lz4-devel ncurses-devel readline-devel libgcrypt-devel "$@"
91
92   if yum info openssl11-devel; then
93     yum install -y openssl11-devel
94   else
95     dnf install -y openssl-devel
96   fi
97
98   if yum info miniupnpc-devel; then
99     yum install -y miniupnpc-devel
100   fi
101 }
102
103 linux_openssl3() {
104   if [ -n "${SKIP_OPENSSL3:-}" ]; then
105     echo >&2 "skipping openssl3 installation in this job"
106     return
107   fi
108
109   src=/usr/local/src/openssl
110   ssl3=/opt/ssl3
111
112   mkdir -p $src
113
114   git clone --depth 1 --branch openssl-3.0.2 https://github.com/openssl/openssl $src
115   cd $src
116
117   ./Configure --prefix=$ssl3 --openssldir=$ssl3
118   make -j"$(nproc)"
119   make install_sw
120
121   if [ -f /etc/ld.so.conf ]; then
122     echo $ssl3/lib64 >>/etc/ld.so.conf
123     ldconfig -v
124   else
125     ldconfig -v $ssl3/lib64
126   fi
127
128   cd -
129 }
130
131 deps_linux() {
132   . /etc/os-release
133
134   case "$ID" in
135   alpine)
136     deps_linux_alpine "$@"
137     ;;
138
139   debian | ubuntu)
140     deps_linux_debian "$@"
141     ;;
142
143   centos | almalinux | fedora)
144     deps_linux_rhel "$@"
145     linux_openssl3
146     ;;
147
148   *) exit 1 ;;
149   esac
150 }
151
152 deps_macos() {
153   brew install lzo lz4 miniupnpc libgcrypt openssl meson "$@"
154 }
155
156 case "$(uname -s)" in
157 Linux) deps_linux "$@" ;;
158 Darwin) deps_macos "$@" ;;
159 *) exit 1 ;;
160 esac