diff -ruN ppp-2.4.4b1/debian/control ppp-2.4.4b1-fix-templates-and-error-logging/debian/control
--- ppp-2.4.4b1/debian/control	2006-05-23 08:01:28.000000000 +0300
+++ ppp-2.4.4b1-fix-templates-and-error-logging/debian/control	2006-05-13 14:43:01.000000000 +0300
@@ -21,10 +21,12 @@
  between the peers.
 
 Package: ppp-udeb
+XC-Package-Type: udeb
 Section: debian-installer
 Architecture: any
-XC-Package-Type: udeb
-Depends: ${shlibs:Depends}, configured-network
+Depends: ${shlibs:Depends}, ethernet-card-detection, ppp-modules
+Provides: configured-network
+XB-Installer-Menu-Item: 18
 Description: Point-to-Point Protocol (PPP) daemon
  The Point-to-Point Protocol (PPP) provides a standard way to transmit
  datagrams over a serial link, as well as a standard way for the machines
diff -ruN ppp-2.4.4b1/debian/ppp-udeb.postinst ppp-2.4.4b1-fix-templates-and-error-logging/debian/ppp-udeb.postinst
--- ppp-2.4.4b1/debian/ppp-udeb.postinst	2006-05-23 08:01:28.000000000 +0300
+++ ppp-2.4.4b1-fix-templates-and-error-logging/debian/ppp-udeb.postinst	2006-05-22 00:43:36.000000000 +0300
@@ -3,19 +3,78 @@
 . /usr/share/debconf/confmodule
 
 INTERFACES=$(grep : /proc/net/dev | cut -d':' -f1 | sort | sed -e 's/ *//' | grep -E '^(eth|nas|tap|nic-)')
-INTERFACES=$(echo $INTERFACES | sed -e 's/ /, /g')
+
+not_already_up ()
+{
+	ISUP=$(ifconfig | egrep "^$1[[:space:]]" | wc -l)
+	return $ISUP
+}
+
+ppp_concentrator_on ()
+{
+	db_subst ppp/detect_progress IFACE "${IFACE}" || true
+	PPPUP=no
+	if not_already_up $1
+	then
+		logger -t ppp-udeb "$IFACE was not configured; ppp-udeb will bring it up"
+		PPPUP=yes
+		ifconfig $IFACE up
+		# TODO: push this in background and display a progress bar
+		MAXWAIT=20
+		db_progress START 0 $MAXWAIT ppp/detect_progress
+		( R=`pppoe-discovery -A -U -I $IFACE|grep AC|wc -l` ; touch /tmp/probe-finished` ) &
+		WAIT=0
+		while [ ! -f /tmp/probe-finished -a $WAIT -lt $MAXWAIT ] ; do
+			sleep 1
+			db_progress STEP 1
+		done
+		PROCESS=$(ps -A | grep pppoe-discovery | sed s:^[[:space:]]::g | cut -f1 -d' ') || true
+		if [ ! -z $PROCESS ] ; then kill $PROCESS || true ; fi || true
+		rm -f /tmp/probe-finished || true
+		db_progress STOP
+		if [ $R -ne 0 ]
+		then
+			return 0
+		else
+			return 1
+		fi
+	fi
+}
 
 if [ -z "$INTERFACES" ]; then
-  # XXX FIXME
-  echo "No ethernet interfaces found!"
+  db_input critical ppp/detect_failed || true
+  db_go || true
   exit 1
 fi
 
-db_subst ppp/interface INTERFACES "$INTERFACES"
-db_input high ppp/interface || true
-db_go || true
-db_get ppp/interface
-INTERFACE="$RET"
+# test each of the interfaces for a concentrator,
+# then stop when one is found.
+
+for IFACE in $INTERFACES
+do
+	if ppp_concentrator_on $IFACE
+	then
+		logger -t ppp-udeb "setting pppoe connection on $IFACE"
+		db_set ppp/interface $IFACE
+		break
+	else
+		if [ z$PPPUP = zyes ]
+		then
+			logger -t ppp-udeb "no concentrator found on $IFACE; will bring the interface back down"
+			ifconfig $IFACE down
+		else
+			logger -t "ppp-udeb no concentrator found on $IFACE"
+		fi
+		IFACE=''
+	fi
+done
+
+if [ z$IFACE = z ]
+then
+	db_input critical ppp/no_concentrators || true
+	db_go || true
+	exit 1
+fi
 
 db_input high ppp/username || true
 db_go || true
@@ -29,7 +88,8 @@
 
 # XXX just to be sure that the answers will not be cached if the script
 # is run a second time
-db_purge
+db_unregister ppp/password
+db_unregister ppp/username
 
 db_stop
 
@@ -47,7 +107,7 @@
 
 # Load the pppoe plugin. Change the ethernet interface name if needed.
 plugin rp-pppoe.so
-$INTERFACE
+$IFACE
 
 # Assumes that your IP address is allocated dynamically by the ISP.
 noipdefault
@@ -76,16 +136,31 @@
 novj
 EOF
 
+touch /etc/ppp/pap-secrets
+chmod 600 /etc/ppp/pap-secrets || true
 cat <<EOF > /etc/ppp/pap-secrets
 #GENERATED-BY-DEBIAN-INSTALLER#
 $USERNAME	*	$PASSWORD
 EOF
 cp /etc/ppp/pap-secrets /etc/ppp/chap-secrets
 
+modprobe pppoe
+
+# FIXME: bring down the pppoe connection if that already exists,
+# but only our pppoe connection to ensure idempotency, otherwise one
+# might end up with more than one pppoe connection on the same IFACE
+
+if [ ! -z "$PPPOE" ] ; then ifconfig $PPPOE down ; fi || true
 pppd call pppoe
+# FIXME: detect the ppp connection that was brought up
+# db_set ppp/pppoe_pair "$IFACE:$PPPOE"
+# this can't be done because db_stop was called earlier. or?
 
 # FIXME - how can this be improved?
-ln -s /etc/ppp/resolv.conf /etc/resolv.conf
+if [ ! -e /etc/resolv.conf ]
+then
+	ln -s /etc/ppp/resolv.conf /etc/resolv.conf
+fi
 
 #DEBHELPER#
 
Binary files ppp-2.4.4b1/debian/.ppp-udeb.postinst.swp and ppp-2.4.4b1-fix-templates-and-error-logging/debian/.ppp-udeb.postinst.swp differ
diff -ruN ppp-2.4.4b1/debian/ppp-udeb.templates ppp-2.4.4b1-fix-templates-and-error-logging/debian/ppp-udeb.templates
--- ppp-2.4.4b1/debian/ppp-udeb.templates	2006-05-23 08:01:28.000000000 +0300
+++ ppp-2.4.4b1-fix-templates-and-error-logging/debian/ppp-udeb.templates	2006-05-21 13:30:15.000000000 +0300
@@ -1,17 +1,59 @@
 Template: debian-installer/ppp-udeb/title
 Type: text
+#  Main menu item
 _Description: Configure and start PPPoE networking
 
-Template: ppp/interface
-Type: select
-Choices: ${INTERFACES}
-_Description: Interface name
- Choose the name of the network interface connected to your PPPoE modem.
+Template: ppp/no_concentrators
+Type: error
+_Description: Concentrator detection failed
+ No concentrator was found while trying to configure PPPoE. The PPPoE
+ connections can be automatically detected by searching for a concentrator.
+ .
+ This was attempted on all known network interfaces in the system, but
+ the installer was not able to detect a concentrator.
+ .
+ If the system has a PPPoE connection, and it was not detected, then probably
+ you should check that connection cables are properly plugged in.
+ .
+ The configuration of PPPoE will be aborted. You can try to configure it again
+ later by selecting the main menu entry \"Configure and start PPPoE 
+ networking\".
 
 Template: ppp/username
 Type: string
-_Description: Your username
+_Description: Your PPPoE username
+ Please enter here the username for the PPPoE connection made over the ${IFACE}
+ network interface.
+ .
+ This information should have been provided by your ISP or the administrator
+  of the PPPoE connection you use.
 
 Template: ppp/password
 Type: password
-_Description: Your password
+_Description: Your PPPoE password
+ Please enter here the password for the PPPoE connection made over the ${IFACE}
+ network interface.
+ .
+ This information should have been provided by your ISP or the administrator
+  of the PPPoE connection you use.
+
+Template: ppp/detect_failed
+Type: error
+_Description: Ethernet card detection failed
+ No Ethernet card was detected. In order to configure PPPoE on the system,
+  at least one Ethernet card is needed.
+ .
+ If the system does have an Ethernet card, then this could mean that
+ it was not detected by the installer.
+ .
+ Also, please note that currently the installer does not support automatic
+ configuration of dial-up connections and this kind of configuration should
+ be done manually.
+ .
+ The configuration of PPPoE will be aborted. You can try to configure it again
+ later by selecting the main menu entry \"Configure and start PPPoE 
+ networking\".
+
+Template: ppp/detect_progress
+Type: progress
+_Description: Seaching concentrators on ${IFACE}
diff -ruN ppp-2.4.4b1/debian/rules ppp-2.4.4b1-fix-templates-and-error-logging/debian/rules
--- ppp-2.4.4b1/debian/rules	2006-05-23 08:01:28.000000000 +0300
+++ ppp-2.4.4b1-fix-templates-and-error-logging/debian/rules	2006-05-22 18:42:50.000000000 +0300
@@ -140,15 +140,18 @@
 
 ifdef BUILD_UDEB
 	dh_installdirs -p ppp-udeb etc/ppp/peers/ usr/sbin/ \
-		usr/lib/pppd/$(PPPDDIR)/ usr/lib/prebaseconfig.d/
+		usr/lib/pppd/$(PPPDDIR)/ usr/lib/finish-install.d/
 	grep '^[a-zA-Z0-9]' extra/options > $D-udeb/etc/ppp/options
 #	cp $B/chat/chat $D-udeb/usr/sbin/
 	cp $B/pppd-udeb/pppd $D-udeb/usr/sbin/
 	cp $B/pppd-udeb/pppd $D-udeb/usr/sbin/
+	cp $B/pppd-udeb/plugins/rp-pppoe/pppoe-discovery \
+		$D-udeb/usr/sbin/
 	cp $B/pppd-udeb/plugins/rp-pppoe/rp-pppoe.so \
 		$B/pppd-udeb/plugins/pppoatm/pppoatm.so \
 		$D-udeb/usr/lib/pppd/$(PPPDDIR)/
-	cp extra/prebaseconfig $D-udeb/usr/lib/prebaseconfig.d/60pppoe
+	cp extra/50config-target-ppp $D-udeb/usr/lib/finish-install.d/
+	dh_installdebconf
 endif
 
 	dh_strip		-a
diff -ruN ppp-2.4.4b1/extra/50config-target-ppp ppp-2.4.4b1-fix-templates-and-error-logging/extra/50config-target-ppp
--- ppp-2.4.4b1/extra/50config-target-ppp	1970-01-01 02:00:00.000000000 +0200
+++ ppp-2.4.4b1-fix-templates-and-error-logging/extra/50config-target-ppp	2006-05-16 22:13:38.000000000 +0300
@@ -0,0 +1,14 @@
+#! /bin/sh
+#
+# Make sure that the ppp configuration is copied to the target 
+# system. If the configuration was ok during install, surely it
+# will be good after the install, too.
+
+set -e
+
+if [ ! -d /target/etc/ppp ] ; then
+    mkdir -p /target/etc/ppp || true
+fi
+
+cp -R -p all /etc/ppp /target/etc || true
+
diff -ruN ppp-2.4.4b1/extra/prebaseconfig ppp-2.4.4b1-fix-templates-and-error-logging/extra/prebaseconfig
--- ppp-2.4.4b1/extra/prebaseconfig	2006-05-23 08:01:28.000000000 +0300
+++ ppp-2.4.4b1-fix-templates-and-error-logging/extra/prebaseconfig	1970-01-01 02:00:00.000000000 +0200
@@ -1,11 +0,0 @@
-#!/bin/sh -e
-
-if [ -e /etc/ppp/pap-secrets -a -e /etc/ppp/chap-secrets -a \
-     -e /etc/ppp/peers/pppoe ]; then
-  mkdir /target/etc/ppp/ /target/etc/ppp/peers/
-  cp /etc/ppp/pap-secrets  /target/etc/ppp/pap-secrets
-  cp /etc/ppp/chap-secrets /target/etc/ppp/chap-secrets
-  chmod 600 /target/etc/ppp/*-secrets
-  cp /etc/ppp/peers/pppoe /target/etc/ppp/peers/
-fi
-
