Index: debian/control
===================================================================
--- debian/control	(revision 763a3abb5a255fc22169c3fd86aabb7020e21086)
+++ debian/control	(revision 619770237590e4a760346f2e12681d7e2220dda4)
@@ -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), po-debconf, libpurple-dev, debhelper (>= 6)
+Build-Depends: libglib2.0-dev (>= 2.4), libevent-dev, libgnutls-dev | libnss-dev (>= 1.6), po-debconf, libpurple-dev, libotr2-dev, debhelper (>= 6)
 Homepage: http://www.bitlbee.org/
 Vcs-Bzr: http://code.bitlbee.org/bitlbee/
@@ -59,2 +59,13 @@
  .
  This package holds development stuff for compiling plug-ins.
+
+Package: bitlbee-plugin-otr
+Architecture: any
+Depends: ${misc:Depends}, ${shlibs:Depends}, bitlbee (= ${bee:Version}) | bitlbee-libpurple (= ${bee:Version})
+Description: An IRC to other chat networks gateway (default version)
+ This program can be used as an IRC server which forwards everything you
+ say to people on other chat networks: Jabber (which includes Google Talk
+ and Facebook Chat), ICQ, AIM, MSN, Yahoo! and Twitter/Identica/Status.net.
+ .
+ This package contains a plugin that adds support for Off-The-Record
+ encryption of instant messages.
Index: debian/rules
===================================================================
--- debian/rules	(revision 763a3abb5a255fc22169c3fd86aabb7020e21086)
+++ debian/rules	(revision 619770237590e4a760346f2e12681d7e2220dda4)
@@ -8,6 +8,7 @@
 #
 
-# Include the bitlbee-libpurple variant by default
+# Include the bitlbee-libpurple variant and OTR plugin by default
 BITLBEE_LIBPURPLE ?= 1
+BITLBEE_OTR ?= plugin
 BITLBEE_CONFIGURE_FLAGS ?=
 DEBUG ?= 0
@@ -22,4 +23,8 @@
 endif
 
+ifneq ($(BITLBEE_OTR),plugin)
+DH_OPTIONS += -Nbitlbee-plugin-otr
+endif
+
 build: build-stamp
 build-stamp:
@@ -27,5 +32,5 @@
 
 	mkdir -p 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)
+	ROOT=$$PWD; cd debian/build-native; $(BITLBEE_CONFIGURE_VERSION) $$ROOT/configure --debug=$(DEBUG) --prefix=/usr --etcdir=/etc/bitlbee --events=libevent --otr=$(BITLBEE_OTR) $(BITLBEE_CONFIGURE_FLAGS)
 	$(MAKE) -C debian/build-native
 
@@ -56,17 +61,16 @@
 	dh_installdirs
 
-	$(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-bin DESTDIR=`pwd`/debian/bitlbee
+	$(MAKE) -C debian/build-native install-etc install-doc DESTDIR=`pwd`/debian/bitlbee-common
 	$(MAKE) -C debian/build-native install-dev DESTDIR=`pwd`/debian/bitlbee-dev
-	patch debian/bitlbee-common/etc/bitlbee/bitlbee.conf debian/patches/bitlbee.conf.diff
+	$(MAKE) -C debian/build-native install-plugins DESTDIR=`pwd`/debian/bitlbee-plugin-otr
 
 ifeq ($(BITLBEE_LIBPURPLE),1)
-	$(MAKE) -C debian/build-libpurple install DESTDIR=`pwd`/debian/bitlbee-libpurple
+	$(MAKE) -C debian/build-libpurple install-bin DESTDIR=`pwd`/debian/bitlbee-libpurple
 	ln -sf debian/bitlbee.prerm debian/bitlbee-libpurple.prerm
 endif
 
-	mkdir -p debian/bitlbee-common/usr
-	mv debian/bitlbee/usr/share debian/bitlbee-common/usr
-	rm -rf debian/bitlbee-libpurple/usr/share
+	patch debian/bitlbee-common/etc/bitlbee/bitlbee.conf debian/patches/bitlbee.conf.diff
+	chmod 640 debian/bitlbee-common/etc/bitlbee/bitlbee.conf
 
 binary-common:
@@ -79,5 +83,5 @@
 	# TODO: Restore --link-doc up here and remove the hack below once
 	# Hardy and Lenny are deprecated.
-	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
+	for p in bitlbee bitlbee-libpurple bitlbee-dev bitlbee-plugin-otr; do rm -r debian/$$p/usr/share/doc/$$p && ln -s bitlbee-common debian/$$p/usr/share/doc/$$p || true; done
 	dh_installdebconf
 	dh_installinit --init-script=bitlbee
