Cgit

Debian package

I made my own debian package for cgit (http://debian.stbuehler.de/), you can view my basic debianize patch here in the debian branch.

The main difference from the original are the install paths; i use /usr/lib/cgi-bin/cgit.cgi for the cgi binary, and /usr/share/cgit for the cgit.css and cgit.png files.

And i compiled it with the mozilla-sha1 and libcurl4-gnutls-dev package instead of openssl due to some licence problems (that is what lintian told me).

Lighttpd setup

I chose to use a separate vhost for the cgit.css and cgit.png files, so the rewrite rule would be easier, and all vhosts using cgit could share them and save bandwidth ;-)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
$HTTP["host"] == "cgit-res.example.com" {
    server.document-root = "/usr/share/cgit"
}

$HTTP["host"] == "cgit.example.com" {
    compress.filetype = ()
    url.rewrite-once = ( "^/([^?/]+/[^?]*)?(?:\?(.*))?$" => "/cgit.cgi?url=$1&$2" )
    alias.url = ( "/cgit.cgi" => "/usr/lib/cgi-bin/cgit.cgi" )
    cgi.assign = ( "/usr/lib/cgi-bin/cgit.cgi" => "" )
    fastcgi.server = ()
}

I disabled compress and fastcgi for the cgit vhost to make sure they don’t get used.

Now adjust the settings in your /etc/cgitrc:

1
2
css=http://cgit-res.example.com/cgit.css
logo=http://cgit-res.example.com/cgit.png

And as we rewrite to cgit.cgi, we don’t want “cgit.cgi” in the urls:

1
virtual-root=/

If you don’t want to use a separate vhost for the static files, you can use this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
$HTTP["host"] == "cgit.example.com" {
    alias.url = (
        "/static/" => "/usr/share/cgit/",
        "/cgit.cgi" => "/usr/lib/cgi-bin/cgit.cgi",
    )
    url.rewrite-once = (
        "^/static/.*$" => "$0",
        "^/([^?/]+/[^?]*)?(?:\?(.*))?$" => "/cgit.cgi?url=$1&$2",
    )
    cgi.assign = (
        "/usr/lib/cgi-bin/cgit.cgi" => "",
    )
}

You still need the virtual-root setting, but you can use simpler urls for logo and css:

1
2
css=/static/cgit.css
logo=/static/cgit.png

Generated using nanoc and bootstrap - Last content change: 2011-06-10 07:41