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:
pkg install developer/versioning/mercurial
pkg install developer/versioning/cvs
pkg install developer/versioning/git
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
pkg install web/java-servlet/tomcat
location=http://hub.opensolaris.org/bin/download/Project+opengrok/files/
pkgadd -d $location/OSOLopengrok-0.11.pkg OSOLopengrok
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
# 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
EXUBERANT_CTAGS=/usr/local/bin/ctags \
/usr/opengrok/bin/OpenGrok deploy && \
svcadm enable tomcat6
EXUBERANT_CTAGS=/usr/local/bin/ctags \
/usr/opengrok/bin/OpenGrok index
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:
Good howto, RESPECT ! :)
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?
@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.
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?
@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.
@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! :(
@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.
@Vladimir: When I double click on the opengrok-dev I get a file not found error and there are no files displayed!
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"
@guest: ssh-keyscan accepts hostname, only. I fixed the instructions accordingly.
@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.