diff --recursive --new-file --unified --exclude=.svn --exclude=.git /ram/gitcmp/flash-kernel/trunk/svn/debian/postinst /ram/gitcmp/flash-kernel/trunk/git/debian/postinst
--- /ram/gitcmp/flash-kernel/trunk/svn/debian/postinst	1970-01-01 01:00:00.000000000 +0100
+++ /ram/gitcmp/flash-kernel/trunk/git/debian/postinst	2009-08-06 23:20:10.642665342 +0200
@@ -0,0 +1,57 @@
+#!/bin/sh
+set -e
+
+. /usr/share/debconf/confmodule
+
+log() {
+	logger -t nslu2-firmware-installer "$@"
+}
+
+error() {
+	log "error: $@"
+}
+
+db_progress START 0 2 nslu2-firmware-installer/progress
+db_progress INFO nslu2-firmware-installer/prepare
+
+# The non-free ixp400_eth can be manually included on a d-i image,
+# if it is copy it into the installed system so it's available there too,
+# and gets put into the initramfs in flash.
+ixp400_found=0
+for file in $(find /lib/modules -type f |grep ixp400); do
+	ixp400_found=1
+	dir=$(dirname $file)
+	mkdir -p /target/$dir
+	cp -a $file /target/$file
+done
+if [ $ixp400_found -gt 1 ]; then
+	log "copied ixp400 driver to /target"
+	chroot /target depmod -a || true
+fi
+
+apt-install initramfs-tools || true # probably already installed; make sure
+if ! apt-install nslu2-utils; then
+	error "apt-install nslu2-utils failed"
+	exit 1
+fi
+
+# Set up nslu2-flashkernel to run on kernel upgrades.
+if ! grep -q nslu2-flashkernel /target/etc/kernel-img.conf; then
+	echo "postinst_hook = /usr/sbin/nslu2-flashkernel" >> \
+		/target/etc/kernel-img.conf
+fi
+
+db_progress STEP 1
+db_progress INFO nslu2-firmware-installer/flashing
+
+# We need the udev /dev which has the MTD devices
+mount -o bind /dev /target/dev
+if ! in-target nslu2-flashkernel; then
+	umount /target/dev || true
+	error "nslu2-flashkernel failed"
+	exit 1
+fi
+umount /target/dev || true
+
+db_progress STEP 1
+db_progress STOP
