Install multiple version of the same package and avoid filesystem conflicts

One common problem with installing out-of-distro packages is that you can’t really be sure they won’t mess with your existing system. Most common problems include having them replace existing files or add plugins that you don’t really want or that will end up crashing other applications.

There’s also the case where you may want to get the all new and shiny version of a software but still keep the old version around as some other users may prefer it or other software may depend on it. The current way of doing that is by spending quite a bit of time packaging the version to avoid any filesystem conflicts, this works but is usually quite painful to do.

So a few weeks ago I quickly hacked together a debhelper script called dh_ubuntuarb that runs at the end of the package build process and moves all the content to /opt/<package name> except for .desktop entries that are renamed to be arb-<package name>-<original name> and altered to run using “arb-wrapper”.

arb-wrapper uses an overlay fuse filesystem to create a view where the content of the package is stacked on top your root filesystem, it then uses fakechroot to make the app believe it’s running in /.

The software and the user shouldn’t notice any difference and doing that solves the whole file system conflicts and allows you to run as many version of the package as you want (it just needs to have a different name). This is particularly handy for automated packaging where you don’t want to spend too much time reviewing the packages and for cases where you want to run multiple version of the same package.

This code is very much proof of concept and might be extended and uploaded to the archive for Ubuntu 12.04. For now it can be tested in a PPA:

Below is an example using “lightyears” from the arb-testing PPA:
# Build lightyear with dh_ubuntuarb and installed it on my system
# then created an empty /tmp/test directory
stgraber@castiana:~$ ls /tmp/test
stgraber@castiana:~$ which lightyears

# Now starting the overlay of my / and /opt/
stgraber@castiana:~$ arb-wrapper lightyears bash

# Checking that lightyears is indeed accessible now
stgraber@castiana:/$ which lightyears

# Creating some data
stgraber@castiana:/$ touch /tmp/test/me

# Exiting the environment
stgraber@castiana:/$ exit

# And the file is still there
stgraber@castiana:~$ ls /tmp/test/me

Installing the “lightyears” package from that PPA will add a desktop entry called arb-lightyears_lightyears.desktop in /usr/share/applications and that’s the only change that will happen outside of /opt/ This software will appear in your menu as usual and when you click on it will use the arb-wrapper to start just as you’d expect it to.

I’m very much interested in hearing ideas of possible use cases for that kind of things in Ubuntu and hope to be able to discuss it more in Orlando at the next UDS.
I think we should be able to get some pretty exciting things going using that kind of tools and containers like arkose provides.

UPDATE: The “arb” in the script names stands for the Ubuntu App Review Board which was the initial reason for doing that work as an easy way of getting a package to match our packaging requirements.

About Stéphane Graber

Project leader of Linux Containers, Linux hacker, Ubuntu core developer, conference organizer and speaker.
This entry was posted in Canonical voices, Planet Ubuntu. Bookmark the permalink.

3 Responses to Install multiple version of the same package and avoid filesystem conflicts

  1. Ikem says:

    I like to be able to mount a *.deb into the filesystem.

    No installation, just mounting. 😛

  2. Ikem says:

    My wish is installing a *.deb by mounting a *.deb.

    1. You can sort-of do it with:
      bstgraber@castiana:~/test$ dpkg -x news_0.4.6-0extras10.10.1_i386.deb news
      stgraber@castiana:~/test$ arb-wrapper ../../home/stgraber/test/news/ bash
      stgraber@castiana:/$ ls /usr/share/applications/news.desktop
      stgraber@castiana:/$ exit

      This basically unpacks the .deb, then use the arb-wrapper I described in my post to mount it using fuse and in this case start a shell from within that fake environment.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.