summaryrefslogtreecommitdiff
path: root/.private/ci-container-build.sh
blob: 7419cb7b2487e1b4bdecb5a32edca729a28462c6 (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
#!/bin/bash

set -eu

# keep container around if $DEBUG is set
[ -n "${DEBUG:-}" ] || OPTS="--rm"

if type podman >/dev/null 2>&1; then
    RUNC=podman
else
    RUNC="sudo docker"
fi

MOUNT_MODE=":ro"

$RUNC run --interactive ${RUNC_OPTIONS:-} ${OPTS:-} --volume `pwd`:/source${MOUNT_MODE:-} ${1:-docker.io/amd64/ubuntu:rolling} /bin/bash << EOF
set -ex

# avoid meson exit code 125; https://github.com/containers/podman/issues/11540
trap '[ \$? -eq 0 ] || exit 1' EXIT

# go-faster apt
echo  'Acquire::Languages "none";' > /etc/apt/apt.conf.d/90nolanguages

# upgrade
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y eatmydata
eatmydata apt-get -y --purge dist-upgrade

# install build and test dependencies
eatmydata apt-get install -y make libtool libudev-dev pkg-config umockdev libumockdev-dev

# run build as user
useradd build
su -s /bin/bash - build << EOG
set -ex

mkdir "/tmp/builddir"
cd "/tmp/builddir"

CFLAGS="-O2"

# enable extra warnings
CFLAGS+=" -Winline"
CFLAGS+=" -Wmissing-include-dirs"
CFLAGS+=" -Wnested-externs"
CFLAGS+=" -Wpointer-arith"
CFLAGS+=" -Wredundant-decls"
CFLAGS+=" -Wswitch-enum"
export CFLAGS

echo ""
echo "Configuring ..."
/source/configure --enable-examples-build --enable-tests-build

echo ""
echo "Building ..."
make -j4 -k

echo ""
echo "Running umockdev tests ..."
tests/umockdev

echo "Running stress tests ..."
tests/stress
tests/stress_mt
EOG
EOF