Tuesday, December 7, 2010

Installing OpenGrok on Debian squeeze

If you have come across lxr, then you might like openGrok. It's a cross referencer for your code. It also highlights as a bonus :) Have a look at the openoffice instance

Pull in the dependencies
  • sudo aptitude install sun-java6-jdk tomcat6 exuberant-ctags

For debian lenny, there default sysctl setting fraks up java. Fix it by setting the vars in /etc/sysctl.d/bindv6only.conf
  • net.ipv6.bindv6only = 0
  • You may restart procps or
  • echo 0 > /proc/sys/net/ipv6/bindv6only
Download the opengrok binary and unzip it
  • wget http://hub.opensolaris.org/bin/download/Project+opengrok/files/opengrok%2D0.9.tar.gz

Make the opengrok directory tree
  • mkdir /opt/opengrok/ && cd /opt/opengrok && mkdir bin data lib source

Copy over files from the unzipped directory to the installation directory
  • cp ~/opengrok-0.9/bin/* bin/
  • cp ~/opengrok-0.9/lib/ lib/

Fix your app
  • mkdir /opt/opengrok/web && cd /opt/opengrok/web && unzip ../lib/source.war
  • Edit your WEB-INF/web.xml to have:
<!-- My configs -->
<context-param>
<param-name>DATA_ROOT</param-name>
<param-value>/opt/opengrok/data</param-value>
<description>REQUIRED: Full path of the directory where data files generated by OpenGrok are stored</description>
</context-param>

<context-param>
<param-name>SRC_ROOT</param-name>
<param-value>/opt/opengrok/source</param-value>
<description>REQUIRED: Full path to source tree</description>
</context-param>

<context-param>
<param-name>SCAN_REPOS</param-name>
<param-value>false</param-value>
<description>Set this variable to true if you would like the web application to scan for external repositories (Mercurial)</description>
</context-param>


  • Save and recreate the war
  • zip -r ../lib/source.war ./

Deploy your app
  • cd /opt/opengrok/bin && ./OpenGrok deploy
  • You should be able to hit the app: http://a.b.c.d:8080/source

Check out your code
  • cd /opt/opengrok/soure && hg clone https://blah.co.ke/app

Index
  • cd /opt/opengrok/bin && ./OpenGrok index /opt/opengrok/source/

Get to work :)

Pretty brilliant!

Thanks to:

4 comments:

  1. It did not work for me. I had the error:
    alberto@lallaccia /opt/opengrok
    $ cd /opt/opengrok/bin && ./OpenGrok index /opt/opengrok/source/
    Loading the default instance configuration ...
    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/oro/io/GlobFilenameFilter
    at org.opensolaris.opengrok.index.IgnoredNames.addPattern(IgnoredNames.java:174)
    at org.opensolaris.opengrok.index.IgnoredNames.access$000(IgnoredNames.java:42)
    at org.opensolaris.opengrok.index.IgnoredNames$PatternList.add(IgnoredNames.java:203)
    at org.opensolaris.opengrok.index.IgnoredNames$PatternList.add(IgnoredNames.java:192)
    at org.opensolaris.opengrok.index.IgnoredNames.add(IgnoredNames.java:110)
    at org.opensolaris.opengrok.index.IgnoredNames.addDefaultPatterns(IgnoredNames.java:167)
    at org.opensolaris.opengrok.index.IgnoredNames.(IgnoredNames.java:90)
    at org.opensolaris.opengrok.configuration.Configuration.(Configuration.java:117)
    at org.opensolaris.opengrok.configuration.RuntimeEnvironment.(RuntimeEnvironment.java:71)
    at org.opensolaris.opengrok.configuration.RuntimeEnvironment.(RuntimeEnvironment.java:56)
    at org.opensolaris.opengrok.index.Indexer.main(Indexer.java:76)
    Caused by: java.lang.ClassNotFoundException: org.apache.oro.io.GlobFilenameFilter
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    ... 11 more


    It worked though with version opengrok-0.10.tar.gz

    ReplyDelete
    Replies
    1. It's bee awhile since I looked at opengrok. The instructions above may have changed..

      Delete
  2. use OpenGrok script ;)

    ReplyDelete