Installing the Darwin Calendar Server on FreeBSD

Posted by Roy Hooper Sat, 07 Jul 2007 23:10:00 GMT

I’ve been contemplating creating a hallway dashboard to replace the paper calendar and birthday list that hangs in the hallway. My wife’s not too thrilled by the idea, so I’ve got to make it look good, work well and be useful to be able to convince her it should get installed on the wall.

As one of its main functions will be as a Calendar and Events listing, I thought it would make sense to investigate the iCal server. It turns out that the underlying server is based on an open source project at Apple by the name of Darwin Calendar Server.

It has a fair number of dependencies… But they all looked pretty reasonable, so I decided to try it out on my household FreeBSD 6.0 server.

The requirements to make it run are:
  1. Python 2.4
  2. Zope Interface 3.1.0c1
  3. PyXML 0.8.4
  4. pyOpenSSL 0.6
  5. python-dateutil-1.0
  6. xattr 0.2 (Bob Ippolito’s implementation)
  7. pysqlite 2.2.2
  8. Twisted
  9. vObject
  10. PyKerberos
  11. PyOpenDirectory

Many of these are already available as ports:

  1. /usr/ports/lang/python
  2. /usr/ports/www/zope3
  3. /usr/ports/textproc/py-xml
  4. /usr/ports/security/py-openssl
  5. /usr/ports/devel/py-dateutil
  6. Needs to be built manually. It also depends on a version of setuptools that is higher than the current port. Get and install setuptools 0.6c6. Once you’ve installed those, get and install xattr-0.4.
  7. /usr/ports/databases/py-pysqlite22
  8. /usr/ports/devel/py-twisted
  9. /usr/ports/desktuil/py-vobject

The final two in the dependency list are available via the MacOS forge SVN server for Darwin Calendar Server. PyKerberos requires you have kerberos installed, but don’t need to have it configured. To get kerberos libraries on your FreeBSD system, install /usr/ports/security/krb5.

Next, create a directory to check out the calendar server into then:

svn co http://svn.calendarserver.org/repository/calendarserver/CalendarServer/trunk CalendarServer

You’re also going to need PyKerberos, but it won’t work as-is on FreeBSD. First we’ll fetch it to the current working directory:

svn co http://svn.calendarserver.org/repository/calendarserver/PyKerberos/trunk PyKerberos

Next you’re going to need to modify setup.py in PyKerberos slightly as well as fix the include path that is used for Python.h. First we’ll fix all the references:

perl -spi -e ’s{<Python/}{<};’ src/*

Next, add these two lines to setup.py just after the sources block:

library_dirs=['/usr/local/lib'],
include_dirs=['/usr/local/include'],

You’ll end up with a setup.py like this:

##
  1. Copyright© 2006-2007 Apple Inc. All rights reserved. #
  2. Licensed under the Apache License, Version 2.0 (the “License”);
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at #
  5. http://www.apache.org/licenses/LICENSE-2.0 #
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an “AS IS” BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License. #
  11. DRI: Cyrus Daboo, cdaboo@apple.com ##
from distutils.core import setup, Extension
import sys
import commands
setup (
    name = "kerberos",
    version = "1.0",
    description = "Kerberos high-level interface",
    ext_modules = [
        Extension(
            "kerberos",
            extra_link_args = commands.getoutput("krb5-config --libs gssapi").split(),
            extra_compile_args = commands.getoutput("krb5-config --cflags gssapi").split(),
            sources = [
                "src/kerberos.c",
                "src/kerberosbasic.c",
                "src/kerberosgss.c",
                "src/base64.c" 
            ],
            library_dirs=['/usr/local/lib'],
            include_dirs=['/usr/local/include'],
        ),
    ],
)

Finally, we’re ready to attempt to fire up the server for the first time, as per the instructions on the quickstart page.

Here too, unfortunately, we run into portability problems. The run script uses /bin/bash. You’ll need to install the bash port if you haven’t already, and then either modify the run script, or fire it up manually:

bash ./run -s

This will build the kerberos library we modified in the previous steps, among other things.

Once the above works (no output), you’re ready to configure things. Before you can launch the server, though, you’ll need to fix:

CalendarServer/bin/caldavd
CalendarServer/run

to use /usr/local/bin/bash

Enjoy.

Local modifications to /etc in BSD

Posted by Roy Hooper Fri, 02 Feb 2007 19:20:00 GMT

One of the things that has bugged me for ages is that /etc is a combination of system files and local configuration files…

I don’t think it should be both!

At lunch today, a colleague and I discussed the idea of making /etc system-only files, and union mounting it with a directory to hold locally modified files.

I’m going to have to try this to see if it works. If it does, then perhaps its time to adopt a new way to manage /etc for FreeBSD.

It turns out that this works, and very well! The only trick is upgrading. And removing files… I’ll have to try using below-mounts and relocating the real /etc to a different directory, and having /etc be the local modifications but with the system /etc/accessible.

Setting up a blog with Typo

Posted by Roy Hooper Thu, 02 Mar 2006 05:19:00 GMT

Sometimes you just have to try something for yourself. Today, that was setting up my own blog on my own server.

Yesterday, I posted my first article about my experiences with Ruby at a seldom used LiveJournal of mine. I eventually decided that it made more sense to have this on my own server, running my own choice of software on my own choice of OS (FreeBSD).

A bit of googling led me to Typo. Typo is a blogging package written using the Ruby on Rails framework.

The package looked slick, has themes, and other nice features, so I figured I’d give it a try. That was the easy part. I’ve spent the better part of my evening upgrading bits and pieces of software as a result.

I started off with the easy bits: upgrading Ruby and rails. This really was the easy part. In FreeBSD, it was a matter of installing the Ruby port, followed by the rubygem-rails port. This port automatically installed all the necessary dependencies, including RubyGems. RubyGems is a package manager type of thing for Ruby. It works well. It reminds me of CPAN for Perl.

Afterwards, I learned I would need FastCGI for good performance with any Rails app. Naturally, I had to upgrade Apache —but couldn’t do it the easy way without cutting off web service for my users for an unacceptable period of time. So I had to build a temporary copy of Apache 2.2 to test the new configuration. After I was satisfied that the temporary copy worked, I switched it on. I then was able to purge the old packages and dependencies, build the new Apache 2.2 package, install, configure, and then test it. I was finally ready to switch off the temporary Apache install and enable the new Apache packages.

Now my system was ready for FastCGI. FastCGI is a nifty way of speeding up applications that are slow to start, but fast once started—like Ruby and Perl applications.

Because I wanted to put this blog at http://www.royhooper.ca/blog/, I had to follow alternate install instructions. Of course this didn’t go smoothly either. I had to futz around with my configuration, looking for the culprit. Eventually, with the help of trusty Google, I ran across two [1, 2] helpful web pages.

I’m fairly happy with the results. I’ll definitely have to play with this theme to make it look the way I want, but I like how it works.