Installing From Source, The Easy Way

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:

/usr/local/encap/mysoft-1.1/bin/mysoft
/usr/local/encap/mysoft-1.1/lib/mysoft.so

epkg would create symlinks such as:

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

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 ftp://ftp.encap.org/pub/encap/epkg/epkg-2.3.9.tar.gz
--23:47:17--  ftp://ftp.encap.org/pub/encap/epkg/epkg-2.3.9.tar.gz
           => `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#
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
root@kore:/usr/local/src/epkg-2.3.9#

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 http://surfnet.dl.sourceforge.net/sourceforge/glx/GLE-4.1.1-src.zip root@kore:/usr/local/src# unzip GLE-4.1.1-src.zip 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.

  1. 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# 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:

/usr/local/encap/GLE-4.1.1/bin
/usr/local/encap/GLE-4.1.1/lib
/usr/local/encap/GLE-4.1.1/share

and so on.

  1. 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# root@kore:/usr/local/encap/GLE-4.1.1# gle GLE version 4.1.1 Usage: gle [options] filename.gle More information: gle -help root@kore:/usr/local/encap/GLE-4.1.1#

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.

Summary

  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 ;-).

Tags// ,
comments powered by Disqus