Index: debian/bitlbee-common.config
===================================================================
--- debian/bitlbee-common.config	(revision 4c0388134ff88b72e343bd07013554480c2a4ef7)
+++ debian/bitlbee-common.config	(revision 4c0388134ff88b72e343bd07013554480c2a4ef7)
@@ -0,0 +1,25 @@
+#!/bin/sh -e
+
+. /usr/share/debconf/confmodule
+[ -f /etc/default/bitlbee ] && . /etc/default/bitlbee
+
+db_title BitlBee
+
+if [ -n "$BITLBEE_PORT" ]; then
+	db_set bitlbee/serveport "$BITLBEE_PORT"
+else
+	db_get bitlbee/serveport
+	if [ "$RET" = "stillhavetoask" ]; then
+		listens=$(netstat -ltn | awk '{print $4}')
+		for port in 6667 6666 6668 6669; do
+			if [ $(expr "$listens " : ".*:$port\s") = "0" ]; then
+				break
+			fi
+		done
+		db_set bitlbee/serveport $port;
+	fi
+fi
+
+if db_input medium bitlbee/serveport; then
+	db_go;
+fi
Index: debian/bitlbee-common.templates
===================================================================
--- debian/bitlbee-common.templates	(revision 4c0388134ff88b72e343bd07013554480c2a4ef7)
+++ debian/bitlbee-common.templates	(revision 4c0388134ff88b72e343bd07013554480c2a4ef7)
@@ -0,0 +1,8 @@
+Template: bitlbee/serveport
+Type: string
+Default: stillhavetoask
+_Description: On what TCP port should BitlBee listen for connections?
+ BitlBee normally listens on the regular IRC port, 6667. This might not be
+ a very good idea when you're running a real IRC daemon as well. 6668 might
+ be a good alternative. Leaving this value blank means that BitlBee will not
+ be run automatically.
Index: debian/bitlbee.postinst
===================================================================
--- debian/bitlbee.postinst	(revision 4c0388134ff88b72e343bd07013554480c2a4ef7)
+++ debian/bitlbee.postinst	(revision 4c0388134ff88b72e343bd07013554480c2a4ef7)
@@ -0,0 +1,102 @@
+#!/bin/sh -e
+
+. /usr/share/debconf/confmodule
+
+db_get bitlbee/serveport
+PORT="$RET"
+
+CONFDIR=/var/lib/bitlbee/
+
+update-rc.d bitlbee defaults > /dev/null 2>&1
+
+## Load default option. Don't want to put this in debconf (yet?)
+BITLBEE_OPTS=-F
+BITLBEE_DISABLED=0
+BITLBEE_UPGRADE_DONT_RESTART=0
+[ -r /etc/default/bitlbee ] && . /etc/default/bitlbee
+
+if [ "$BITLBEE_DISABLED" = "0" ] && type update-inetd > /dev/null 2> /dev/null &&
+   ( expr "$2" : '0\..*' > /dev/null || expr "$2" : '1\.0\..*' > /dev/null ); then
+	## Make sure the inetd entry is gone (can still be there from a
+	## previous version.
+	update-inetd --remove '.*/usr/sbin/bitlbee'
+	if grep -q /usr/sbin/bitlbee /etc/inetd.conf 2> /dev/null; then
+		# Thanks for breaking update-inetd! (bugs.debian.org/311111)
+		# I hope that it works at least with xinetd, because this
+		# emergency hack doesn't:
+		perl -pi -e 's:^[^#].*/usr/sbin/bitlbee$:## Now using daemon mode\: # $&:' /etc/inetd.conf
+		killall -HUP inetd || true
+	fi
+fi
+
+cat<<EOF>/etc/default/bitlbee
+## /etc/default/bitlbee: Auto-generated/updated script.
+##
+## If running in (fork)daemon mode, listen on this TCP port.
+BITLBEE_PORT="$PORT"
+
+## Use single-process or forking daemon mode? Can't be changed from debconf,
+## but maintainer scripts will save your changes here.
+BITLBEE_OPTS="$BITLBEE_OPTS"
+
+## In case you want to stick with inetd mode (or if you just want to disable
+## the init scripts for some other reason), you can disable the init script
+## here. (Just set it to 1)
+BITLBEE_DISABLED=$BITLBEE_DISABLED
+
+## As a server operator, you can use the RESTART command to restart only the
+## master process while keeping all the child processes and their IPC
+## connections. By enabling this, the maintainer scripts won't restart
+## BitlBee during upgrades so you can restart the master process by hand.
+BITLBEE_UPGRADE_DONT_RESTART=$BITLBEE_UPGRADE_DONT_RESTART
+EOF
+
+## Bye-bye DebConf, we don't need you anymore.
+db_stop
+
+## Restore the helpfile in case we weren't upgrading but just reconfiguring:
+if [ -e /usr/share/bitlbee/help.upgrading ]; then
+	if [ -e /usr/share/bitlbee/help.txt ]; then
+		rm -f /usr/share/bitlbee/help.upgrading
+	else
+		mv /usr/share/bitlbee/help.upgrading /usr/share/bitlbee/help.txt
+	fi
+fi
+
+if [ -n "$2" -a "$BITLBEE_UPGRADE_DONT_RESTART" != "1" ]; then
+	if which invoke-rc.d >/dev/null 2>&1; then
+		invoke-rc.d bitlbee restart
+	else
+		/etc/init.d/bitlbee restart
+	fi
+fi
+
+## If we're upgrading, we'll probably skip this next part
+if [ -d $CONFDIR ] && chown -R bitlbee: $CONFDIR; then
+	echo 'BitlBee (probably) already installed, skipping user/configdir installation'
+	exit 0
+fi
+
+adduser --system --group --disabled-login --disabled-password --home /var/lib/bitlbee/ bitlbee
+chmod 700 /var/lib/bitlbee/
+
+## Can't do this in packaging phase: Don't know the UID yet. Access to
+## the file should be limited, now that it stores passwords. Added
+## --group later for a little more security, but have to see if I can
+## apply this change to existing installations on upgrades. Will think
+## about that later.
+if getent group bitlbee > /dev/null; then
+	chmod 640 /etc/bitlbee/bitlbee.conf
+	chown root:bitlbee /etc/bitlbee/bitlbee.conf
+else
+	chmod 600 /etc/bitlbee/bitlbee.conf
+	chown bitlbee /etc/bitlbee/bitlbee.conf
+fi
+
+if [ -z "$2" ]; then
+	if which invoke-rc.d >/dev/null 2>&1; then
+		invoke-rc.d bitlbee start
+	else
+		/etc/init.d/bitlbee start
+	fi
+fi
Index: debian/bitlbee.postrm
===================================================================
--- debian/bitlbee.postrm	(revision 4c0388134ff88b72e343bd07013554480c2a4ef7)
+++ debian/bitlbee.postrm	(revision 4c0388134ff88b72e343bd07013554480c2a4ef7)
@@ -0,0 +1,14 @@
+#!/bin/sh -e
+
+[ "$1" = "purge" ] || exit 0
+
+if [ -e /usr/share/debconf/confmodule ]; then
+	. /usr/share/debconf/confmodule;
+	db_purge;
+fi
+
+update-rc.d bitlbee remove > /dev/null 2>&1 || true
+rm -f /etc/default/bitlbee
+
+deluser --system --remove-home bitlbee || true
+rm -rf /var/lib/bitlbee ## deluser doesn't seem to do this for homedirs in /var
Index: debian/bitlbee.prerm
===================================================================
--- debian/bitlbee.prerm	(revision 4c0388134ff88b72e343bd07013554480c2a4ef7)
+++ debian/bitlbee.prerm	(revision 4c0388134ff88b72e343bd07013554480c2a4ef7)
@@ -0,0 +1,17 @@
+#!/bin/sh -e
+
+if [ "$1" = "upgrade" ]; then
+	## To prevent the help function from breaking in currently running
+	## BitlBee processes. Have to do it like this because dpkg-reconfigure
+	## looks a lot like an upgrade and we don't want to lose help.txt...
+	if [ -e /usr/share/bitlbee/help.txt ]; then
+		rm -f /usr/share/bitlbee/help.upgrading
+		mv /usr/share/bitlbee/help.txt /usr/share/bitlbee/help.upgrading
+	fi
+else
+	if which invoke-rc.d >/dev/null 2>&1; then
+		invoke-rc.d bitlbee stop || exit 0
+	else
+		/etc/init.d/bitlbee stop || exit 0
+	fi
+fi
Index: debian/config
===================================================================
--- debian/config	(revision 095a5f046c36c4cff689305fef81533a9e9603fc)
+++ 	(revision )
@@ -1,25 +1,0 @@
-#!/bin/sh -e
-
-. /usr/share/debconf/confmodule
-[ -f /etc/default/bitlbee ] && . /etc/default/bitlbee
-
-db_title BitlBee
-
-if [ -n "$BITLBEE_PORT" ]; then
-	db_set bitlbee/serveport "$BITLBEE_PORT"
-else
-	db_get bitlbee/serveport
-	if [ "$RET" = "stillhavetoask" ]; then
-		listens=$(netstat -ltn | awk '{print $4}')
-		for port in 6667 6666 6668 6669; do
-			if [ $(expr "$listens " : ".*:$port\s") = "0" ]; then
-				break
-			fi
-		done
-		db_set bitlbee/serveport $port;
-	fi
-fi
-
-if db_input medium bitlbee/serveport; then
-	db_go;
-fi
Index: debian/control
===================================================================
--- debian/control	(revision 095a5f046c36c4cff689305fef81533a9e9603fc)
+++ debian/control	(revision 4c0388134ff88b72e343bd07013554480c2a4ef7)
@@ -5,5 +5,5 @@
 Uploaders: Jelmer Vernooij <jelmer@samba.org>
 Standards-Version: 3.8.4
-Build-Depends: libglib2.0-dev (>= 2.4), libevent-dev, libgnutls-dev | libnss-dev (>= 1.6), debconf-2.0, po-debconf, libpurple-dev
+Build-Depends: libglib2.0-dev (>= 2.4), libevent-dev, libgnutls-dev | libnss-dev (>= 1.6), po-debconf, libpurple-dev, debhelper (>= 7)
 Homepage: http://www.bitlbee.org/
 Vcs-Bzr: http://code.bitlbee.org/bitlbee/
@@ -12,5 +12,7 @@
 Package: bitlbee
 Architecture: any
-Depends: ${shlibs:Depends}, adduser, net-tools, debianutils (>= 1.16), bitlbee-common (>= ${source:Version}), bitlbee-common (<< ${source:Version}.1~)
+Depends: ${shlibs:Depends}, adduser, debianutils (>= 1.16), bitlbee-common (= ${source:Version})
+Conflicts: bitlbee-libpurple
+Replaces: bitlbee-libpurple
 Description: An IRC to other chat networks gateway
  This program can be used as an IRC server which forwards everything you
@@ -19,5 +21,7 @@
 Package: bitlbee-libpurple
 Architecture: any
-Depends: ${shlibs:Depends}, adduser, net-tools, debianutils (>= 1.16), bitlbee-common (>= ${source:Version}), bitlbee-common (<< ${source:Version}.1~)
+Depends: ${shlibs:Depends}, adduser, debianutils (>= 1.16), bitlbee-common (= ${source:Version})
+Conflicts: bitlbee
+Replaces: bitlbee
 Description: An IRC to other chat networks gateway
  This program can be used as an IRC server which forwards everything you
@@ -34,5 +38,6 @@
 Package: bitlbee-common
 Architecture: all
-Replaces: bitlbee (<= 1.3)
+Depends: ${misc:Depends}, net-tools
+Replaces: bitlbee
 Description: An IRC to other chat networks gateway
  This program can be used as an IRC server which forwards everything you
@@ -44,5 +49,5 @@
 Package: bitlbee-dev
 Architecture: all
-Depends: bitlbee (>= ${source:Version}), bitlbee (<< ${source:Version}.1~)
+Depends: ${misc:Depends}, bitlbee (>= ${source:Version}), bitlbee (<< ${source:Version}.1~)
 Description: An IRC to other chat networks gateway
  This program can be used as an IRC server which forwards everything you
Index: debian/postinst
===================================================================
--- debian/postinst	(revision 095a5f046c36c4cff689305fef81533a9e9603fc)
+++ 	(revision )
@@ -1,102 +1,0 @@
-#!/bin/sh -e
-
-. /usr/share/debconf/confmodule
-
-db_get bitlbee/serveport
-PORT="$RET"
-
-CONFDIR=/var/lib/bitlbee/
-
-update-rc.d bitlbee defaults > /dev/null 2>&1
-
-## Load default option. Don't want to put this in debconf (yet?)
-BITLBEE_OPTS=-F
-BITLBEE_DISABLED=0
-BITLBEE_UPGRADE_DONT_RESTART=0
-[ -r /etc/default/bitlbee ] && . /etc/default/bitlbee
-
-if [ "$BITLBEE_DISABLED" = "0" ] && type update-inetd > /dev/null 2> /dev/null &&
-   ( expr "$2" : '0\..*' > /dev/null || expr "$2" : '1\.0\..*' > /dev/null ); then
-	## Make sure the inetd entry is gone (can still be there from a
-	## previous version.
-	update-inetd --remove '.*/usr/sbin/bitlbee'
-	if grep -q /usr/sbin/bitlbee /etc/inetd.conf 2> /dev/null; then
-		# Thanks for breaking update-inetd! (bugs.debian.org/311111)
-		# I hope that it works at least with xinetd, because this
-		# emergency hack doesn't:
-		perl -pi -e 's:^[^#].*/usr/sbin/bitlbee$:## Now using daemon mode\: # $&:' /etc/inetd.conf
-		killall -HUP inetd || true
-	fi
-fi
-
-cat<<EOF>/etc/default/bitlbee
-## /etc/default/bitlbee: Auto-generated/updated script.
-##
-## If running in (fork)daemon mode, listen on this TCP port.
-BITLBEE_PORT="$PORT"
-
-## Use single-process or forking daemon mode? Can't be changed from debconf,
-## but maintainer scripts will save your changes here.
-BITLBEE_OPTS="$BITLBEE_OPTS"
-
-## In case you want to stick with inetd mode (or if you just want to disable
-## the init scripts for some other reason), you can disable the init script
-## here. (Just set it to 1)
-BITLBEE_DISABLED=$BITLBEE_DISABLED
-
-## As a server operator, you can use the RESTART command to restart only the
-## master process while keeping all the child processes and their IPC
-## connections. By enabling this, the maintainer scripts won't restart
-## BitlBee during upgrades so you can restart the master process by hand.
-BITLBEE_UPGRADE_DONT_RESTART=$BITLBEE_UPGRADE_DONT_RESTART
-EOF
-
-## Bye-bye DebConf, we don't need you anymore.
-db_stop
-
-## Restore the helpfile in case we weren't upgrading but just reconfiguring:
-if [ -e /usr/share/bitlbee/help.upgrading ]; then
-	if [ -e /usr/share/bitlbee/help.txt ]; then
-		rm -f /usr/share/bitlbee/help.upgrading
-	else
-		mv /usr/share/bitlbee/help.upgrading /usr/share/bitlbee/help.txt
-	fi
-fi
-
-if [ -n "$2" -a "$BITLBEE_UPGRADE_DONT_RESTART" != "1" ]; then
-	if which invoke-rc.d >/dev/null 2>&1; then
-		invoke-rc.d bitlbee restart
-	else
-		/etc/init.d/bitlbee restart
-	fi
-fi
-
-## If we're upgrading, we'll probably skip this next part
-if [ -d $CONFDIR ] && chown -R bitlbee: $CONFDIR; then
-	echo 'BitlBee (probably) already installed, skipping user/configdir installation'
-	exit 0
-fi
-
-adduser --system --group --disabled-login --disabled-password --home /var/lib/bitlbee/ bitlbee
-chmod 700 /var/lib/bitlbee/
-
-## Can't do this in packaging phase: Don't know the UID yet. Access to
-## the file should be limited, now that it stores passwords. Added
-## --group later for a little more security, but have to see if I can
-## apply this change to existing installations on upgrades. Will think
-## about that later.
-if getent group bitlbee > /dev/null; then
-	chmod 640 /etc/bitlbee/bitlbee.conf
-	chown root:bitlbee /etc/bitlbee/bitlbee.conf
-else
-	chmod 600 /etc/bitlbee/bitlbee.conf
-	chown bitlbee /etc/bitlbee/bitlbee.conf
-fi
-
-if [ -z "$2" ]; then
-	if which invoke-rc.d >/dev/null 2>&1; then
-		invoke-rc.d bitlbee start
-	else
-		/etc/init.d/bitlbee start
-	fi
-fi
Index: debian/postrm
===================================================================
--- debian/postrm	(revision 095a5f046c36c4cff689305fef81533a9e9603fc)
+++ 	(revision )
@@ -1,14 +1,0 @@
-#!/bin/sh -e
-
-[ "$1" = "purge" ] || exit 0
-
-if [ -e /usr/share/debconf/confmodule ]; then
-	. /usr/share/debconf/confmodule;
-	db_purge;
-fi
-
-update-rc.d bitlbee remove > /dev/null 2>&1 || true
-rm -f /etc/default/bitlbee
-
-deluser --system --remove-home bitlbee || true
-rm -rf /var/lib/bitlbee ## deluser doesn't seem to do this for homedirs in /var
Index: debian/prerm
===================================================================
--- debian/prerm	(revision 095a5f046c36c4cff689305fef81533a9e9603fc)
+++ 	(revision )
@@ -1,17 +1,0 @@
-#!/bin/sh -e
-
-if [ "$1" = "upgrade" ]; then
-	## To prevent the help function from breaking in currently running
-	## BitlBee processes. Have to do it like this because dpkg-reconfigure
-	## looks a lot like an upgrade and we don't want to lose help.txt...
-	if [ -e /usr/share/bitlbee/help.txt ]; then
-		rm -f /usr/share/bitlbee/help.upgrading
-		mv /usr/share/bitlbee/help.txt /usr/share/bitlbee/help.upgrading
-	fi
-else
-	if which invoke-rc.d >/dev/null 2>&1; then
-		invoke-rc.d bitlbee stop || exit 0
-	else
-		/etc/init.d/bitlbee stop || exit 0
-	fi
-fi
Index: debian/rules
===================================================================
--- debian/rules	(revision 095a5f046c36c4cff689305fef81533a9e9603fc)
+++ debian/rules	(revision 4c0388134ff88b72e343bd07013554480c2a4ef7)
@@ -11,7 +11,5 @@
 DEBUG ?= 0
 
-ifdef BITLBEE_VERSION
-BITLBEE_FORCE_VERSION=1
-else
+ifndef BITLBEE_VERSION
 # Want to use the full package version number instead of just the release.
 BITLBEE_CONFIGURE_VERSION ?= BITLBEE_VERSION=\"$(shell dpkg-parsechangelog | grep ^Version: | awk '{print $$2}')\"
@@ -68,4 +66,7 @@
 	dh_installdebconf
 	dh_installinit
+ifeq ($(DH_OPTIONS),-a)
+	cp -a debian/bitlbee/etc debian/bitlbee-libpurple
+endif
 	dh_installman
 	dh_strip
@@ -74,6 +75,9 @@
 	dh_fixperms
 	dh_installdeb
+ifeq ($(DH_OPTIONS),-a)
+	cp -a debian/bitlbee/DEBIAN/{post,pre}* debian/bitlbee-libpurple/DEBIAN
+endif
 	dh_shlibdeps
-ifdef BITLBEE_FORCE_VERSION
+ifdef BITLBEE_VERSION
 	dh_gencontrol -- -v1:$(BITLBEE_VERSION)-0
 else
Index: debian/templates
===================================================================
--- debian/templates	(revision 095a5f046c36c4cff689305fef81533a9e9603fc)
+++ 	(revision )
@@ -1,8 +1,0 @@
-Template: bitlbee/serveport
-Type: string
-Default: stillhavetoask
-_Description: On what TCP port should BitlBee listen for connections?
- BitlBee normally listens on the regular IRC port, 6667. This might not be
- a very good idea when you're running a real IRC daemon as well. 6668 might
- be a good alternative. Leaving this value blank means that BitlBee will not
- be run automatically.
