49a7772f070f6d223c2fcabf77d837d45c527a56
[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 make autoconf automake gcc linux-headers diffutils \
10     procps socat shadow sudo libgcrypt-dev texinfo texlive gzip \
11     openssl-dev zlib-dev lzo-dev ncurses-dev readline-dev musl-dev lz4-dev vde2-dev
12 }
13
14 deps_linux_debian() {
15   export DEBIAN_FRONTEND=noninteractive
16
17   HOST=${HOST:-}
18
19   if [ -n "$HOST" ]; then
20     dpkg --add-architecture "$HOST"
21   fi
22
23   apt-get update
24   apt-get upgrade -y
25
26   apt-get install -y \
27     git binutils make autoconf automake gcc diffutils sudo texinfo texlive netcat-openbsd procps socat \
28     zlib1g-dev:"$HOST" \
29     libssl-dev:"$HOST" \
30     liblzo2-dev:"$HOST" \
31     liblz4-dev:"$HOST" \
32     libncurses-dev:"$HOST" \
33     libreadline-dev:"$HOST" \
34     libgcrypt-dev:"$HOST" \
35     libminiupnpc-dev:"$HOST" \
36     libvdeplug-dev:"$HOST" \
37     "$@"
38
39   if [ -n "$HOST" ]; then
40     apt-get install -y crossbuild-essential-"$HOST" qemu-user
41   fi
42 }
43
44 deps_linux_rhel() {
45   if [ "$ID" != fedora ]; then
46     yum install -y epel-release
47
48     if type dnf; then
49       dnf install -y 'dnf-command(config-manager)'
50       dnf config-manager --enable powertools
51     fi
52   fi
53
54   yum upgrade -y
55
56   yum install -y \
57     git binutils make autoconf automake gcc diffutils sudo texinfo-tex netcat procps systemd \
58     findutils socat lzo-devel zlib-devel lz4-devel ncurses-devel readline-devel libgcrypt-devel "$@"
59
60   if yum info openssl11-devel; then
61     yum install -y openssl11-devel
62   else
63     dnf install -y openssl-devel
64   fi
65
66   if yum info miniupnpc-devel; then
67     yum install -y miniupnpc-devel
68   fi
69 }
70
71 deps_linux() {
72   . /etc/os-release
73
74   case "$ID" in
75   alpine)
76     deps_linux_alpine "$@"
77     ;;
78
79   debian | ubuntu)
80     deps_linux_debian "$@"
81     ;;
82
83   centos | almalinux | fedora)
84     deps_linux_rhel "$@"
85     ;;
86
87   *) exit 1 ;;
88   esac
89 }
90
91 deps_macos() {
92   brew install coreutils netcat automake lzo lz4 miniupnpc libgcrypt openssl "$@"
93   pip3 install --user compiledb
94 }
95
96 case "$(uname -s)" in
97 Linux) deps_linux "$@" ;;
98 Darwin) deps_macos "$@" ;;
99 *) exit 1 ;;
100 esac