Not Really a Blog

January 21, 2008

Installing From Source, The Easy Way

Filed under: Linux, System Administration — Tags: — jesus @ 00:40

Installing software in any unix-like operating system these days has become very easy. Package managers such as dpkg, the one used by Debian or Ubuntu, take most of the hassle by dealing with all the dependencies and intricacies that modern software has nowadays. It’s just a matter of getting the package that some hard-working and/or generous developer has made and install it in our system. It’s straightforward compared with how things were a mere few years ago.

We’ve always had the possibility of installing from the software, provided we have resolved all the needed dependencies. Installing from the source can be handy and useful at times. We might want to change some options on compile time or we might want to have two versions of the same package installed on different locations for example.

The problem lies when we want to upgrade the software and we have different versions of it installed, we could end up in a very cluttered scenario, say, with files installed across the file system from different versions of it. Even more, we might not have an easy way to track down which files belong to which version, let alone uninstalling the software.

The Easy Way ® ;-)

As always there are simple solutions for complex problems. There is a nice piece of software which helps us to keep track of software packages installed from source in a clean way. It doesn’t work for all cases, but it does a pretty good job for most of them. I’m talking about epkg, The Encap Package Manager.

I’ll try to describe how it works in a not very technical or detailed way, just to get you going with it and then I’ll install it on my system so you’ll be able to see how handy it is.

Basically, all you have to do is install all software packages on a directory on /usr/local/encap, creating a directory for each of them in a package-version.revision fashion. Then we will use epkg to just create symlinks to the appropriate places, usually /usr/local.

So, say we’ve got:


epkg would create symlinks such as:

/usr/local/bin/mysoft  ->  /usr/local/encap/mysoft-1.1/bin/mysoft
/usr/local/lib/  -> /usr/local/encap/mysoft-1.1/lib/

and that’s it, pretty much. With more complex packages it can get more difficult, but you get the idea.

Let’s just see an example

First of all, we need to install epkg on our system. I will be using an Ubuntu 7.10 system, which, to date, doesn’t have epkg on it. So I will install it from source in the usual way, to /usr/local

root@kore:/usr/local/src# wget
           => `epkg-2.3.9.tar.gz'
23:47:32 (85.66 KB/s) - `epkg-2.3.9.tar.gz' saved [237232]

root@kore:/usr/local/src# tar xfz epkg-2.3.9.tar.gz
root@kore:/usr/local/src# cd epkg-2.3.9/
root@kore:/usr/local/src/epkg-2.3.9# ./configure --prefix=/usr/local
checking for epkg... no
checking for mkencap... no
checking for Encap source directory... /usr/local/encap
checking for Encap target directory... /usr/local
checking for Encap package directory... /usr/local/encap/epkg-2.3.9
checking for gcc... gcc
config.status: creating epkg/Makefile
config.status: creating mkencap/Makefile
config.status: creating mkencap/mkencap_environment
config.status: creating doc/Makefile
config.status: creating config.h

As we see, we’ll install the package with its default options, pointing to to /usr/local/encap as the encap directory. Please, see the help for more options.

We install it:

root@kore:/usr/local/src/epkg-2.3.9# make && make install
epkg: installing package epkg-2.3.9...
  > reading Encap source directory...
  > installing package epkg-2.3.9
    !  man: not an Encap link
    > executing postinstall script
installing: /usr/local/etc/mkencap_environment
    > installation partially successful

If we have a look at /usr/local/bin and /usr/local/encap it has installed itself as an encapped package :), and now we are ready to use it with a real example.

Installing GLE

Say we wanted to install The Graphics Layout Engine, or GLE on our computer and we don’t have a binary package at hand, or we want to control it, or whatever :), let’s just do it with epkg.

  1. Get the source
    root@kore:/usr/local/src# wget
    root@kore:/usr/local/src# unzip
    root@kore:/usr/local/src# cd gle4/
  2. Configure: We will be configuring the software to make it believe it is going to be installed on /usr/local but we will actually install it on /usr/local/encap/ instead, so epkg can deal with it. This is an important step, so let’s just do it by configuring it with those options and with any other that we might want to use:
    root@kore:/usr/local/src/gle4# aptitude install libpng12-dev libpng12-0 libtiff4-dev libtiff4 libjpeg62-dev libjpeg62
    root@kore:/usr/local/src/gle4# ./configure --with-qt=no --prefix=/usr/local
    root@kore:/usr/local/src/gle4# make

    As you can see, I installed some dev packages (using debian’s aptitude) because they are dependencies for GLE. After that, I configure the package without any graphical environment (based on Qt) and pointing to /usr/local. Then we compile it.

  3. Installing. Now, we will be installing it on /usr/local/encap. Bear with me now and I’ll explain what I did after doing it :)
    root@kore:/usr/local/src/gle4# make DESTDIR=/usr/local/encap/GLE-4.1.1 install
    root@kore:/usr/local/encap/GLE-4.1.1# mv usr/local/* .
    root@kore:/usr/local/encap/GLE-4.1.1# rm -rf usr
    root@kore:/usr/local/encap/GLE-4.1.1# ls
    bin  lib  share

    Ok, we what I’ve done is execute make install but setting the DESTDIR variable (which is supported by GLE’s Makefile) to install it on /usr/local/encap/GLE-4.1.1. But there, it is usually installed within its own “usr/local” directory, so to make it be as if it were installed on /usr/local hierarchy, we move it to the right place so now we have:


    and so on.

  4. Install it with epkg Now the final step is to call epkg to actually create the proper symlinks and that’s it:
    root@kore:/usr/local/encap/GLE-4.1.1# epkg GLE
    epkg: installing package GLE...
      > reading Encap source directory...
      > installing package GLE-4.1.1
        > installation successful
    root@kore:/usr/local/encap/GLE-4.1.1# gle
    GLE version 4.1.1
    Usage: gle [options]
    More information: gle -help

And that’s it, really. Now, two things,

  • If we install a newer version, say 4.2.0 whenever that’s ready, we just install it on /usr/local/encap/GLE-4.2.0 as we’ve seen before, and simple calling again
    # epkg GLE

    would create the right symlinks (that’s it, “deinstall” the previous version and install the new one.

  • If we want to uninstall it, that’s it, remove the symlinks, we simply issue this command:
    # epkg -r GLE

    and that’s all.


  1. epkg lets us install software from source having control over it, ie. Installing it in a clean way, being able to deinstall it and upgrade it without cluttering the file system
  2. All you have to do is install the software on /usr/local/encap/package-version as if were /usr/local. The variable DESTDIR on Makefiles helps us to do it in an easy way. If the software is too simple, you’ll have to do it manually.
  3. Remember /usr/local/encap/package-version/usr/local/bin must end up as /usr/local/encap/package-version/bin.
  4. Execute epkg package to install it and epkg -r package to uninstall it.
  5. If you have problems with the libraries, try executing ldconfig.
  6. Be Careful I usually make mistakes, overwrite things and delete files, so take care with what you do and do it under your own responsibility ;-).
About these ads


  1. That’s very interesting. I’ll try to remember next time I need to keep two versions of the same software coexisting…

    Comment by tripu — January 21, 2008 @ 01:02

  2. […] de escribir una entrada en mi otro blog que me ha dejado un poco cabreado después de tener que corregirla varias […]

    Pingback by Terminus » Blog Archive » Editores para wordpress — January 21, 2008 @ 01:12

  3. Interesting…may come in handy some day…

    Comment by dbosque — January 31, 2008 @ 19:02

  4. Why don’t you just use
    # ./configure –with-qt=no –prefix=/usr/local/encap/GLE-4.1.1
    and leave out the DESTDIR specification and the moving of subdirectories?

    The programs should look for their own files in their own /usr/local/encap subdirectory, not in /usr/local, I think. If they would look in /usr/local, they would find the files of the currently installed version, while you can also execute other versions directly from /usr/local/encap.

    Other programs that use the files should look in /usr/local, not in /usr/local/encap, so they will just use the currently installed version via the symlinks.

    Comment by Fedde — April 27, 2010 @ 20:23

    • Well, I just want them to look for them in /usr/local as I’m only going to have the latest version installed.

      Comment by jroncero — April 28, 2010 @ 08:35

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The Shocking Blue Green Theme. Create a free website or blog at


Get every new post delivered to your Inbox.

Join 2,855 other followers

%d bloggers like this: