#! /bin/sh

set -e

clean_symlinks() {
	# debianutils 5.9 and 5.10 added incorrect links in the postinst: #1050784.
	# Get rid of them again. We do no longer support non-usrmerged systems.
	# TODO This can be dropped before trixie toolchain freeze but not before Sep 2024.
	for l in "$DPKG_ROOT/usr/bin/run-parts" "$DPKG_ROOT/bin/tmpfile" "$DPKG_ROOT/usr/bin/tmpfile" "$DPKG_ROOT/bin/tempfile" "$DPKG_ROOT/usr/bin/tempfile" "$DPKG_ROOT/usr/sbin/installkernel" "$DPKG_ROOT/sbin/installkernel"
	do
		[ ! -L "$l" ] || rm -f "$l"
	done
}

if test -z "$2" && test ! -f "$DPKG_ROOT/etc/shells"
then
	cp -pZ "$DPKG_ROOT/usr/share/debianutils/shells" "$DPKG_ROOT/etc/shells" || cp -p "$DPKG_ROOT/usr/share/debianutils/shells" "$DPKG_ROOT/etc/shells"
fi

case "$1" in
    (configure)
	update-shells
	clean_symlinks
    ;;
    (triggered)
	update-shells
    ;;

    (abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    (*)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

#DEBHELPER#
