Eyes, JAPAN Blog > How to store custom binary builds in a convenient way

How to store custom binary builds in a convenient way

denvazh

この記事は1年以上前に書かれたもので、内容が古い可能性がありますのでご注意ください。

Reason

Recently, I found myself in building an creating dozens of binaries for the same project which I had to test simultaneously, so obvious task for me was to make it more convenient and efficient way.
Note: this post might be interesting for those who knows how command-line magic works 🙂

Use-case

I like examples. It’s always better to show once, then explain in theory again and again. Last time I was building mesa library from sources, so let’s use this as an example for this nice blog post.
Usual sequence of commands for building something from sources:

$: ./configure
$: make
$: make install

With this setup, however, majority of applications are installed to “/usr/bin” or “/usr/local/bin” , i.e. system-wide. So, unless you absolutely sure that it works, it is better to test stuff locally, say
in your own user’s home folder. To do this, we supply ./configure script with “–prefix” option, where we set path below which we would like to install files. I usually, put such kind of stuff to “$HOME/opt”
directory. There I put stuff I don’t want to install system-wide. Going back to our use-case, and assuming that we testing how mesa library would build, let’s assume we have 7.11.1 and 7.11.2 versions.

So, we will build them like this:

For 7.11.1 version:

$: ./configure --prefix=$HOME/opt/mesa/7.11.1
$: make && make install

For 7.11.2 version:

$: ./configure --prefix=$HOME/opt/mesa/7.11.2
$: make && make install

Then if we look inside the “$HOME/opt/mesa” we find the following structure:

$: ls -1 $HOME/opt/mesa
7.11.1
7.11.2

Now we are at the goal of this blog post. How this setup is easy for testing? Answer is obvious: It’s flexible!

Let’s create symbolic link to the library version we would like to use:

$: cd $HOME/opt/mesa
$: ln -s 7.11.2 current
$: ls -1a
7.11.1
7.11.2
current -> 7.11.2

The we can enable library from within .bashrc or .bash_profile ( in case of BASH shell ) adding lines below:

$MESA_HOME=$HOME/opt/mesa/current
$MESA_LIB=$MESA_HOME/lib

# In case of Linux
export LD_LIBRARY_PATH=$MESA_LIB:$LD_LIBRARY_PATH

# In case of Mac OS X
export DYLD_LIBRARY_PATH=$MESA_LIB:$DYLD_LIBRARY_PATH

Conclusion

Setting up custom builds one makes in his home folder is very flexible and reliable if done this way. Mainly because
all the build are installed below specific directory and already categorized. Also, when one needs to select different version all he need to do is
to delete existing symlink at “$HOME/opt/mesa” and create new one, running “ln -s current %some other version%”

Comments are closed.