Praveen's Blog

An Eternal Quest for Incremental Improvement

Per-user Mercurial Installation

Recently, I had to install Mercurial on one of our Solaris 10 development machines without root access. The installation procedure was a little bit tricky. So, I thought it would be helpful to share the experience.

First, I downloaded Mercurial source and extracted it. This is a standard procedure for installing any package from source.

$ wget http://mercurial.selenic.com/release/mercurial-1.3.tar.gz
$ tar -zxvf mercurial-1.3.tar.gz
$ cd mercurial-1.3

The installation mechanism is directly controlled by the Makefile. Per-user installation can be selected by choosing Makefile target install-home, install-home-bin or install-home-doc. The target install-home is a collection of install-home-bin and install-home-doc targets. The target install-home-bin builds/installs Mercurial binaries and the target install-home-doc builds/installs Mercurial documentation. To build the documentation, we would need ASCIIDOC and XMLTO. So, I decided to skip building the documentation. The target that I chose was install-home-bin. The installation prefix can be controlled by the environment variable HOME.

The build process uses C compiler to compile Mercurial extensions written in C and linker to create the shared libraries. We need to specify the desired compiler and linker through CC and LD environment variables respectively. When using GCC, we need to specify CFLAGS to build relocatable objects. If the Python library is located in a non-standard location, we have to specify LDFLAGS appropriately as well. Here is how my compilation line looked like.

$ make install-home-bin HOME=/home/praveen/chaos.SunOS CC=gcc CFLAGS="-fPIC" \
    LDSHARED="gcc -shared" LDFLAGS="-L/opt/csw/lib -Wl,-R/opt/csw/lib"

Once installed, I had to configure my PATH and PYTHONPATH with the location of installation. To make this persistent, I had to add it to ~/.bashrc file.

$ export PYTHONPATH=${HOME}/chaos.SunOS/lib/python
$ export PATH=${HOME}/chaos.SunOS/bin:$PATH

Now I verified that Mercurial worked fine by running the following.

$ hg debuginstall
Checking encoding (ascii)...
Checking extensions...
Checking templates...
Checking patch...
Checking commit editor...
Checking username...
 No username found, using 'praveen@HOSTCENSORED' instead
 (specify a username in your .hgrc file)
No problems detected

Happy distributed version controlling!


Comments