#!/bin/sh
set -e

case ${PIUPARTS_OBJECTS%%=*} in
	TARBALL)
		# skip while creating the tarball
		exit 0
		;;
esac

if [ ! -f /etc/dpkg/dpkg.cfg.d/piuparts-force-unsafe-io ]
then
	if dpkg --force-help | grep -q unsafe-io
	then
		echo "Enabling dpkg --force-unsafe-io."
		echo force-unsafe-io > /etc/dpkg/dpkg.cfg.d/piuparts-force-unsafe-io
	fi
fi

if [ ! -h /bin/sync ]
then
	dpkg-divert --rename /bin/sync
	ln -sv true /bin/sync
fi
