Solaris serviceability and nifty tools

OpenGrok 0.11 setup on Solaris 11

OpenGrok 0.11 has been just released (see Lubos' post with release notes). This is nice version number coincidence to try it on Solaris 11.
In case you are wondering what is OpenGrok, it is blindigly fast source code search and cross reference engine accessible over web.
It is written in Java. It is also behind the source code browser on src.opensolaris.org, albeit running older version.
For more information about the project take a look at its project page.

Now, how to get OpenGrok running for your source code base on Solaris 11. I will illustrate this on source code coming from three different Source Code Management systems (for complete support see the full list).
The complete setup on freshly installed Solaris 11 has 6 main steps:

  1. Install pre-requisities first:
    1. install couple of Source Code Management systems (depends on your needs):
      • install Mercurial:
            pkg install developer/versioning/mercurial
      • install CVS
            pkg install developer/versioning/cvs
      • git
            pkg install developer/versioning/git
    2. download, compile and install exuberant ctags:
      pkg install developer/gcc-45
      pkg install system/header
      wget http://prdownloads.sourceforge.net/ctags/ctags-5.8.tar.gz
      tar xfz ctags-5.8.tar.gz
      cd ctags-5.8
      ./configure && make && make install
    3. install Tomcat6:
        pkg install web/java-servlet/tomcat

  2. Now download and install OpenGrok package:
    pkgadd -d $location/OSOLopengrok-0.11.pkg OSOLopengrok

  3. Mirror some source code as webservd user (note that OpenGrok by itself does not synchronize or mirror source code, this has to be done separately):
    cd /var/opengrok/src/
    cvs -d anonymous@cvs.openssl.org:/openssl-cvs co -rOpenSSL_1_0_0-stable openssl
    hg clone ssh://anon@hg.opensolaris.org/hg/opengrok/trunk opengrok-dev
    git clone http://git.samba.org/samba.git
      Run the following first (as root) to make sure history indexing does not prompt to confirm the identify when consulting with remote repositories (CVS):

      # store the pubkeys
      ssh-keyscan -t rsa,dsa cvs.openssl.org >> /etc/ssh/known_hosts
      ssh-keyscan -t rsa,dsa hg.opensolaris.org >> /etc/ssh/known_hosts

  4. Deploy and start the web application (as root):
    EXUBERANT_CTAGS=/usr/local/bin/ctags \
    /usr/opengrok/bin/OpenGrok deploy && \
    svcadm enable tomcat6

  5. Index the source code and send the configuration to the running instance (as webservd user):
    EXUBERANT_CTAGS=/usr/local/bin/ctags \
    /usr/opengrok/bin/OpenGrok index

  6. enable the service (as root):
    svcadm enable opengrok

OpenGrok is now accessible at http://SERVER_HOSTNAME:8080/source/ (where SERVER_HOSTNAME is the hostname of the server on which the above setup was done).

Except for the part with ctags it is pretty streamlined and no brainer process. Hopefully the exuberant-ctags package will be available again from the standard Oracle pkg repositories.

And here is the result:

Join the discussion

Comments ( 11 )
  • Taz Thursday, February 9, 2012

    Good howto, RESPECT ! :)

  • guest Thursday, February 9, 2012

    I tried the above process but when I access the source through browser it is not showing any source code. Where are we indexing the source code.

    I assume through this command right

    EXUBERANT_CTAGS=/usr/local/bin/ctags \

    /usr/opengrok/bin/OpenGrok deploy && \

    svcadm enable tomcat6

    Should'nt we give the path of the sources?

  • Vladimir Kotal Friday, February 10, 2012

    @guest: the indexing of source code is done in step #5. It uses the default location of source code (/var/opengrok/src, see how it is used in step #3) so it is not necessary to explicitly state the source code path.

  • guest Friday, February 10, 2012

    When I try the indexing step #5. I get the warnings about BazaarRepo not working.

    Is this why I am not able to see any sources?

    Thank you!

    # EXUBERANT_CTAGS=/usr/local/bin/ctags \

    > /usr/opengrok/bin/OpenGrok index

    Loading the default instance configuration ...

    08:44:08 WARNING: BazaarRepository not working (missing binaries?): /var/opengrok/src/opengrok-dev/testdata/repositories/bazaar

    08:44:08 WARNING: BazaarRepository not working (missing binaries?): /var/opengrok/src/opengrok-dev/testdata/repositories/bazaar

    08:44:08 WARNING: Skipping creation of historycache of BazaarRepository repository in /var/opengrok/src/opengrok-dev/testdata/repositories/bazaar: Missing SCM dependencies?

  • Vladimir Kotal Friday, February 10, 2012

    @guest: No, that's not it. The indexer prints this warning because the opengrok source code (stored under /var/opengrok/src/opengrok-dev) contains Bazaar repository (Bazaar is one of the Source Code Management systems) for testing purposes. opengrok-dev repository is Mercurial based so the warning is not relevant.

  • guest Friday, February 10, 2012

    @Vladimir: Thank you for that clarification. One quick question the SERVER_HOSTNAME should be the i.p address of the machine I am setting this up on right?

    I am not sure why it is not showing me the sources. When I access http://SERVER_HOSTNAME:8080/source/ I see the opengrok-dev in the project dropdown but there are no files listed! :(

  • Vladimir Kotal Friday, February 10, 2012

    @guest: yes, SERVER_HOSTNAME is the hostname of the server where the commands are run. The fact that opengrok-dev is listed in the menu means the web application was configured correctly and is aware of the project. Try double clicking on the opengrok-dev and you should see the files. Also, you can perform some search - e.g. select the opengrok-dev project, enter 'java' (without the quotes) to the File Path field and hit Search.

  • guest Friday, February 10, 2012

    @Vladimir: When I double click on the opengrok-dev I get a file not found error and there are no files displayed!

  • guest Friday, February 10, 2012

    Also when I try to execute the ssh-keyscan i get an error saying

    "getaddrinfo anon@hg.opensolaris.org: node name or service name not known"

  • Vladimir Kotal Monday, February 13, 2012

    @guest: ssh-keyscan accepts hostname, only. I fixed the instructions accordingly.

  • Vladimir Kotal Monday, February 13, 2012

    @guest: after some off-line communication we figured that the files in data directory are not owned by webservd as they should; recursive chown command fixed the problem. The key is that indexing (step #5) is run under the webservd user.

Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.