#!/bin/sh

# ensure we are in the abibreak subdirectory
cd "$(readlink -f $(dirname $0))"

if [ ! -d ../build ]; then
	echo "../build missing, did you run make?"
	exit 1
fi

if ! command -v abi-compliance-checker 2>/dev/null >&2; then
	echo "Please install the 'abi-compliance-checker' package"
	exit 1
fi

LIBPATH=$(find /usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH) -type f -regex '.*/libapt-\(pkg\|inst\)\.so\..*' -printf %p\\\\n)
sed s#@installed_libapt@#$LIBPATH# apt_installed.xml.in > apt_installed.xml

BUILDPATH=$(readlink -f ../build)
sed s#@build_path@#$BUILDPATH# apt_build.xml.in > apt_build.xml

abi-compliance-checker -l apt -d1 apt_installed.xml -d2 apt_build.xml $@