Before starting, keep in mind that if you don't want to patch your courier, you can use the authentication module courier-authmkhome on my home page to create users' home directories. However, if you don't patch courier, you need to do little tricks with the user home directory. Read the specific documentation.
You'll need: patch, make, tar, gzip, gunzip, gcc, and all the files needed to compile courier.
$ cd /usr/src
$ tar -xvzf ~/courier-imap.tar.gz
$ tar -xvzf ~/courier_patch.tar.gz
$ cd courier-0.x.x
$ cat ../courier_patch/courier_0.x.x.diff | patch -p1
You should follow the steps indicated in courier documentation. It would be good to include support for authdaemon and for some kind of database :-).
# apt-get install dpkg-dev
# apt-get install gcc make patch g++
# apt-get source courier
# apt-get build-dep courier
# cd courier_0.x.x.orig
# cat ../courier_patch/courier_0.x.x | patch -p1
Remember to always apply the patch provided with debian before
any other patch (in this case, apt-get source takes care of that).
# dpkg-buildpackage
# dpkg -i ./courier-imap_0.x.x.deb
# dpkg -i ./courier-pop3_0.x.x.deb
# dpkg -i ./courier-authdaemon_0.x.x.deb
# dpkg -i ./courier-authmysql_0.x.x.deb