#!/bin/sh
# postinst script for noris-base
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#	 * <postinst> `configure' <most-recently-configured-version>
#	 * <old-postinst> `abort-upgrade' <new version>
#	 * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#	   <new-version>
#	 * <postinst> `abort-remove'
#	 * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#	   <failed-install-package> <version> `removing'
#	   <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package


case "$1" in
    configure)
	/usr/bin/localedef --list-archive | grep en_US >/dev/null || /usr/sbin/locale-gen
	if ! [ -L /dev/random ]; then
		echo -n "Replacing /dev/random with a symlink to /dev/urandom..."
		cd /dev/
		rm -f /dev/random
		ln -s /dev/urandom /dev/random
		echo "done."
	fi
        if [ -c /dev/.static/dev/urandom ]; then
                echo -n "udev active, "
                if ! [ -L /dev/.static/dev/random ]; then
                        echo -n "so we have to set static links too..."
                        cd /dev/.static/dev/
                        rm -f random
                        ln -s urandom random
                else 
			echo -n "but it's already a symlink..."
                fi
		echo "done."
        fi
	apt-key list | grep Debian-Volatile > /dev/null || wget http://volatile.debian.net/etch-volatile.asc -O - | apt-key add -
	apt-key list | grep noris > /dev/null || wget http://apt.noris.net/etch-noris.asc -O - | apt-key add -
	apt-key list | grep backports > /dev/null || wget http://mirror.noris.net/backports/archive.key -O - | apt-key add -
	apt-file update
	grep " proposed-updates" /etc/apt/sources.list >/dev/null && (\
		mv /etc/apt/sources.list /etc/apt/sources.list.tmp
		sed -e 's/ proposed-updates/ etch-proposed-updates/g' /etc/apt/sources.list.tmp \
			> /etc/apt/sources.list
		rm /etc/apt/sources.list.tmp)
# muss rein wegen DELL-Paketen s. RT#540176
        if lshw|grep vendor|grep -i dell > /dev/null; then
                if ! apt-key list|grep 22D16719 > /dev/null; then
                    wget http://mirror.noris.net/debian_sara.asc -O - | apt-key add -
                fi
                DELLSOURCESLIST=/etc/apt/sources.list.d/dell.sources.list
                if [ ! -f $DELLSOURCESLIST ]; then
                    echo 'deb http://mirror.noris.net/dell-omsa dell sara' > \
                     $DELLSOURCESLIST
                else
                        if ! grep sara $DELLSOURCESLIST > /dev/null; then
                    echo 'deb http://mirror.noris.net/dell-omsa dell sara' > \
                        $DELLSOURCESLIST
                        fi
                fi
        fi

    ;;

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

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

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0


