#!/bin/sh
# Copyright 2023 Simon McVittie
# SPDX-License-Identifier: FSFAP

set -eu

export GDP_BUILDDIR="$(echo obj-*)"
export GDP_TEST_DESTRUCTIVE=yes

cat > "$AUTOPKGTEST_TMP/apt.conf" <<EOF
APT::Get::Assume-Yes "true";
EOF
export APT_CONFIG="$AUTOPKGTEST_TMP/apt.conf"

cat > "$AUTOPKGTEST_TMP/10-local-autopkgtest.rules" <<EOF
// Make members of group sudo trivially root-equivalent
polkit.addRule(function(action, subject) {
    if (subject.isInGroup("sudo")) {
        return polkit.Result.YES;
    }
    return polkit.Result.NOT_HANDLED;
});
EOF
sudo install -m644 "$AUTOPKGTEST_TMP/10-local-autopkgtest.rules" \
    /etc/polkit-1/rules.d/10-local-autopkgtest.rules

exec ./tests/integration.py
