{OpenGrok setup under ubuntu

Its quite easy and really handy in source code browsing. If you are aware of LXR, and want to setup a similar stuff for your own source code repo, OpenGrok is the thing. I know cscope with ctags can do the trick in VIm, but not all guys like vim that much :) So here is the link which explains it in great detail – worth reading (and implementing).


I am just summarizing the steps:

1. Need following packages.

And of course, OpenGrok, but i don’t think its there in ubuntu repo, so need to go to the official webpage of OpenGrok (which is http://opensolaris.org/os/project/opengrok/) and download it from there.

Now from the shell,

cd ~/src/
wget http://opensolaris.org/os/project/opengrok/files/opengrok-0.7.tar.gz
tar -xvzf opengrok-0.7.tar.gz
cd opengrok-0.7

sudo mkdir -p /var/lib/opengrok/bin
sudo mkdir -p /var/lib/opengrok/data
sudo mkdir -p /var/lib/opengrok/src
sudo mkdir /var/log/opengrok/

#To following files will be present under the opengrok package which you have downloaded, just search for that
cp -r run.sh OpenGrok opengrok.jar lib /var/lib/opengrok/bin/

#Now go to /var/lib/opengrok/src directory and put the source-code for which you want to generate the cross-reference pages. You can put as many directories as you want, and you can add any number of directories later on as well.

cd /var/lib/opengrok/src/
svn checkout <repo1_URL>
svn checkout <repo2_URL>

#Now start the indexing process - got and get yourself a coffee, it takes a while - depending upon the size of your code-base

sudo java -jar /var/lib/opengrok/bin/opengrok.jar -W /var/lib/opengrok/configuration.xml -c /usr/bin/ctags -P -s /var/lib/opengrok/src/ -d /var/lib/opengrok/data -w opengrok -L polished

#Now its time to setup the webpage - which will have the links for cross references
#Again, find the following .war file from the opengrok download package.

unzip source.war -d source
cd source
vi WEB-INF/web.xml

#Change the CONFIGURATION context-param to point to our configuration file, but be sure to leave the ConfigAddress alone since this is required for source history and annotation to work. 

    <description>Full path to the configuration file where OpenGrok can read it's configuration</description>

#Now we update the web.xml in the war and deploy the webapp as opengrok.war. This matches the context we specified when generating the index. 

zip -u ../source.war WEB-INF/web.xml
sudo cp ../source.war /var/lib/tomcat6/webapps/opengrok.war

#Hurray, it's done!! Go to browser, and type http://localhost:8080/opengrok

That’s it. It should work.


One thought on “{OpenGrok setup under ubuntu

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s