16 December 2012

293. Running GIMP 2.8 in a chroot on debian stable/squeeze (ugly)

Update: because I had copied and pasted some of the instructions from one of my earlier attempts at building gimp under stable, there were some minor discrepancies. Those are fixed now.

Original post:
Here's the least elegant and functional way of running GIMP 2.8 on stable/squeeze other than running it in a virtual machine.
 I've previously tried
 * creating a statically linked binary of gimp 2.8 under testing, then using it under stable (didn't work --
 * compiling gimp + all dependencies from scratch -- ballooned out of control
 * compiling the bare minimum needed for gimp from scratch, but had issues with libglib2.0-dev -- the dev files are obviously taken care of when you compile glib, but the -dev package is required by a lot of libraries needed for graphics support, and I wanted to replace the libglib2.0-0 package.

Long story short, I gave up. If you don't mind the overhead in terms of space, you can run it in a chrooted environment. It's not pretty, but it works.


We first set up a chrooted environment

sudo apt-get install debootstrap coreutils
mkdir -p $HOME/tmp/architectures/testing
cd $HOME/tmp/architectures
sudo debootstrap --arch amd64 testing $HOME/tmp/architectures/testing/ http://ftp.au.debian.org/debian/
sudo chroot testing/

Cosmetic
Sort out locales to avoid annoying error messages
apt-get install locales
echo 'export LC_ALL="C"'>>/etc/bash.bashrc
echo 'export LANG="C"'>>/etc/bash.bashrc
source /etc/bash.bashrc

Also, add your hostname (=beryllium) to /etc/hosts by putting your hostname at the end of the 127.0.0.1 line:
127.0.0.1 localhost beryllium

to avoid constant warnings about unresolved hostname like the one below
sudo: unable to resolve host beryllium

Continue
I don't like working as root even in a chrooted environment, so create a new user, 'build' and give it superuser powers:
adduser gimp

And edit /etc/sudoers to add
gimp ALL=ALL:ALL
Defaults !tty_tickets

The reason we add the !tty_tickets is that otherwise you will have to type the password each time you use sudo i.e. it will time out instantaneously.

Run the echo command below and exit your chroot:
echo "export DISPLAY=:0.0">>/etc/bash.bashrc
exit
And put this in a file, e.g. gimp.sh
xhost + sudo mount -o bind /proc $HOME/tmp/architectures/testing/proc sudo cp /etc/resolv.conf $HOME/tmp/architectures/testing/etc/resolv.conf sudo chroot $HOME/tmp/architectures/testing
Run
sh gimp.sh

Now inside the chrooted shell that you just started, do
su gimp
cd ~

Time to install gimp
sudo apt-get install gimp

And you're done!

You can now run GIMP 2.8 in the chrooted environment. It is NOT elegant though.
Gimp running in a chrooted Wheezy on a Squeeze virtual machine (LXDE) on a Wheezy physical machine (gnome 3).
Moving files in and out of the jail:
There are a few options -- you can obviously always move files from your host system to the chroot jail. A major point of a chroot jail is that you can't access the host system though, but we've set up our gimp.sh so that we can connect via ssh or sftp as well

In your chroot, as the user gimp, do e.g.
sudo apt-get install openssh-client
sftp me@host:shared/

I warned you that it wasn't elegant...

No comments:

Post a Comment