summaryrefslogtreecommitdiff
path: root/ci/builddeps.sh
blob: 4accd2e315506f8ead4db1994095640ec3b77350 (plain)
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
#!/usr/bin/env bash
# Copyright 2021 Simon McVittie
# SPDX-License-Identifier: LGPL-2.0-or-later

set -eux
set -o pipefail

usage() {
    if [ "${1-2}" -ne 0 ]; then
        exec >&2
    fi
    cat <<EOF
Usage: see source code
EOF
    exit "${1-2}"
}

opt_clang=

getopt_temp="help"
getopt_temp="$getopt_temp,clang"

getopt_temp="$(getopt -o '' --long "${getopt_temp}" -n "$0" -- "$@")"
eval set -- "$getopt_temp"
unset getopt_temp

while true; do
    case "$1" in
        (--clang)
            clang=yes
            shift
            ;;

        (--help)
            usage 0
            # not reached
            ;;

        (--)
            shift
            break
            ;;

        (*)
            echo 'Error parsing options' >&2
            usage 2
            ;;
    esac
done

# No more arguments please
for arg in "$@"; do
    usage 2
done

if dpkg-vendor --derives-from Debian; then
    apt-get -y update
    apt-get -q -y install \
        autoconf \
        automake \
        build-essential \
        docbook-xml \
        docbook-xsl \
        libcap-dev \
        libselinux1-dev \
        libtool \
        meson \
        pkg-config \
        python3 \
        xsltproc \
        ${NULL+}

    if [ -n "${opt_clang}" ]; then
        apt-get -y install clang
    fi

    exit 0
fi

if command -v yum; then
    yum -y install \
        'pkgconfig(libselinux)' \
        /usr/bin/eu-readelf \
        autoconf \
        automake \
        docbook-style-xsl \
        gcc \
        git \
        libasan \
        libcap-devel \
        libtool \
        libtsan \
        libubsan \
        libxslt \
        make \
        meson \
        redhat-rpm-config \
        rsync \
        ${NULL+}

    if [ -n "${opt_clang}" ]; then
        yum -y install clang
    fi

    exit 0
fi

echo "Unknown distribution" >&2
exit 1

# vim:set sw=4 sts=4 et: