--- /tmp/pouet/var/lib/dpkg/info/cdrom-detect.postinst	1970-01-01 01:00:00.000000000 +0100
+++ var/lib/dpkg/info/cdrom-detect.postinst	2006-05-15 20:41:50.000000000 +0200
@@ -27,110 +27,64 @@
 
 mkdir /cdrom 2>/dev/null || true
 
-while true
-do
-    mounted=0
-
-    if [ -d /dev/cdroms ]; then
-        devices="`echo /dev/cdroms/*`"
-    else
-        devices=""
-    fi
-    for device in $devices
-    do
-        if mount -t iso9660 -o ro,exec $device /cdrom; then
-            log "CDROM-mount succeeded: device=$device"
-            mounted=1
-	    db_set cdrom-detect/cdrom_device $device
-            break
-        else
-            log "CDROM-mount failed (error=$?): device=$device"
-            log "Unmounting CD just to be sure."
-            umount /cdrom 2>/dev/null || true
-            log "Trying it again."
-            if mount -t iso9660 -o ro,exec $device /cdrom
-            then
-                log "CDROM-mount succeeded: device=$device"
-                mounted=1
-                db_set cdrom-detect/cdrom_device $device
-                break
-            else
-                log "CDROM-mount failed again (error=$?): device=$device"
-                log "Unmounting CD just to be sure and giving it up."
-                umount /cdrom 2>/dev/null || true
-            fi
-        fi
-    done
-
-    if [ "$mounted" = "1" ]; then
-        break
-    fi
+log "Configuring network"
+ifconfig lo 127.0.0.1
+dhclient eth0
+log "Loading modules"
+modprobe nfs
+modprobe lockd
+modprobe sunrpc
+log "Looking for NFS..."
+for x in `cat /proc/cmdline` ; do
+  case "${x}" in
+	nfs=*)
+		NFS=$(echo $x | cut -f2 -d=)
+		;;
+	ubuntu)
+		DIST=ubuntu
+		;;
+	kubuntu)
+		DIST=kubuntu
+		;;
+	*)
+		;;
+  esac
+done
+if [ "x$DIST" = "x" ] ; then
+	DIST=ubuntu
+fi
 
-    # If a device was detected but the mount failed, ask for the CD.
-    if [ -n "$devices" ]; then
-	db_input critical cdrom-detect/retry || [ $? -eq 30 ]
-	db_go
-	db_get cdrom-detect/retry
-	if [ "$RET" = "true" ]; then
-	    continue
-	else
-            fail
+# No nfs= given on the command line, trying to find the location
+# of the NFS mount point using the option-128 and option-129 fields 
+# of the DHCP lease.
+if [ "x$NFS" = "x" ] ; then
+	log "Trying through DHCP ..."
+	if [ "$DIST" = "ubuntu" ] ; then
+		DHCP_OPT_CODE=128
+	elif [ "$DIST" = "kubuntu" ] ; then
+		DHCP_OPT_CODE=129
+	fi
+	DHCP_OPT_PRESENT=$(grep -E "option option-$DHCP_OPT_CODE" /var/state/dhcp/dhclient.leases | wc -l)
+	if [ $DHCP_OPT_PRESENT -eq 1 ] ; then
+		NFS=$(grep -E "option option-$DHCP_OPT_CODE" /var/state/dhcp/dhclient.leases | sed "s/option option-$DHCP_OPT_CODE \"\(.*\)\";$/\1/")
 	fi
-    fi
- 
-    # If no device was detected, perhaps a driver floppy is needed.
-    if [ -e /usr/lib/debian-installer/retriever/floppy-retriever ]; then
-        db_input critical cdrom-detect/load_floppy
-	db_go
-	db_get cdrom-detect/load_floppy
-	if [ "$RET" = true ]; then
-		anna floppy-retriever
-		hw-detect cdrom-detect/detect_progress_title || true
-		continue
-	fi
-    fi
-    
-    # Otherwise manual configuration may be needed
-    db_input critical cdrom-detect/manual_config || [ $? -eq 30 ]
-    db_go
-    db_get cdrom-detect/manual_config
-
-    modules=none
-    for i in `ls -1 /lib/modules/*/kernel/drivers/cdrom/ | sed 's/\.ko$//' | sed 's/\.o$//'`
-    do
-	modules="$modules, $i"
-    done
-    
-    if [ "$RET" = "true" ]; then
-	db_subst cdrom-detect/cdrom_module choices "$modules"
-	db_input critical cdrom-detect/cdrom_module || [ $? -eq 30 ]
-	db_go
-
-	db_get cdrom-detect/cdrom_module
-	module="$RET"
-
-	db_input critical cdrom-detect/cdrom_device || [ $? -eq 30 ]
-	db_go
-
-	db_get cdrom-detect/cdrom_device
-	device="$RET"
+fi
+log "After DHCP, NFS=$NFS"
+# Cannot find the mountpoint in the DHCP lease, trying using SLP
+if [ "x$NFS" = "x" ] ; then
+	log "Trying through SLP"
+	NFS=$(slptool findsrvs service:nfs-$DIST-livecd | sed "s#service:nfs-$DIST-livecd:nfs://\(.*\),.*#\1#")
+fi
+log "After SLP, NFS=$NFS"
+# Still no NFS mountpoint found
+if [ "x$NFS" = "x" ] ; then
+	log "No NFS mountpoint found"
+	exit 1
+fi
 
-	if [ "$module" != "none" ]; then
-	    modprobe $module
-	fi
-	if mount -t iso9660 -o ro,exec $device /cdrom; then
-            log "CDROM-mount succeeded: device=$device"
-	    mounted=1
-	    break
-        else
-            log "CDROM-mount failed (error=$?): device=$device"
-            log "Unmounting CD just to be sure and giving it up."
-            umount /cdrom 2>/dev/null || true
-	fi
-    else
-	fail
-    fi
-done
+log "Mounting NFS $NFS"
+mount -n -o ro -o nolock,rsize=4096,wsize=4096 -t nfs $NFS /cdrom
+log "Mouting NFS...Done!"
 
 if [ -e /cdrom/.disk/info ] ; then
    CDNAME=`cat /cdrom/.disk/info`
