#!/bin/sh
set -eux
# install build dependencies
dnf -y install python3-setuptools python3 python3-gobject-base \
    python3-dbus dbus-x11 util-linux \
    upower NetworkManager bluez libnotify polkit

if ! grep -q :el /etc/os-release; then
    dnf -y install python3-flake8 python3-pylint python3-mypy \
        power-profiles-daemon iio-sensor-proxy
fi

# systemd's tools otherwise fail on "not been booted with systemd"
mkdir -p /run/systemd/system

# run build and test as user
useradd build
su -s /bin/sh - build << EOF
set -ex
cd /source
export TEST_CODE="$TEST_CODE"
python3 -m unittest -v || {
  [ -z "$DEBUG" ] || sleep infinity
  exit 1
}
EOF
