Faking a Linux environment without chroot

1

1

For a university project I want to test a C++11 program on a 32-core machine. Unfortunately the machine has Ubuntu 12.04 with GCC 4.6 installed (we need GCC 4.7 because of some C++11 threading features). In such an environment I would normally run a chroot with a custom linux (say a debootstrap with Ubuntu 12.10). Since we don't get root access on the machine we can't use chroot.

So far I have prepared a run-time environment using debootstrap for our code, I compiled it in the debootstrap environemnt. Then copied it onto the server (using rsync). In order to run our C++ code I set the LD_LIBRARY_PATH to

export LD_LIBRARY_PATH=~/debootstrap/usr/lib/:~/debootstrap/lib64/:~/debootstrap/usr/lib/x86_64-linux-gnu/:~/debootstrap/lib/x86_64-linux-gnu/:$LD_LIBRARY_PATH

and so far our code seems to run. I'm however stuck with our python code. It doesn't seem to be sufficient to set the paths manually.

export PYTHONPATH=~/debootstrap/usr/lib/python2.7/dist-packages:~/debootstrap/usr/lib/python2.7:~/debootstrap/usr/lib/python2.7/plat-linux2:~/debootstrap/usr/lib/python2.7/lib-tk:~/debootstrap/usr/lib/python2.7/lib-dynload:~/debootstrap/usr/local/lib/python2.7/dist-packages:~/debootstrap/usr/lib/pymodules/python2.7:~/debootstrap/usr/lib/python2.7/dist-packages/PIL:~/debootstrap/usr/lib/python2.7/dist-packages/gtk-2.0:~/debootstrap/usr/lib/python2.7

Executing our script results in

ImportError: No module named _path

Is there an easier way to accomplish a "fake"-chroot than just overriding and creating environment variables?

Note I need python since we created a custom C++-Python module in order to run our tests. Maybe I should create two questions from this.

Pascal

Posted 2012-12-10T21:48:29.547

Reputation: 183

What about downloading the newer version of gcc (or the source) and installing it as a use in your home directory (if you have one)? Well, how big is this program? – Nick – 2012-12-10T22:01:22.143

1Did you also try to set PYTHONHOME? – Cedric – 2012-12-10T22:18:55.303

What's the standard location for PYTHONHOME? Is it /usr/lib/python2.7? – Pascal – 2012-12-10T22:27:38.703

Nick: it's easier to create a sandboxed environment because replacing gcc requires also the replacement of glibc (or a recompilation) which then also has very broad side effects. – Pascal – 2012-12-10T22:35:59.293

1

Have you tried fakeroot or fakeroot-ng? You might be able to coerce a chroot under fakeroot-ng...

– allquixotic – 2012-12-10T22:51:17.197

There's actually a package called fakechroot. Which allows for the creation of a "fake" chroot environment (exactly what we need actually). I'm however hesitant since both fakeroot and fakechroot can produce a significant performance overhead since all system calls are redirected.. – Pascal – 2012-12-10T23:14:51.783

@Nick: Pascal stated a requirement to use a 32-core machine.  Not many people have one of those at home. – Scott – 2012-12-10T23:18:10.533

@Pascal: when you respond to a comment (in a new comment), it’s conventional to mention the author’s name, preceded by a “@” symbol, as in “@Nick”.  That way he gets notified.  See the Replying in comments paragraphs of the Comment formatting section of the Markdown Editing Help page.

– Scott – 2012-12-10T23:18:43.420

Have you tried using virtualenv to manage your python environment? – Darth Android – 2012-12-10T23:46:50.110

@Pascal, oops. I must have glazed over it and read it as 32-bit. Even so, I think I'm out of my league. – Nick – 2012-12-11T12:31:35.643

@allquixotic fakechroot seems to work but we had to take special care of the symlinks in the directories. I'm a bit unsure about the performance overhead though. – Pascal – 2012-12-12T20:27:45.077

@DarthAndroid: virtualenv is a bit problematic since ubuntu does some weird stuff to their python libraries... We managed to run some of the libraries but only in a fachechroot environment after taking care of the symlinks. For the time being we just request the python libraries on the target machine... – Pascal – 2012-12-12T20:29:57.540

@Cedric For the python problem. Pip install --user <pythonmodules> definitely helped ;) – Pascal – 2012-12-12T21:11:18.047

No answers