Index: debian/bitlbee-common.init
===================================================================
--- debian/bitlbee-common.init	(revision 5b94e9ecc30e9f3b96c083e41235e4df2d0d75c9)
+++ debian/bitlbee-common.init	(revision 5b94e9ecc30e9f3b96c083e41235e4df2d0d75c9)
@@ -0,0 +1,88 @@
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides:          bitlbee
+# Required-Start:    $remote_fs $syslog
+# Required-Stop:     $remote_fs $syslog
+# Default-Start:     2 3 4 5
+# Default-Stop:      1
+### END INIT INFO
+#
+# Init script for BitlBee Debian package. Based on skeleton init script:
+#
+# Version:	@(#)skeleton  2.85-23  28-Jul-2004  miquels@cistron.nl
+#
+
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+DESC="BitlBee IRC/IM gateway"
+NAME=bitlbee
+DAEMON=/usr/sbin/$NAME
+PIDFILE=/var/run/$NAME.pid
+SCRIPTNAME=/etc/init.d/$NAME
+
+# Gracefully exit if the package has been removed.
+[ -x $DAEMON ] || exit 0
+
+# Default value
+BITLBEE_PORT=6667
+BITLBEE_OPTS=-F
+
+# Read config file if it is present.
+if [ -r /etc/default/$NAME ]; then
+	. /etc/default/$NAME
+fi
+
+
+#
+#	Function that starts the daemon/service.
+#
+d_start() {
+	# Make sure BitlBee can actually write its PID...
+	touch $PIDFILE
+	chown bitlbee: $PIDFILE
+	
+	start-stop-daemon --start --quiet --pidfile $PIDFILE \
+		--exec $DAEMON -- -p $BITLBEE_PORT -P $PIDFILE $BITLBEE_OPTS
+}
+
+#
+#	Function that stops the daemon/service.
+#
+d_stop() {
+	start-stop-daemon --stop --quiet --pidfile $PIDFILE \
+		--name $NAME
+}
+
+
+case "$1" in
+  start)
+	[ "$BITLBEE_DISABLED" = "1" ] && exit 0
+
+	echo -n "Starting $DESC: $NAME"
+	d_start
+	echo "."
+	;;
+  stop)
+	echo -n "Stopping $DESC: $NAME"
+	d_stop
+	echo "."
+	;;
+  #reload)
+	#
+	#	No reload target, but there's a REHASH command which we
+	#	might use later...
+	#
+  #;;
+  restart|force-reload)
+	echo -n "Restarting $DESC: $NAME"
+	d_stop
+	sleep 1
+	d_start
+	echo "."
+	;;
+  *)
+	echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
+	exit 1
+	;;
+esac
+
+exit 0
Index: debian/bitlbee-common.postinst
===================================================================
--- debian/bitlbee-common.postinst	(revision 5b94e9ecc30e9f3b96c083e41235e4df2d0d75c9)
+++ debian/bitlbee-common.postinst	(revision 5b94e9ecc30e9f3b96c083e41235e4df2d0d75c9)
@@ -0,0 +1,94 @@
+#!/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
+	invoke-rc.d bitlbee restart
+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
+	invoke-rc.d bitlbee start
+fi
Index: debian/bitlbee-common.postrm
===================================================================
--- debian/bitlbee-common.postrm	(revision 5b94e9ecc30e9f3b96c083e41235e4df2d0d75c9)
+++ debian/bitlbee-common.postrm	(revision 5b94e9ecc30e9f3b96c083e41235e4df2d0d75c9)
@@ -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-common.prerm
===================================================================
--- debian/bitlbee-common.prerm	(revision 5b94e9ecc30e9f3b96c083e41235e4df2d0d75c9)
+++ debian/bitlbee-common.prerm	(revision 5b94e9ecc30e9f3b96c083e41235e4df2d0d75c9)
@@ -0,0 +1,13 @@
+#!/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
+	invoke-rc.d bitlbee stop || exit 0
+fi
Index: debian/bitlbee.init
===================================================================
--- debian/bitlbee.init	(revision d20ea9f92f70fa9732baf4520582abfc45124548)
+++ 	(revision )
@@ -1,88 +1,0 @@
-#! /bin/sh
-### BEGIN INIT INFO
-# Provides:          bitlbee
-# Required-Start:    $remote_fs $syslog
-# Required-Stop:     $remote_fs $syslog
-# Default-Start:     2 3 4 5
-# Default-Stop:      1
-### END INIT INFO
-#
-# Init script for BitlBee Debian package. Based on skeleton init script:
-#
-# Version:	@(#)skeleton  2.85-23  28-Jul-2004  miquels@cistron.nl
-#
-
-PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
-DESC="BitlBee IRC/IM gateway"
-NAME=bitlbee
-DAEMON=/usr/sbin/$NAME
-PIDFILE=/var/run/$NAME.pid
-SCRIPTNAME=/etc/init.d/$NAME
-
-# Gracefully exit if the package has been removed.
-[ -x $DAEMON ] || exit 0
-
-# Default value
-BITLBEE_PORT=6667
-BITLBEE_OPTS=-F
-
-# Read config file if it is present.
-if [ -r /etc/default/$NAME ]; then
-	. /etc/default/$NAME
-fi
-
-
-#
-#	Function that starts the daemon/service.
-#
-d_start() {
-	# Make sure BitlBee can actually write its PID...
-	touch $PIDFILE
-	chown bitlbee: $PIDFILE
-	
-	start-stop-daemon --start --quiet --pidfile $PIDFILE \
-		--exec $DAEMON -- -p $BITLBEE_PORT -P $PIDFILE $BITLBEE_OPTS
-}
-
-#
-#	Function that stops the daemon/service.
-#
-d_stop() {
-	start-stop-daemon --stop --quiet --pidfile $PIDFILE \
-		--name $NAME
-}
-
-
-case "$1" in
-  start)
-	[ "$BITLBEE_DISABLED" = "1" ] && exit 0
-
-	echo -n "Starting $DESC: $NAME"
-	d_start
-	echo "."
-	;;
-  stop)
-	echo -n "Stopping $DESC: $NAME"
-	d_stop
-	echo "."
-	;;
-  #reload)
-	#
-	#	No reload target, but there's a REHASH command which we
-	#	might use later...
-	#
-  #;;
-  restart|force-reload)
-	echo -n "Restarting $DESC: $NAME"
-	d_stop
-	sleep 1
-	d_start
-	echo "."
-	;;
-  *)
-	echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
-	exit 1
-	;;
-esac
-
-exit 0
Index: debian/bitlbee.postinst
===================================================================
--- debian/bitlbee.postinst	(revision d20ea9f92f70fa9732baf4520582abfc45124548)
+++ 	(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/bitlbee.postrm
===================================================================
--- debian/bitlbee.postrm	(revision d20ea9f92f70fa9732baf4520582abfc45124548)
+++ 	(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/bitlbee.prerm
===================================================================
--- debian/bitlbee.prerm	(revision d20ea9f92f70fa9732baf4520582abfc45124548)
+++ debian/bitlbee.prerm	(revision 5b94e9ecc30e9f3b96c083e41235e4df2d0d75c9)
@@ -1,17 +1,5 @@
 #!/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
+if [ "$1" != "upgrade" ]; then
+	invoke-rc.d bitlbee stop || exit 0
 fi
Index: debian/changelog
===================================================================
--- debian/changelog	(revision d20ea9f92f70fa9732baf4520582abfc45124548)
+++ debian/changelog	(revision 5b94e9ecc30e9f3b96c083e41235e4df2d0d75c9)
@@ -1,3 +1,3 @@
-bitlbee (1.3-0) unstable; urgency=low
+bitlbee (1.3-1) unstable; urgency=low
 
   * Setting some bogus version number, fix that later.
Index: debian/rules
===================================================================
--- debian/rules	(revision d20ea9f92f70fa9732baf4520582abfc45124548)
+++ debian/rules	(revision 5b94e9ecc30e9f3b96c083e41235e4df2d0d75c9)
@@ -41,5 +41,5 @@
 	rm -f build-stamp
 
-	rm -rf build-arch-stamp debian/build-*
+	rm -rf build-arch-stamp debian/build-* debian/bitlbee-libpurple.prerm
 	$(MAKE) distclean
 
@@ -52,11 +52,12 @@
 	dh_installdirs
 
-	$(MAKE) -C debian/build-native install install-etc DESTDIR=`pwd`/debian/bitlbee
+	$(MAKE) -C debian/build-native install DESTDIR=`pwd`/debian/bitlbee
+	$(MAKE) -C debian/build-native install-etc DESTDIR=`pwd`/debian/bitlbee-common
 	$(MAKE) -C debian/build-native install-dev DESTDIR=`pwd`/debian/bitlbee-dev
-	patch debian/bitlbee/etc/bitlbee/bitlbee.conf debian/patches/bitlbee.conf.diff
+	patch debian/bitlbee-common/etc/bitlbee/bitlbee.conf debian/patches/bitlbee.conf.diff
 
 ifeq ($(BITLBEE_LIBPURPLE),1)
-	$(MAKE) -C debian/build-libpurple install install-etc DESTDIR=`pwd`/debian/bitlbee-libpurple
-	patch debian/bitlbee-libpurple/etc/bitlbee/bitlbee.conf debian/patches/bitlbee.conf.diff
+	$(MAKE) -C debian/build-libpurple install DESTDIR=`pwd`/debian/bitlbee-libpurple
+	ln -sf debian/bitlbee.prerm debian/bitlbee-libpurple.prerm
 endif
 
@@ -76,8 +77,5 @@
 	for p in bitlbee bitlbee-libpurple bitlbee-dev; do rm -r debian/$$p/usr/share/doc/$$p && ln -s bitlbee-common debian/$$p/usr/share/doc/$$p; done
 	dh_installdebconf
-	dh_installinit
-ifeq ($(BITLBEE_LIBPURPLE)$(DH_OPTIONS),1-a)
-	cp -a debian/bitlbee/etc debian/bitlbee-libpurple
-endif
+	dh_installinit --init-script=bitlbee
 	dh_installman
 	dh_strip
@@ -86,7 +84,4 @@
 	dh_fixperms
 	dh_installdeb
-ifeq ($(BITLBEE_LIBPURPLE)$(DH_OPTIONS),1-a)
-	cp -a debian/bitlbee/DEBIAN/post* debian/bitlbee/DEBIAN/pre* debian/bitlbee-libpurple/DEBIAN
-endif
 	dh_shlibdeps
 ifdef BITLBEE_VERSION
