Tuesday, January 12, 2010

Setting up lxr for Inferno

Understanding and studying the code is much easier if you have source code cross reference set up. There are public repositories for most well known operating systems. You can find them at http://fxr.watson.org/.

Unfortunately, Inferno source code is not hosted here. So, I had to go through the endeavor myself. There are few tutorial out there which gives simple steps for installing and configuring lxr for Linux source code. here are few examples that I referred.
http://tread.wordpress.com/2007/08/25/howto-setup-lxr-on-linux-ubuntu-feisty/
http://orangespike.ca/content/ubuntu-710-lxr-linux-cross-referencing-howto

But I could not find anything which tells how to do it for generic code. So, here I will describe the steps I took for configuring generic code in lxr. Inferno code is taken as example here. It should be easy to replace Inferno with other system code in following steps.


sudo apt-get install apache2 libapache2-mod-perl2
sudo apt-get install libcgi-simple-perl libcgi-ajax-perl libhtml-parser-perl libtemplate-perl


Install LXR.

sudo apt-get install lxr


If possible, install glimpse also. It provides free-text search capabilities. apt-get did not worked for this one in my case. And I did not fight to get it installed also. If following command does not work for you then you can try to get it from http://webglimpse.net/.

sudo apt-get install glimpse


Add the following lines to /etc/apache2/httpd.conf at the end:

# Linux Cross Reference Stuff
Alias /lxr /usr/share/lxr

Options All
AllowOverride All


Create a file /usr/share/lxr/http/.htaccess which contains:



SetHandler cgi-script



Restart Apache

/etc/init.d/apache2 restart



Create /usr/share/lxr/source if it doesn’t exist.

sudo mkdir -p /usr/share/lxr/source
cd /usr/share/lxr/source
sudo mkdir inferno
hg clone https://ericvh-brasil.googlecode.com/hg/ ericvh-brasil
echo "inferno" > /usr/share/lxr/source/versions
sudo ln -s /usr/share/lxr/source/inferno /usr/share/lxr/source/defversion


I performed following steps to get ownership of these file, so that I can edit them directly. You may not have to do these steps. Just make sure that the code directory is accessible to everyone for read and browse.


cd /usr/share/lxr/source
chown -R pravin.pravin inferno
chmod -R +x inferno
chmod 777 /usr/share/lxr/source/inferno/fileidx


Now comes the most important step. You need to modify /usr/share/lxr/http/lxr.conf
to suit your source-code. This file is set-up for linux source-code organization, so, does not work out of the blue for other source-codes. Here is the link to my lxr.conf file. Lines which are modified are highlighted. Most important is to change srcrootname to the root directory of your code. In my case, this entry was modified to

srcrootname: ericvh-brasil


Once you configure /usr/share/lxr/http/lxr.conf, perform following steps.

cd /usr/share/lxr/source/inferno
genxref

Now, your lxr is ready to browse.
Visit http://localhost/lxr/http/source/ericvh-brasil/ to start browsing the code.

If you have system other than Linux or inferno, just try and replace inferno and ericvh-brasil with your version name and source-code root directory and hopefully it will work.

I am quite sure that, this is not the most optimal way to get lxr working. Few of the above steps can be avoided. But, above steps worked for me. Lets hope it helps others as well.

No comments:

Post a Comment