Friday, March 06, 2009

Ubuntu and offline software installation

I often find myself working with systems that are not connected to the internet. Many of these systems are running Ubuntu and I find myself wishing I had installed a particular package after the disconnect has occurred. Since network access is not an option, I was looking for an easy approach to identifying all dependencies for a particular package, downloading them and burning them to a CD for offline installation. It turns out that this is not as easy as one might like.

The first problem is package dependencies can be recursive. If A requires B and B requires C, then a recursive dependency search is required. Software installation apps such as apt-get and aptitude are adept at resolving these dependencies, but it is not helpful to me since the target system is offline. I took a look at http://packages.ubuntu.com and indeed, the package descriptions do offer dependency identification based upon distribution version as well as architecture.

I went about developing a script that, given a package name, an architecture, and a distribution version (i.e. hardy), gets a list of all first-order dependencies. From there, it pulls in the dependencies recursively until a complete list has been developed. Given this list of dependencies, I can extract a download URL for the package of interest as well as all dependencies.

Unfortunately, there is a significant problem with this approach. First, most packages have dependencies such as libc and glibc that are common to even a minimal Ubuntu install. In some cases, these common default packages can inflate the dependency list substantially. Since my offline system already has these packages, I would like to avoid tracking them if possible.

To avoid this problem, I modified the script to only list package dependencies from the "Universe" repository. Since it is easy to acquire a DVD containing most packages from the "Main" repository, this should allow the script to only identify packages that would not likely be in a base install without burning the entire Universe repo to media.

In any case, the script is located here: http://github.com/rmjokers/helpful-scripts/blob/1085f5419bea93df0ca06cdbfffb6fa202c3ed0d/uupd.py

It is a work in progress, but serves its purpose for me at the moment :)

Update: After a few use cases, I have decided to remove the Universe-only dependency resolution. It does not identify packages from Main that are not in the default install media, which are required for offline installs.

New version here: http://github.com/rmjokers/helpful-scripts/blob/7e389a83e469e06f57d72b0f085a70b4c8955bef/updr.py