LXR Guide: Difference between revisions

From Leo's Notes
This page was last edited on 11 March 2014, at 23:54.
No edit summary
Line 1: Line 1:
LXR, shortened for Linux Cross-Reference, is a perl web application that lets you read linux kernel source code of different versions while having the benefit of having static values and functions 'linked' to each other which makes it a good reference when dealing with kernel source.
LXR, shortened for Linux Cross-Reference, is a perl web application that lets you read linux kernel source code of different versions with the benefit of having static values and functions 'linked' to each other which makes it a good reference when dealing with kernel source.


== Step by Step Guide ==
== Step by Step Guide ==

Revision as of 23:54, 11 March 2014

LXR, shortened for Linux Cross-Reference, is a perl web application that lets you read linux kernel source code of different versions with the benefit of having static values and functions 'linked' to each other which makes it a good reference when dealing with kernel source.

Step by Step Guide

Prerequisites

Install required packages. Unfortunately, there are a few packages that are not available through yum (through default repos), and must be built through CPAN. screen is not a dependency, but it is nice to run the indexer through it as it can take from hours to days depending on your hardware.

yum --nogpgcheck install \
    perl-CGI-Ajax \
    perl-CGI-Simple \
    perl-CPAN \
    perl-DBD-Pg \
    perl-DBI \
    perl-Devel-Size \
    perl-ExtUtils-CBuilder \
    perl-ExtUtils-MakeMaker \
    perl-ExtUtils-Embed \
    perl-PerlIO-gzip \
    perl-HTML-Entities* \
    perl-Term-ProgressBar \
    perl-Template* \
    xapian* \
    postgresql postgresql-server \
    httpd \
    mod_perl \
    mod_perl-devel \
    ctags-etags \
    make gcc gcc-c++ \
    git \
    screen

lxr expects it as ctag as ctags-exuberant.

 ln -s /usr/bin/ctags /usr/bin/ctags-exuberant

Install the missing dependencies through CPAN:

 perl -MCPAN -e "install Search::Xapian Apache2::Reload"


Setting up PostgreSQL

With PostgreSQL installed, set it up with a lxrng database. You may want to set up permissions as well, but I will be using the root account.

/etc/init.d/postgresql initdb
/etc/init.d/postgresql start

sudo -u postgres psql
  ALTER USER postgres WITH ENCRYPTED PASSWORD 'lxrng';
  CREATE DATABASE lxrng;
  \q

# Use passwords
sed -i "s/ident$/md5/g" /var/lib/pgsql/data/pg_hba.conf

# Apply changes by restarting
/etc/init.d/postgresql restart

# Make sure postgres starts on startup
chkconfig postgresql on --level 345

LXRng Setup

We will be putting LXRng into /export

mkdir /export
cd /export
# Source is from git. If unavailable, there is a copy at http://pages.cpsc.ucalgary.ca/~leo/support/packages/src/lxrng*.tar.gz
git clone git://lxr.linux.no/git/lxrng.git

Edit LXRng's configuration at lxrng.conf. Make sure the database settings and URL is correct.

cd lxrng
cp lxrng.conf-dist lxrng.conf
sed -i "s/\/var\/lib/\/export/g" /export/lxrng/lxrng.conf
sed -i "s/db_user => \"\"/db_user => \"postgres\"/g" /export/lxrng/lxrng.conf
sed -i "s/db_pass => \"\"/db_pass => \"lxrng\"/g" /export/lxrng/lxrng.conf
sed -i "s/localhost/lxr.lab.cpsc.ucalgary.ca/g" /export/lxrng/lxrng.conf
sed -i "s/'ver_default'\s*=>\s*'[a-z0-9.]*'/'ver_default' => 'v2.6.32'/g" /export/lxrng/lxrng.conf

Set up a few directories such as repos which will contain all the source code to be referenced.

mkdir repos
mkdir -p text-db/linux-2.6
mkdir cache
chmod 777 cache
touch lxr-ctags-quirks

Fetch the Kernel Source

Get the source code either via git or from an existing tarball.

cd repos

# wget http://pages.cpsc.ucalgary.ca/~leo/support/linux-2.6-source.tar.gz -O - | tar -xzf -
git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git

# or for the newest post-2.6 kernels:
git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

Start the indexing process:

cd /export/lxrng
./lxr-db-admin linux --init
screen -d -m ./lxr-genxref linux

Setting up Apache

cd /export/lxrng
cp apache2-site.conf-dist-mod_perl /etc/httpd/conf.d/lxrng.conf
sed -i "s/@@LXRROOT@@/\/export\/lxrng/g" /etc/httpd/conf.d/lxrng.conf
sed -i "s/@@LXRURL@@/lxr/g" /etc/httpd/conf.d/lxrng.conf
sed -i "s/^[\(^#\)]*/# /" /etc/httpd/conf.d/welcome.conf
/etc/init.d/httpd start
chkconfig httpd on --level 345


Run 'screen -r' to view the progress of the cross reference generation progress


Updating Kernel Source

cd repos
git pull git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git master