Index: debian/bitlbee-common.docs
===================================================================
--- debian/bitlbee-common.docs	(revision 095a5f046c36c4cff689305fef81533a9e9603fc)
+++ debian/bitlbee-common.docs	(revision 095a5f046c36c4cff689305fef81533a9e9603fc)
@@ -0,0 +1,6 @@
+doc/user-guide/user-guide.txt
+doc/user-guide/user-guide.html
+doc/AUTHORS
+doc/CREDITS
+doc/FAQ
+doc/README
Index: debian/bitlbee-common.examples
===================================================================
--- debian/bitlbee-common.examples	(revision 095a5f046c36c4cff689305fef81533a9e9603fc)
+++ debian/bitlbee-common.examples	(revision 095a5f046c36c4cff689305fef81533a9e9603fc)
@@ -0,0 +1,1 @@
+utils/*
Index: debian/changelog
===================================================================
--- debian/changelog	(revision 04dc563f2a30476bf96e72ce3e66cb5a8b2606d3)
+++ debian/changelog	(revision 095a5f046c36c4cff689305fef81533a9e9603fc)
@@ -1,2 +1,11 @@
+bitlbee (1.3-0) unstable; urgency=low
+
+  * Setting some bogus version number, fix that later.
+  * Now using debhelper to improve maintainability.
+  * Added a bitlbee-libpurple package, and split off docs and stuff into
+    bitlbee-common.
+
+ -- Wilmer van der Gaast <wilmer@gaast.net>  Sat, 05 Jun 2010 15:16:38 +0100
+
 bitlbee (1.2.6a-1) unstable; urgency=low
 
Index: debian/compat
===================================================================
--- debian/compat	(revision 095a5f046c36c4cff689305fef81533a9e9603fc)
+++ debian/compat	(revision 095a5f046c36c4cff689305fef81533a9e9603fc)
@@ -0,0 +1,1 @@
+7
Index: bian/conffiles
===================================================================
--- debian/conffiles	(revision 04dc563f2a30476bf96e72ce3e66cb5a8b2606d3)
+++ 	(revision )
@@ -1,3 +1,0 @@
-/etc/bitlbee/motd.txt
-/etc/bitlbee/bitlbee.conf
-/etc/init.d/bitlbee
Index: debian/control
===================================================================
--- debian/control	(revision 04dc563f2a30476bf96e72ce3e66cb5a8b2606d3)
+++ debian/control	(revision 095a5f046c36c4cff689305fef81533a9e9603fc)
@@ -4,5 +4,5 @@
 Maintainer: Wilmer van der Gaast <wilmer@gaast.net>
 Uploaders: Jelmer Vernooij <jelmer@samba.org>
-Standards-Version: 3.8.0
+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
 Homepage: http://www.bitlbee.org/
@@ -12,8 +12,33 @@
 Package: bitlbee
 Architecture: any
-Depends: ${shlibs:Depends}, adduser, net-tools, ${debconf-depends}, debianutils (>= 1.16)
+Depends: ${shlibs:Depends}, adduser, net-tools, debianutils (>= 1.16), bitlbee-common (>= ${source:Version}), bitlbee-common (<< ${source:Version}.1~)
 Description: An IRC to other chat networks gateway
  This program can be used as an IRC server which forwards everything you
  say to people on other chat networks: Jabber, ICQ, AIM, MSN and Yahoo.
+
+Package: bitlbee-libpurple
+Architecture: any
+Depends: ${shlibs:Depends}, adduser, net-tools, debianutils (>= 1.16), bitlbee-common (>= ${source:Version}), bitlbee-common (<< ${source:Version}.1~)
+Description: An IRC to other chat networks gateway
+ This program can be used as an IRC server which forwards everything you
+ say to people on other chat networks: Jabber, ICQ, AIM, MSN and Yahoo.
+ .
+ This package contains a version of BitlBee that uses the libpurple instant
+ messaging library instead of built-in code, which adds support for more IM
+ protocols (all protocols supported by Pidgin/Finch) and features (like file
+ transfers), at the price of being less lightweight.
+ .
+ This variant may not be very suitable for BitlBee instances used by many
+ (tens or hundreds) of clients.
+
+Package: bitlbee-common
+Architecture: all
+Replaces: bitlbee (<= 1.3)
+Description: An IRC to other chat networks gateway
+ This program can be used as an IRC server which forwards everything you
+ say to people on other chat networks: Jabber, ICQ, AIM, MSN and Yahoo.
+ .
+ This package contains common files (mostly documentation) for bitlbee and
+ bitlbee-libpurple.
 
 Package: bitlbee-dev
Index: debian/patches/bitlbee.conf.diff
===================================================================
--- debian/patches/bitlbee.conf.diff	(revision 04dc563f2a30476bf96e72ce3e66cb5a8b2606d3)
+++ debian/patches/bitlbee.conf.diff	(revision 095a5f046c36c4cff689305fef81533a9e9603fc)
@@ -1,4 +1,4 @@
---- debian/bitlbee/etc/bitlbee/bitlbee.conf	2009-06-01 00:20:24.000000000 +0100
-+++ debian/bitlbee/etc/bitlbee/bitlbee.conf	2009-06-07 21:16:19.000000000 +0100
+--- bitlbee.conf	2009-06-01 00:20:24.000000000 +0100
++++ bitlbee.conf	2009-06-07 21:16:19.000000000 +0100
 @@ -23,13 +23,18 @@
  ## If BitlBee is started by root as a daemon, it can drop root privileges,
Index: debian/rules
===================================================================
--- debian/rules	(revision 04dc563f2a30476bf96e72ce3e66cb5a8b2606d3)
+++ debian/rules	(revision 095a5f046c36c4cff689305fef81533a9e9603fc)
@@ -1,3 +1,10 @@
 #!/usr/bin/make -f
+#
+# Finally switching to debhelper.
+#
+# Not using debhelper was an exercise suggested to me by my AM (Gergely
+# Nagy). It was educating at the time but I finally decided that the
+# exercise is over now.
+#
 
 BITLBEE_CONFIGURE_FLAGS ?=
@@ -8,103 +15,81 @@
 else
 # Want to use the full package version number instead of just the release.
-BITLBEE_VERSION ?= "$(shell dpkg-parsechangelog | grep ^Version: | awk '{print $$2}')"
-export BITLBEE_VERSION
+BITLBEE_CONFIGURE_VERSION ?= BITLBEE_VERSION=\"$(shell dpkg-parsechangelog | grep ^Version: | awk '{print $$2}')\"
 endif
 
-build-arch: build-arch-stamp
-build-arch-stamp:
-	[ -d debian ]
-	./configure --debug=$(DEBUG) --prefix=/usr --etcdir=/etc/bitlbee --events=libevent $(BITLBEE_CONFIGURE_FLAGS)
-	$(MAKE)
-#	$(MAKE) -C doc/ all
-	touch build-arch-stamp
+build: build-stamp
+build-stamp:
+	dh_testdir
+
+	mkdir debian/build-native
+	ROOT=$$PWD; cd debian/build-native; $(BITLBEE_CONFIGURE_VERSION) $$ROOT/configure --debug=$(DEBUG) --prefix=/usr --etcdir=/etc/bitlbee --events=libevent $(BITLBEE_CONFIGURE_FLAGS)
+	$(MAKE) -C debian/build-native
+
+	mkdir debian/build-libpurple
+	ROOT=$$PWD; cd debian/build-libpurple; $(BITLBEE_CONFIGURE_VERSION) $$ROOT/configure --debug=$(DEBUG) --prefix=/usr --etcdir=/etc/bitlbee --purple=1 $(BITLBEE_CONFIGURE_FLAGS)
+	$(MAKE) -C debian/build-libpurple
+
+	touch build-stamp
 
 clean:
-	[ "`whoami`" = "root" -a -d debian ]
-	rm -rf build-arch-stamp debian/bitlbee debian/*.substvars debian/files debian/bitlbee-dev
+	dh_testdir
+	dh_testroot
+	rm -f build-stamp
+
+	rm -rf build-arch-stamp debian/build-*
 	$(MAKE) distclean
-#	-$(MAKE) -C doc/ clean
-				
 
-install-arch: build-arch
-	[ "`whoami`" = "root" -a -d debian ]
-	mkdir -p debian/bitlbee/DEBIAN/
-	$(MAKE) install install-etc DESTDIR=`pwd`/debian/bitlbee
+	dh_clean
 
-	mkdir -p debian/bitlbee/usr/share/doc/bitlbee/
-	cp doc/user-guide/user-guide.txt debian/bitlbee/usr/share/doc/bitlbee/
-	cp doc/user-guide/user-guide.html debian/bitlbee/usr/share/doc/bitlbee/
+install: build
+	dh_testdir
+	dh_testroot
+	dh_prep
+	dh_installdirs
 
-install-indep: install-arch
-	[ "`whoami`" = "root" -a -d debian ]
-	mkdir -p debian/bitlbee-dev/DEBIAN/
-	$(MAKE) install-dev DESTDIR=`pwd`/debian/bitlbee-dev
+	$(MAKE) -C debian/build-native install install-etc DESTDIR=`pwd`/debian/bitlbee
+	$(MAKE) -C debian/build-libpurple install install-etc DESTDIR=`pwd`/debian/bitlbee-libpurple
+	$(MAKE) -C debian/build-native install-dev DESTDIR=`pwd`/debian/bitlbee-dev
 
-	mkdir -p debian/bitlbee-dev/usr/share/doc/bitlbee-dev/
+	patch debian/bitlbee/etc/bitlbee/bitlbee.conf debian/patches/bitlbee.conf.diff
+	patch debian/bitlbee-libpurple/etc/bitlbee/bitlbee.conf debian/patches/bitlbee.conf.diff
 
-binary-arch: build-arch install-arch
-	[ "`whoami`" = "root" -a -d debian ]
+	mkdir -p debian/bitlbee-common/usr
+	mv debian/bitlbee/usr/share debian/bitlbee-common/usr
+	rm -rf debian/bitlbee-libpurple/usr/share
 
-	chmod 755 debian/post* debian/pre* debian/config debian/bitlbee.init
+binary-common:
+	dh_testdir
+	dh_testroot
 
-	mkdir -p debian/bitlbee/usr/share/doc/bitlbee/examples/ debian/bitlbee/etc/init.d/
-	-cp doc/RELEASE-SPEECH* debian/bitlbee/usr/share/doc/bitlbee/ && gzip -9 debian/bitlbee/usr/share/doc/bitlbee/RELEASE-SPEECH*
-	cp doc/CREDITS doc/AUTHORS doc/README doc/FAQ debian/README.Debian debian/bitlbee/usr/share/doc/bitlbee/
-	cp debian/changelog debian/bitlbee/usr/share/doc/bitlbee/changelog.Debian
-	cp debian/copyright debian/bitlbee/usr/share/doc/bitlbee/copyright
-	cp doc/CHANGES debian/bitlbee/usr/share/doc/bitlbee/changelog
-	cp utils/* debian/bitlbee/usr/share/doc/bitlbee/examples/
-	cp debian/bitlbee.init debian/bitlbee/etc/init.d/bitlbee
-	patch -p0 < debian/patches/bitlbee.conf.diff
-	cd debian/bitlbee/usr/share/; \
-		gzip -9 doc/bitlbee/changelog.Debian doc/bitlbee/changelog doc/bitlbee/user-guide.txt \
-		        doc/bitlbee/examples/* man/man8/bitlbee.8 man/man5/bitlbee.conf.5
-	
-	chown -R root:root debian/bitlbee/
-	find debian/bitlbee/usr/share/ -type d -exec chmod 755 {} \;
-	find debian/bitlbee/usr/share/ -type f -exec chmod 644 {} \;
-	
-	cp debian/prerm debian/bitlbee/DEBIAN/
-	cp debian/postinst debian/bitlbee/DEBIAN/
-	cp debian/postrm debian/bitlbee/DEBIAN/
-	cp debian/config debian/bitlbee/DEBIAN/
+	dh_installdocs --link-doc=bitlbee-common
+	dh_installchangelogs
+	dh_installexamples
+	dh_installdebconf
+	dh_installinit
+	dh_installman
+	dh_strip
+	dh_link
+	dh_compress
+	dh_fixperms
+	dh_installdeb
+	dh_shlibdeps
+ifdef BITLBEE_FORCE_VERSION
+	dh_gencontrol -- -v1:$(BITLBEE_VERSION)-0
+else
+	dh_gencontrol
+endif
+	dh_md5sums
+	dh_builddeb
 
-	po2debconf debian/templates > debian/bitlbee/DEBIAN/templates
-	cp debian/conffiles debian/bitlbee/DEBIAN/
-	
-	if [ "$(DEBUG)" = "0" ]; then strip -R .comment -R .note debian/bitlbee/usr/sbin/bitlbee; fi
+binary-indep: build install
+	$(MAKE) -f debian/rules DH_OPTIONS=-i binary-common
 
-	cd debian/bitlbee; \
-		find usr -type f -exec md5sum {} \; > DEBIAN/md5sums
-	dpkg-shlibdeps -Tdebian/bitlbee.substvars -dDepends debian/bitlbee/usr/sbin/bitlbee
-ifdef BITLBEE_FORCE_VERSION
-	dpkg-gencontrol -ldebian/changelog -isp -pbitlbee -Tdebian/bitlbee.substvars -Pdebian/bitlbee -v1:$(BITLBEE_VERSION)-0 -V'debconf-depends=debconf (>= 1.2.0) | debconf-2.0'
-else
-	dpkg-gencontrol -ldebian/changelog -isp -pbitlbee -Tdebian/bitlbee.substvars -Pdebian/bitlbee -V'debconf-depends=debconf (>= 1.2.0) | debconf-2.0'
-endif
+binary-arch: build install
+	$(MAKE) -f debian/rules DH_OPTIONS=-a binary-common
 
-	dpkg --build debian/bitlbee ..
+binary-%: build install
+	make -f debian/rules binary-common DH_OPTIONS=-p$*
 
-binary-indep: install-indep
-	[ "`whoami`" = "root" -a -d debian ]
-
-	chown -R root.root debian/bitlbee-dev/
-	find debian/bitlbee-dev/usr/share/ -type d -exec chmod 755 {} \;
-	find debian/bitlbee-dev/usr/share/ -type f -exec chmod 644 {} \;
-
-	cp debian/changelog debian/bitlbee-dev/usr/share/doc/bitlbee-dev/changelog.Debian
-	gzip -9 debian/bitlbee-dev/usr/share/doc/bitlbee-dev/changelog.Debian
-	cp debian/copyright debian/bitlbee-dev/usr/share/doc/bitlbee-dev/copyright
-
-	cd debian/bitlbee-dev; \
-		find usr -type f -exec md5sum {} \; > DEBIAN/md5sums
-
-	dpkg-gencontrol -ldebian/changelog -isp -pbitlbee-dev -Pdebian/bitlbee-dev -v1:$(BITLBEE_VERSION)-0
-
-	dpkg --build debian/bitlbee-dev ..
-
-binary: binary-arch binary-indep
-build: build-arch
-install: install-arch install-indep
-
-.PHONY: build-arch build clean binary-arch binary install-arch install binary-indep install-indep
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary-common binary install
