Serving darcs repositories with lighttpd

What is darcs?

Darcs is a distributed revision control system written in Haskell by David Roundy. Compared to Subversion and CVS darcs comes with the feature that every copy of the source itself acts as a complete repository. Darcs is based on the concept of patches. When changing the source code you record your changes and commit then as patch to other repositories.

Using darcsweb it's possible to serve darcs repositories via http. For this article I assume you've got darcs installed, as it is required by the darcsweb.cgi, and lighttpd up and running. If you want to compile darcs from source, make sure you've got ghc6 installed, as darcs requires the Haskell compiler. To start fetch the darcsweb package from http://blitiri.com.ar/p/darcsweb/.

Webserver Configuration

Since we want to use the darcsweb.cgi we have to enable the cgi-module for lighttpd. This is done by activating mod_cgi in the lighttpd.conf server.modules statement. On debian you can also create an symlink in /etc/lighttpd/conf-enabled/ to /etc/lighttpd/conf-available/10-cgi.conf (using ln -s taget linkname) which will automatically add mod_cgi on webserver restart.

server.modules { ... "mod_cgi", ... }

Now create a subdirectory inside of your webroot named "darcsweb" and make sure your configuration also includes the following lines:

$HTTP["url"] =~ "^/darcsweb/" { cgi.assign = ( ".cgi" => "" ) }

This enables CGI execution in the darcsweb subdirectory we just created. If not already done, add execution rights to the darcsweb.cgi:

chmod +x darcsweb.cgi

This is everything that has to be done to make lighttpd execute the darcsweb.cgi. Now we have to configure darcsweb itself.

Darcsweb Configuration

I decided to store all my repositories in a subdirectory of /var/www/darcs. Adjust the paths in the next examples to your own configuration wishes.

mkdir -p /var/www/darcs/myproject cd /var/www/darcs/myproject darcs initialize

This will create a subdirectory names "myproject" and initialize it as empty darcs repository. The darcsweb package contains a sample configuration file which we will make use of. Rename it to config.py:

mv config.py.sample config.py

Now open the configuration in your prefered editor. The configuration is divided into classes, where class "base" represents the base configuration common to all repositories. You can leave most of it unedited, just make sure that the darcs binary isaccessible through the environments PATH-Variable (or alternatively specify the path to the binary using the "darcspath" setting in the "base" class of the configuration). Remove the example classes and add the configuration settings for our repository:

class MyProject: reponame = 'My Project' repodesc = 'Cool repository' repodir = '/var/www/darcs/myproject' repourl = 'http://mydomain.tld/darcsweb/' repoencoding = 'latin1'

Now all is set and done. Trigger a webserver restart by typing "/etc/init.d/lighttpd restart" and point your browser to http://yourdomain.tld/darcsweb - if you've done everything right you'll see something like the following:

Darcsweb with lighttpd

Comments (0) |

No comments yet!

Submit Comment