Running rawhide app in chroot by example of Eclipse

You don’t need rawhide machine to test Fedora rawhide packages. In fact you don’t even need Fedora machine, any Linux distro should do.

First you’ll need YUM installed. It gets preinstalled on Fedora, but on other distros you’ll likely have to install it manually. I am running Debian, so I did:

apt-get install yum

On Fedora you can use DNF instead of YUM. I had to use YUM because DNF is not (yet) packaged for Debian.

You need to decide in which directory to install Eclipse. You’ll need at least 1 GB free storage space. I chose /srv/eclipse-rawhide/.

Next step is creaing basic directory structure and mounting udev, sysfs and proc.

mkdir -p /srv/eclipse-rawhide/{dev,proc,sys,etc}
mount -B /dev /srv/eclipse-rawhide/dev
mount -B /sys /srv/eclipse-rawhide/sys
mount -B /proc /srv/eclipse-rawhide/proc

Now time to configure YUM. Default YUM settings will do for us, it’s only really necessary to define repos from which Eclipse should be installed. Besides standard rawhide repo I also added Koji YUM repo to have the most up-to-date packages available without having to wait for compose and mirror sync.

cat <<EOF >/srv/eclipse-rawhide/etc/yum.conf
[fedora-rawhide]
name=fedora-rawhide
baseurl=http://ftp.linux.cz/pub/linux/fedora/linux/development/rawhide/x86_64/os

[fedora-rawhide-koji]
name=fedora-rawhide-koji
baseurl=http://kojipkgs.fedoraproject.org/repos/rawhide/latest/x86_64/
cost=2000
EOF

Lets install eclipse now. It’s done using (almost) standard YUM command:

yum --installroot /srv/eclipse-rawhide install eclipse

This will download about 350 MB of packages. If you have an existing YUM cache somewhere you can bind-mount it to /srv/eclipse-rawhide/var/cache/yum to reduce download size. I was to lazy to do that that and I needed a tee break anyways :)

Eclipse installed. We’re almost done. We can chroot in:

chroot /srv/eclipse-rawhide

Eclipse cannot run as root, so we have to create an unprivileged user and login as it.

adduser me
su me

We can run eclipse now.

eclipse

For me it didn’t work at first try because Eclipse couldn’t connect to X server. I had to copy .Xauthority file into chroot and re-run eclipse.

cp /home/kojan/.Xauthority /srv/eclipse-rawhide/home/me/
chroot /srv/eclipse-rawhide
chown me:me /home/me/.Xauthority
su me
eclipse

What normally do instead is bind-mount the whole home directory which contains not only .Xauthority, but also all my git repos and Eclipse workspaces. This works like a charm if you want to use rawhide Eclipse for your normal work. For testing it may be better to just copy required stuff into chroot.

By default Eclipse appearance may be quite ugly. You can improve it by installing some extra fonts and GTK theme of your choice.

yum --installroot /srv/eclipse-rawhide install @fonts gtk-nodoka-engine
ln -s /usr/share/themes/Nodoka/gtk-2.0/gtkrc /srv/eclipse-rawhide/home/me/.gtkrc-2.0

You can create a setuid-root script which will mount required stuff, chroot to /srv/eclipse-rawhide and run Eclipse for you. I don’t use any desktop environment, but if you do then you can even create .desktop file to launch Eclipse more easily.

Now you have a complete Eclipse installation under /srv/eclipse-rawhide. Updating it is just a matter of running YUM:

yum --installroot /srv/eclipse-rawhide update

Installing additional plugins is equally simple:

yum --installroot /srv/eclipse-rawhide install eclipse-m2e-core

This approach is faster and more lightweight than a VM (lower memory consumprion, no boot delays, no network latency, VNC overhead etc). It is also more stable than maintaining a VM (you are not affected by kernel, GRUB, Dracut or GNOME breakage). I’ve been successfully using this approach for 2 years. Happy testing rawhide Eclipse and other apps!