Archive for August, 2012

Updating selected debian/ubuntu repositories

Posted in Uncategorized on August 6, 2012 by voline

I’ve been dealing with the pains of a slow connection for sometime now and one of the many annoyances is trying to update a single repository (in my case a launchpad ppa).  There are over 50 repositories that I subscribe to, which isn’t a problem so much, since most of them are updated infrequently and have only a few packages in them.  But since the official repos are large (like over 4Mb each) and updated frequently, I almost alway need to update them.  Even though downloading the official and unofficial repos happen in parallel, getting the official ones consume a significant percent of my bandwidth.  Also, I want to keep the previous repos not being updated (like the official ones).

After a little googling, I found others trying to solve this problem.  But the answers weren’t really satisfactory.  The simplest solution was to use an infrequently updated mirror.  While definitely something that I wanted to do, I still don’t want to be forced to update when this mirror gets updated, even if its once every two or three weeks.

One suggested ubuntu repository management tool to deselect undesired repos and then running update.  But this is a pain with over 50 repos, where most I don’t want to update.  Also by default unselected repos are deleted.  Since most 3rd party repos have dependencies on packages in the official repos, we don’t want to have the official repos removed.  The latter behavior is controlled by an apt configure option, but I like that behavior in general (when I have a fast connection).

The best solution I saw overrode config options of apt to have it use a file with the desired repo lines.  The original answer didn’t include using the options ‘-o APT::Get::List-Cleanup="0"‘ so that existing repos wouldn’t get removed.  Still this solution didn’t provide for multiple files of repo lines or specifying repos on the command line.

Still I wanted a general tool that could be given a series of files with repo lines and even have repo lines specified on the command line.  Well that and I needed an excuse to see if I could do what I wanted to with python-apt, the python binding to libapt-pkg.  So here’s what I came up with, and remember that python-apt must be installed for this to run properly:

Its slightly annoying that there doesn’t seem to be a way to add repos to a SourceList object directly (libapt-pkg seems not to support it either. So I have to write a temp file with all the repo lines in it.