Escape Dependency Hell: Automatically create portable Linux software using CDE

552

Have you ever been in a situation where you had a Linux program on your machine that you wanted to run on someone else’s machine?

For example:

  • You are hacking on a research prototype and want your colleagues to be able to test out your prototype software on their machines.
  • You are a scientist running computational experiments and want your colleagues to be able to reproduce and tweak those experiments on their own machines (embodying the ideals of reproducible research).
  • You want to quickly deploy your program to a compute cluster (where you don’t have root access) or to a cloud computing service.
  • You have a useful utility on your desktop machine that you want to run on a production server (e.g., a network diagnostics tool), but you don’t have permission to install anything on that server.
  • You want to run a specific program on one of your older machines, but that machine doesn’t have the libraries required to properly install or run it.

In this post, I’m going to show you how to use a new tool called CDE¬†to quickly accomplish this task of migrating a program from one machine to another without any installation or dependency hell.

CDE automatically packages up the Code, Data, and Environment involved in running any set of Linux commands, so that they can execute identically on another machine without any installation or configuration. A command can range from a simple command-line utility to a sophisticated GUI application with 3D graphics. The only requirement is that the other machine have the same hardware architecture (e.g., x86) and major kernel version (e.g., 2.6.X) as yours.

CDE allows you to easily run programs on other machines without needing to create a one-click installer or making people suffer from the dependency hell that inevitably occurs when attempting to install libraries.

How to Use CDE

First, download CDE and make sure that the cde executable is in your $PATH. Now it only takes three steps to use CDE:

Step 1: Prepend any Linux command with cde, and CDE will execute that command, monitor its actions (using ptrace), and copy all files it accesses (e.g., executables, scripts, shared libraries, plug-ins, configuration/data files) into a self-contained package named cde-package/ within your current directory.

Step 2: Transport the cde-package/ sub-directory (which I call a ‘CDE package’) to another machine in whatever way you like (e.g., USB flash drive, online file upload).

Step 3: Run that same command from within the CDE package, without having to first install anything on the target machine.

That’s all you need to do! In sum, if you can run a set of Linux commands on your machine (no matter how complicated), then CDE enables others to run it on theirs.

Example Use Case: Google Earth

Let’s say that you love using the Google Earth 3D map program (version 5) on your 2008 Ubuntu 8.04 LTS machine (2.6.24 kernel). You tell your friend all about how cool it is, so she decides to download and install it on her 2006 Knoppix machine (2.6.17 kernel). However, when she tries to run the googleearth executable, she gets a ton of error messages like the following:

./googleearth-bin: /lib/tls/libc.so.6: version `GLIBC_2.4' not found (required by ./libgoogleearth_free.so)
./googleearth-bin: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by ./libgoogleearth_free.so)
./googleearth-bin: /lib/tls/libc.so.6: version `GLIBC_2.4' not found (required by ./libQtGui.so.4)
./googleearth-bin: /lib/tls/libc.so.6: version `GLIBC_2.4' not found (required by ./libIGCore.so)
./googleearth-bin: /lib/tls/libc.so.6: version `GLIBC_2.4' not found (required by ./libauth.so)
[...]

Unfortunately, she can’t run Google Earth on her machine since its system libraries are simply too old. It would be too much of a hassle to upgrade her entire system just to be able to run Google Earth.

This sounds like a perfect use case for CDE! Here is how you can use CDE to let your friend run Google Earth on her machine without having to upgrade her system libraries or do any other installation:

Step 1: Run Google Earth with CDE on your own machine by prepending the regular googleearth command with cde:

cde googleearth

CDE will start up a new Google Earth instance and monitor its actions in the background. After the GUI finishes loading up, you can close it, and now you should see a new sub-directory named cde-package/ within your current directory. This sub-directory (the ‘CDE package’) contains all the files needed to run Google Earth on another Linux machine, including the actual executable and all of its dependent shared libraries, scripts, and configuration/data files.

Step 2: Now you can transport the cde-package/ sub-directory to your friend’s machine in whatever way you like (e.g., USB flash drive, online file upload).

Step 3: To run Google Earth on your friend’s machine, first change into the package directory and then simply run the googleearth.cde command, which is a script that CDE generated to wrap around the actual executable:

cd cde-package/
./googleearth.cde

This command should start up a new Google Earth instance, just like it did on your machine! The screenshot below shows Google Earth running from within a CDE package on a 2006 Knoppix LiveCD, without any installation (note that it’s impossible to run Google Earth natively on that distro):

Let’s recap what you just accomplished with CDE: You were able to let your friend run Google Earth (a highly-complex GUI application with 3D graphics) on a machine whose operating system was too old to properly run it in the first place! Without CDE, it would have been impossible for her to run Google Earth without first upgrading her entire operating system.

Conclusion

I only used Google Earth as an illustrative example here since it’s a well-known consumer application. In an enterprise setting, “your friend’s machine” might actually be a live production server running an older distro. You might have some diagnostic utilities on your desktop that you want to run on the server, but you don’t want to risk messing up the server by installing anything as root (or the sysadmin won’t even let you have root access).

This post is merely a preview of what CDE can do for you. Please visit the CDE website for more detailed instructions and additional use cases. Happy packing!