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
|
#!/bin/sh
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
$RUNC run --interactive ${RUNC_OPTIONS:-} ${OPTS:-} --volume `pwd`:/source:ro ${1:-registry.fedoraproject.org/fedora} /bin/sh << EOF
set -eu
# avoid meson exit code 125; https://github.com/containers/podman/issues/11540
trap '[ \$? -eq 0 ] || exit 1' EXIT
dnf -y update
if [ -n "${SYSTEMD_MAIN:-}" ]; then
. /etc/os-release
dnf config-manager addrepo --from-repofile="https://download.opensuse.org/repositories/system:systemd/Fedora_\${VERSION_ID}/system:systemd.repo"
dnf -y update --repo=system_systemd --setopt=install_weak_deps=False
fi
if grep -q ID=.*centos /etc/os-release; then
repos=--enablerepo=crb
packages=""
coverage=false
# building gtk-doc does not yet work with meson 0.49.2
gtk_doc=false
# don't run coverage on rawhide, toolchain is sometimes unstable
elif grep -q rawhide /etc/os-release; then
packages="evtest gphoto2"
coverage=false
gtk_doc=true
else
# gcovr 5.2+ is broken: https://bugzilla.redhat.com/show_bug.cgi?id=2166960
# packages="gcovr"
# coverage=true
packages="evtest gphoto2"
coverage=false
gtk_doc=true
fi
# install build and test dependencies
dnf -y \${repos:-} install meson git gcc clang glib2-devel gtk-doc libgudev1-devel libtool libudev-devel libpcap-devel make python3 python3-gobject-base usbutils vala xz systemd-udev valgrind \$packages
# run build as user
useradd guest
su -s /bin/sh - guest << EOG
set -eux
git config --global safe.directory /source
export BRITTLE_TESTS="${BRITTLE_TESTS:-}"
cd /source
# thanks gcc for making your major version so easy to parse
GCC_VERSION=\\\$(gcc --version | grep -oE '[0-9]+\.[0-9]+' | head -n1 | cut -f1 -d.)
meson setup /tmp/dbg --buildtype debug --prefix /usr -Dgtk_doc=\${gtk_doc} -Db_coverage=\$coverage --werror
cd /tmp/dbg
DESTDIR=/tmp/inst meson install
meson test -v --num-processes=1
if [ "\$coverage" = true ]; then
ninja coverage-text
meson test -v --num-processes=1 --setup valgrind --no-suite fails-valgrind
cat meson-logs/coverage.txt
fi
# build with clang
cd /source
CC=clang meson setup /tmp/clang -Dgtk_doc=false --werror
meson test -C /tmp/clang -v --num-processes=1
# build with optimization and fortify
if [ \\\$GCC_VERSION -ge 12 ]; then
fortify_level=3
else
fortify_level=2
fi
CFLAGS="-O2 -D_FORTIFY_SOURCE=\\\$fortify_level" meson setup /tmp/fortify -Dgtk_doc=false --werror
meson test -C /tmp/fortify/ -v --num-processes=1
EOG
EOF
|