#!/bin/sh -e
# Copyright: 2025 Michael Gilbert <mgilbert@debian.org>
# License: LGPL-2.1+

if [ -e debian/control.check ]; then
    echo "error: debian/control.check should not exist before calling check-control" >&2
    exit 1
fi

make -f debian/rules debian/control.check > /dev/null
test -e debian/control || make -f debian/rules debian/control
diff="$(diff -u debian/control debian/control.check || true)"
rm -f debian/control.check
if [ "$diff" != "" ]; then
    echo "error: debian/control.in or debian/control.stable.in have changed, consider running: \$ make -f debian/rules debian/control" >&2
    exit 1
fi
