LXR Guide

From Leo's Notes
Revision as of 19:16, 4 May 2013 by Leo (talk | contribs) (Created page with "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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
This page was last edited on 4 May 2013, at 19:16.

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.

The scripted guide is displayed below. It was used and tested on a clean install of ScientificLinux 6.3.

I recommend doing everything one step at a time as this was just the list of steps I used to configure/install it.

#!/bin/sh

cd /root

# Installing dependencies.
# Note: Screen isn't a dependency, but it is nice to run the indexer in the background.
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

# Ctags setup. lxr expects it as ctags-exuberant.
ln -s /usr/bin/ctags /usr/bin/ctags-exuberant

# Perl setup
#echo "I need you to init cpan, then run:"
#echo "cpan> install Search::Xapian"
#echo "cpan> install Apache2::Reload"
perl -MCPAN -e "install Search::Xapian Apache2::Reload"

#
# Postgres Setup
#
/etc/init.d/postgresql initdb
/etc/init.d/postgresql start
echo "I need you to enter:"
echo "postgres=# ALTER USER postgres WITH ENCRYPTED PASSWORD 'lxrng';"
echo "postgres=# CREATE DATABASE lxrng;"
echo "postgres=# \q"
sudo -u postgres psql

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

# Apply - restart required
/etc/init.d/postgresql restart

chkconfig postgresql on --level 345

#
# LXR Setup
#
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

# Configure lxrng - change the settings here as necessary
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

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

# Either get everything from git by running:
#  git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
# or get it from an existing source.
cd repos
wget http://pages.cpsc.ucalgary.ca/~leo/support/linux-2.6-source.tar.gz -O - | tar -xzf -

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

#
# Setup 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

echo "Done."
echo "Run 'screen -r' to view the progress of the cross reference generation progress"