#! /bin/sh
set -e

if [ "$1" = remove ]; then
    if command -v suidunregister >/dev/null 2>&1 && [ -e /etc/suid.conf ]; then
	if [ -x /usr/lib/pt_chown ]; then
	    suidunregister -s libc6 /usr/lib/pt_chown
	elif [ -x /usr/libexec/pt_chown ]; then
	    suidunregister -s libc6 /usr/libexec/pt_chown
	fi
    fi
fi

if [ "$1" = upgrade ]; then
    case $(dpkg --print-architecture) in
	i386|sparc)
	    if dpkg --compare-versions "$2" lt 2.3.4-3; then
		# Make sure the downgraded package does not support
		# ld.so.hwcappkgs mechanism on i686 and sparc.
		rm -f /etc/ld.so.hwcappkgs
		echo "downgrade-to-old-glibc" >> /etc/ld.so.nohwcap

		echo
		echo You are trying to downgrade to glibc 2.3.4-2 or earlier.
		echo Such old packages do not support the version mismatch between
		echo standard libc and hwcap libc using /etc/ld.so.hwcappkgs
		echo on i386 and sparc.  To be safe from library inconsistency,
		echo hwcap libraries are disabled until glibc 2.3.4-3 or later
		echo is installed.
		echo
	    fi
	    ;;
    esac
fi

if [ "$1" = deconfigure ]; then
    :; # blah, do something useful with ldso
fi

#if [ "$1" = purge ]; then
#    update-rc.d mountkernfs remove > /dev/null
#fi

# Automatically added by dh_installdebconf
if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then
	. /usr/share/debconf/confmodule
	db_purge
fi
# End automatically added section
# Automatically added by dh_makeshlibs
if [ "$1" = "remove" ]; then
	ldconfig
fi
# End automatically added section


exit 0
