Welcome the company of trees

Calendar server

2012-02-11

Revision History
Revision 0.12012-02-11FU
Initial version

In the quest to set up a server a solution calendaring and contacts became necessary. After comparing Apples calendarserver and Davical the choice came to calendarserver at the end. Both seemed OK, but calendarserver did not need a database (version 2.X), and was written in python. Davicals php and database would have required more maintenance and setup. Both had at the time valid debian packages. Now fast forward to 2012.

Debianizing calendarserver

The debian package for calendarserver does not seem to be maintained anymore. The need for a working carddav solution made me bite the bullet and try to upgrade my installation to the latest version. The initial work started with getting the trunk (using git svn).

Target was a squeeze server but to begin with the porting was done on sid. To try to find the correct dependencies, the run script and supporting scripts was the start. There were no proper dependency list on the calendarserver homepage.

Table 1. Calendarserver dependencies
Softwarecalendarserversqueezewheezysiddebian
python2.7.12.6.6-3+squeeze62.7.2-102.7.2-10python
libevent1.4.13-stable1.4.13-stable-1--libevent-1.4-2
libevent1.4.13-stable-2.0.16-stable-12.0.16-stable-1libevent-2.0-5
memcached1.4.51.4.5-11.4.7-0.1+b11.4.7-0.1+b1memcached
postgres9.0.38.4.10-0squeeze19.1+1289.1+128postgresql
openldap2.4.252.4.23-7.22.4.28-1.12.4.28-1.1slapd
setuptools0.6c110.6.14-40.6.24-10.6.24-1python-setuptools
zope.interface3.3.03.5.3-1+b13.6.1-13.6.1-1python-zope.interface
pyxml0.8.4---python-xml->python
pyopenssl0.100.10-10.13-10.13-1python-openssl
PyKerberos-1.1+svn4895-1+b11.1+svn4895-1+b21.1+svn4895-1+b2python-kerberos
PyOpenDirectory-----
xattr0.6.10.4-5+squeeze10.6.2-10.6.2-1python-xattr
cx_Oracle5.1----
PyGreSQL4.01:4.0-2+b11:4.0-31:4.0-3python-pygresql
twisted11.0.010.1.0-311.1.0-111.1.0-1python-twisted
python-dateutil1.51.4.1-31.5-11.5-1python-dateutil
python-ldap2.3.132.3.11-12.3.13-12.3.13-1python-ldap
pycalendarr188----
sqlparse0.1.2-0.1.3-10.1.3-1python-sqlparse
pyflakes0.4.00.4.0-10.5.0-10.5.0-1pyflakes
CalDAVClientLibrarytrunk----
CalDAVTestertrunk----
pytz2011g2010b-12011h-12011h-1python-tz
pydoctor0.30.3-10.3+bzr567-10.3+bzr567-1python-pydoctor

After collecting the dependencies I tried to build a debian package. I first cloned the repsitory using git.

git
    svn clone --stdlayout
    http://svn.macosforge.org/repository/calendarserver/CalendarServer

Then merge it into the master :

git merge remotes/trunk
    master

Next was to generate a release to work with. To get a "pure" server package I ran

./setup.py sdist --dist-dir=../
    --prune

following some of the instructions from the post Creating a .deb package from a python setup.py At first, as I use git the svnversion command fails. I created a small script to deal with that ~/bin/svnversion : #!/bin/bash REV=`git svn find-rev master` echo -n $REV This creates a tar.gz package that is almost usable. The version number is not what debian wants, and creating a versioned tree is not that easy. That is why the support/version.py exists. The dependency of this file is a bit problematic as support is not a part of the source package.

To get around the issues with version and a external non packaged reference to versions.py, I made a build.sh script, and applied some patches to my environment, builds a source package, unpacks it and adds the debian directory directory. Later it has to be adapted to take the svn branch and apply the patches via debian quilt. Once all is set up

dpkg-buildpackage -i -I
    -rfakeroot

builds the package. Then install

sudo dpkg -i
    ../calendarserver_4.1-SVNVERSION_all.deb

Debian directory

I started out with a very basic debian directory, with an almost empty control file. Also the changelog is very crude. It first became clear that python 2.7 was needed so I set that as required python version for now.

Next step was to iterate and find out what dependencies existed and what problems existed with debian that might require patches. I did this by just testrunning the

sudo caldavd -X
    -L

directly in /usr/bin. Following is the list of the packages I installed (in brackets dependencies) : python-twisted-core (11.1.0-1) [ python-openssl (0.13-1) python-pam (0.4.2-12.3+b1) python-serial (2.5-2.1) python-zope.interface (3.6.1-1)? ] python-twisted-mail (11.1.0-1) [ python-twisted-names (11.1.0-1) ] python-twisted-web (11.1.0-1) python-dateutil (1.5-1)


      git svn clone http://svn.mulberrymail.com/repos/PyCalendar/branches/server pycalendar
      python ./setup.py sdist --dist-dir=../ --prune
      cd ..
      py2dsc pycalendar-2.0.tar.gz
      cd deb_dist/pycalendar-2.0
      dpkg-buildpackage -rfakeroot -uc -us
      sudo dpkg -i ../python-pycalendar_2.0-1_all.deb
    

python-pycalendar (2.0-1) python-pygresql (1:4.0-3) [ libpq5 (9.1.2-4) python-egenix-mxtools (3.2.1-1) python-egenix-mxdatetime (3.2.1-1) ] python-xattr (0.6.2-1) python-sqlparse (0.1.3-1) [ libjs-underscore (1.3.1-1) libjs-sphinxdoc (1.1.2+dfsg-5) ]


      mkdir /var/db/caldavd
      chown daemon.daemon /var/db/caldavd
      mkdir /var/log/caldavd
    

Now we reached the place where we have to configure postgres. First enable it in the caldav.plist and the set up Postgres postgresql-9.1 (9.1.2-4) [ postgresql-client-common (128) postgresql-client-9.1 (9.1.2-4) postgresql-common (128) ] Then it is time to set up the caldav user and database. This can also be done with the

calendarserver_bootstrap_database

. I made changes to the command to make it work with Debian, but still more improvments could be made. For testing I added the follwing /etc/postgresql/9.1/main/pg_hba.conf to make it work on debian. # TYPE DATABASE USER ADDRESS METHOD local caldav caldav trust This is currently highly insecure (calendars are readable by users on the system), but for now I have not created a better solution. Once I add a user caldav to the system I can use peer, limiting the access to the caldav user.

Once the database is installed we install memcached (1.4.7-0.1+b1) and that service will be started by caldavd so we stop it now.

/etc/init.d/memcached
    stop

. If it is running it will interfere with the calendarserver that starts it from within the server. Need to investigate if this behavior can be changed configured.