Sunday, December 15, 2013

Setting up OpenGrok Source Browser in Ubuntu


OpenGrok is a JSP Servlet for Source Browsing similar to LXR (linux cross reference) but having more features and simpler to setup. Checkout http://opengrok.github.io/OpenGrok/  for more details.

Requirements:
    * Latest Java (At least 1.7)
      http://www.oracle.com/technetwork/java/
    * A servlet container like Tomcat (7.x or later)
      supporting Servlet 2.4 and JSP 2.0
      http://tomcat.apache.org/
    * Exuberant Ctags
      http://ctags.sourceforge.net/
    * Source Code Management (SCM) installation
      depending on type of repositories indexed (ex. git)

Installation of Requirements:
1. JDK will be available by default with the installation of Ubuntu 12.04 LTS. If not available, you can install using below command.
$ sudo apt-get install openjdk-6-jdk openjdk-6-jre
2. Install JSP Server Container - Tomcat.
$ sudo apt-get install tomcat6 tomcat6-common tomcat-examples tomcat6-admin tomcat6-docs tomcat6-extras
Note: packages tomcat6 and tomcat6-common are  sufficient and other packages are optional.

3. Install Exuberant Ctags
$ sudo apt-get install exuberant-ctags
4. Install SCM Tool - GIT
$ sudo apt-get install git git-core gitk 

Setting up OpenGrok
1. Download OpenGrok from the below link:
http://java.net/projects/opengrok/downloads/download/opengrok-0.11.1.tar.gz

Note: Below Steps require sudo/root permission.
2. Extract the contents of opengrok to /var 


$ sudo tar xvzf opengrok-0.11.1.tar.gz -C /var
3. Rename /var/opengrok-0.11.1 to /var/opengrok 
$ sudo mv /var/opengrok-0.11.1 /var/opengrok
4. Create additional directories under /var/opengrok
cd /var/opengrok
$ sudo mkdir etc src data web web/source
5. Copy opengrok JSP Server source.war to web direcory.
$ sudo cp lib/source.war web/
6. Extract opengrok JSP Server source.war to web/source direcory.
$ cd web/source
$ unzip ../source.war
7. Update opengrok src and data directories config in WEB-INF/web.xml as shown below (bold-italic) after the second occurrence of </context-param>  
 <context-param>
    <param-name>ConfigAddress</param-name>
    <param-value>localhost:2424</param-value>
    <description>An address where OpenGrok can receive new configuration</description>
  </context-param>

  <context-param>
    <param-name>SRC_ROOT</param-name>
    <param-value>/var/opengrok/src</param-value>
    <description>Source Directory containing all repositories</description>
  </context-param>

  <context-param>
    <param-name>DATA_ROOT</param-name>
    <param-value>/var/opengrok/data</param-value>
    <description>Data Directory for OpenGrok</description>
  </context-param>

  <listener>
   <listener-class>org.opensolaris.opengrok.web.WebappListener</listener-class>
  </listener>

8. Update the modified web.xml in source.war (using below command assuming current directory is /var/opengrok/web/source)
$  sudo zip -r ../source.war *
9. Deploy the modified source.war under tomcat webapps. (usally it will be /var/lib/tomcat6/webapps)
 $  sudo cp ../source.war /var/lib/tomcat6/webapps
10. Clone the required git repositories under opengrok/src
$  cd /var/opengrok/src
$ sudo git clone <git repository path>
Note: Multiple git repositories can be cloned under src directories as a sub-folder.

11. Build the opengrok index.
$  cd /var/opengrok/
$ sudo bin/OpenGrok index
Note: This will take a while depending on the no. of repositories and its size. This operation need to done whenever the src directories are updated (eg. using git pull) and it can also be automated using crontab to do at a specified interval.

12. Checkout the OpenGrok Source Browsing using your favourite Browser with the below URL:
Happy Source Browsing.


Basic Commands - Package Installation in Ubuntu

This post will help you with the basic commands for installation of packages in command-line in Ubuntu (12.04).

1. To install a debian package (.deb) downloaded from internet.
$ sudo dpkg -i <package name.deb>
2. To install a package from ubuntu repository.
$ sudo apt-get install <package name>
Note: you can pass -y option (yes for installation) in the above command to skip the y/n prompt for installation.

3. To search for a package from ubuntu repository.
$ sudo apt-cache search <package name>


Restart/reset USB in Ubuntu 12.04 without rebooting


      Sometimes USB devices will not get identified or locked in Ubuntu 12.04. To resolve this issue without restart, you can use the below command to do it.

Note: You need sudo/root permission to execute the below commands.

Either place the following into a script or run the commands directly:
echo -n "0000:00:1a.0" | tee /sys/bus/pci/drivers/ehci_hcd/unbind
echo -n "0000:00:1d.0" | tee /sys/bus/pci/drivers/ehci_hcd/unbind
echo -n "0000:00:14.0" | tee /sys/bus/pci/drivers/xhci_hcd/unbind
echo -n "0000:00:1a.0" | tee /sys/bus/pci/drivers/ehci_hcd/bind
echo -n "0000:00:1d.0" | tee /sys/bus/pci/drivers/ehci_hcd/bind
echo -n "0000:00:14.0" | tee /sys/bus/pci/drivers/xhci_hcd/bind
The hardware identifiers being passed around here can be revealed using a command like lspci | grep USB

Courtesy: http://davidjb.com/blog/2012/06/restartreset-usb-in-ubuntu-12-04-without-rebooting/

Saturday, December 7, 2013

Ubuntu Linux Configuration

Hardware:
Dell Inspiron 15 3521 Laptop 
Processor: 3rd Gen PDC
RAM: 4GB
Hardisk: 500GB

Operating System:
Ubuntu 12.04 LTS (64-bit)