Created at:

Opengrok notes

Setup on NetBSD with Tomcat

Install pkgsrc/devel/opengrok. pkgsrc will resolve its dependencies.

OpenGrok is a Java web application that runs under Tomcat so we need to make it work under Tomcat. The documentation you have to follow is in /usr/p../../share/opengrok/README.txt.

OpenGrok Tomcat webapp is in source.war. This file is not more than a zipped file. You need to edit the web.xml file that is in it.

Extract and edit WEB-INF/web.xml file::

    $ cd /usr/p../../share/opengrok/
    $ unzip source.war WEB-INF/web.xml
    $ vi WEB-INF/web.xml

Edit the DATA_ROOT parameter. Its value (<param-value>) have to be the final directory where OpenGrok database (in order to allow cross-reference and searching) will be created.

Edit the SRC_ROOT parameter. Its value have to be the source code of your application. See that if you are using CVS, this variable should not point to the CVS repository, but for a directory with already checked out modules.

Note: When setting these paths, it is a good idea to let a trailing slash at the end of them. Official documentation doesn't say anything about that, but I had problems not letting the trailing slash.

After editing the WEB-INF/web.xml file, pack it back in the source.war file::

    $ zip -u WEB-INF/web.xml

Now move the source.war file to the Tomcat web apps dir::

    $ mv source.war /usr/pkg/tomcat/webapps

Now we need to start Tomcat::

    $ cd /usr/pkg/tomcat/bin
    $ export JAVA_HOME=/usr/pkg/java/sun-1.5
    $ ./startup.sh

Tomcat running at the default port, 8080. Just open a browser and see what is running at localhost:8080 (replace "localhost" for the hostname Tomcat is installed in).

Now it is possible to browse the source code checked out from CVS, but cross-reference and searching are not working yet. It is necessary to setup the database. So create the following script::

    #!/bin/sh

    PROGDIR=/usr/p../../share/opengrok
    SRC_ROOT=/home/silas/src
    DATA_ROOT=/disk/files/www/opengrok
    EXUB_CTAGS=/usr/pkg/bin/exctags

    /usr/pkg/java/sun-1.5/bin/java -jar ${PROGDIR}/opengrok.jar -c ${EXUB_CTAGS} -s ${SRC_ROOT} ${DATA_ROOT}

Just run this script. When it is done, the database is created and OpenGrok should now work with cross-reference and searching features. If some problem arise, check if DATA_ROOT and SRC_ROOT in web.xml and correct.

You can improve the script above to include checkout of your CVS repository and put it in crontab to make update automatic.

Some references I used:

Forum in opensolaris.org

Opengrok website

A Readme.txt in opensolaris.org site