Andrew Stacey


About
Andrew Stacey
Information about my research, teaching, and other interests.

By: Andrew Stacey
Contact details


Andrew Stacey


blosxom icon


Wed, 6th Dec 2006 (HowDidIDoThat :: Ubuntu :: Edgy)

Updating Ubuntu Offline

I have two machines running Ubuntu. One runs Edgy but is not connected to the internet. The other runs Dapper and has a fast connection. So to keep the Edgy one up to date I want to download the software on the Dapper machine and transfer it; but I want this to be as easy as possible so I want to use the apt system as much as I can. The following does not depend on the fact that the machine connected to the internet runs Dapper, though it was useful for figuring out some of the information that I needed. It should be simple to modify this process for another machine.


There is a new option in the Synaptic Package Manager that makes the day-to-day part of this very simple. Under the File menu are two options:

  • Generate package download script
  • Add downloaded packages
So in gory detail, here's what I do:
  • Launch the Synaptic Package Manger
  • Select all the packages that I want to install
  • Instead of clicking Apply I use the Generate package download script option and save the script somewhere nice
  • Transfer that script to the Dapper machine
  • Run it, possibly with some modification first (see below)
  • Take the downloaded debs back to the Edgy machine
  • Launch the Synaptic Package Manager
  • Click the Add downloaded packages option and select the directory where I've just put the downloaded debs
  • Make a cup of strong tea
Of course, nothing is ever quite as simple as that ...

The problem with the above solution is telling the Synaptic Package Manager about the packages in the first place, as well as telling it about updates and upgrades. This information is stored on the internet and so is unavailable to the Edgy machine. As yet, the Synaptic Package Manager doesn't have an offline option to update itself so this has to be done by hand. Fortunately, it's fairly straightforward.

There are probably several ways of doing this. My approach is based on the fact that I don't understand how the various programs that maintain the system on my machines fit together and interact so rather than trying to mess about with them I would rather just feed them misleading information and let them deal with it how they like. So what I do is set up a mini-mirror of the Ubuntu repositories on my Edgy machine and tell the Synaptic Package Manager to get its information from that. I then keep this mini-mirror up to date via the Dapper machine and everything runs as it should. It does mean the addition of one step in the above process, but it is an easy one. By mini-mirror what I mean is that I mirror the information about the packages in the repositories, but not the packages themselves.

The first thing to do is decide which repositories to use. A Ubuntu machine connected to the internet will use several mirrors; the policy seems to be that potentially high risk situations require the main mirrors but other stuff should distribute the load and use a regional mirror. The risks are considerably lessened for a machine offline and so it is possible to use just one mirror. This also simplifies matters a little. I use the following repositories:

  • Binaries: main restricted universe multiverse
  • Sources: main restricted
I'm on a standard intel pc so my architecture is i386 and I live in the UK so my mirror is gb.archive.ubuntu.com. The list of files that I need to download can be found in edgy-resources. I download all of this information by running:

wget -xi edgy-resources

This creates a directory gb.archive.ubuntu.com.

The next step is to transfer this to the Edgy machine. I put it in /usr/local/share/ubuntu but anywhere sensible would do.

The final step is to tell the Synaptic Package Manager where to get its information about packages. This is done by editing the file /etc/apt/sources.list. My version of it can be found in sources.list. It should be obvious how to modify it if necessary.

To keep the Synaptic Package Manager up to date, all that is needed to do is to keep hold of the file edgy_resources (or whatever you've called it) and run wget -xNi edgy_resources from time to time, then transfer the downloaded stuff to the Edgy machine. The N option means that wget will only download newer files. It should be fairly obvious how to adapt the above to add or delete a repository.

One extra step is needed when downloading the actual packages. The script generated by the Synaptic Package Manager will look for the packages in /usr/local/share/ubuntu/.... Thus this script needs to be altered to look in the right places. With my set-up, the following perl script does this just fine.

perl -i.orig -pe 's%file:///usr/local/share/ubuntu/%http://%;' edgy_downloads

There is a potential problem in this method if the packages on the mirror get updated between downloading the information and downloading the packages. However, the mirrors appear to keep a couple of older versions so there should still be a package to download. If not, wget will complain and you can manually download that package.

Resources

[Full link]
Last modified on:
Wed, 6th Dec 2006