By "default path", I mean "/usr/local
", or other paths managed by root ("system paths").
I have to install many application packages (by that, I mean: svn
, httpd
, git
, perl
, python
, ...) on a few Linux (RedHat) or Solaris (10, in local zones) servers.
But:
- those servers manage many different applications (sometimes using different versions of svn or perl or ...)
- I am not administrator on those servers (no
sudo root
for me)
I tried using, for instance on Solaris, pkgadd -R
to try an install pre-compiled packages in a custom path (namely within the homedir of a specific user, rather than in the normal default path of /usr/local/...
), but said pre-compiled packages all comes with references to other resources in /usr/...
:
A ldd /path/to/local/installed/packages
will show many dependencies to system paths:
ldd /home/myuser/usr/local/git
libz.so => /usr/local/lib/libz.so
libiconv.so.2 => /usr/local/lib/libiconv.so.2
libsocket.so.1 => /usr/local/libsocket.so.1
...
That will not do, because:
- In Solaris, I have no way to write anything on
/usr
which is only writable from the global zone, not from a local zone. - In Solaris or Linux, I am not root anyway, so I cannot write anything in system path.
- I don't manage the upgrades on those servers, so if any library changes, it can potentially breaks many of my installed services.
What would you recommend to do in order to install in an isolated way different "services" on a same (Linux or Solaris) server, each one potentially requiring their own version of (perl, python, ...)?
I propose a solution below, but if you have other alternatives, I am interested.
The only solution I have found so far:
is:
recompile everything
(and by everything, I mean even
gcc
itself if needed, since the/usr/swf/bin/gcc
installed by default on our Solaris servers is even older than the pre-requisitegcc
3.4.6)All the versions used in this global recompilation are comming from sunfreeware, which will details all the necessary dependencies, and will provide a link to the sources for each packages.
That works both on Linux and Solaris.
Each package source is downloaded, compiled, and installed in
$HOME/usr/local
(i.e. not in a system path).The key is to have a
.bashrc
(for instance) which will change the $PATH in order to not have any/usr/bin
or/usr/local/bin
in it, but only$HOME/usr/local/bin
.I found over time several advantages:
/usr
can change, that will have 0 impact on the several services currently running (because they all have been compiled on their own set of dependencies installed in$HOME/usr/local
)$HOME/usr/local
$HOME
and compile again all dependencies for testing an upgrade of a given application. You can end up with several versions of a same package, and test/switch from one version to another.The main disadvantages are:
But you don't always need to recompile everything.
LDFLAGS
,CFLAGS
,CPPFLAGS
,LD_LIBRARY_PATH
) can be tricky to setup with the right values(I am in the process of making that script, and will publish it on GitHub)
There's an option to set up a chroot environment for every service and installing those packages under that. It certainly involes some bloat in that you are required to basically replicate many libraries into chroot environment. But it does isolate your services from everyone else's and vice versa and gives you full (root-like) control over the enviroment.
This still requires root access to set up and to access the chroot environment.
Subsequent access can be managed using e.g. SSH:
http://www.techrepublic.com/blog/opensource/chroot-users-with-openssh-an-easier-way-to-confine-users-to-their-home-directories/229
On Solaris, you can define RPATH using the $ORIGIN magic word. For example, if you have the following layout, you can define RPATH as '$ORIGIN/../lib' in the RPATH of your binaries, passing the -R flag to the linker.
However, it won't work if the layout is specified by the user. For example, the user could set bindir to /usr/local/bin/sparcv9 and libdir to /usr/local/lib/sparcv9. In this case the setting should be $ORIGIN/../../lib/sparcv9.
Traditionally, all binaries compiled for Solaris use hardcoded RPATH, which makes them non-relocatable.
One other thing to look at might be crle, which allows to configure the dynamic linker.