Downloading Debian source packages easily

Posted by Steve on Tue 6 Mar 2007 at 09:30

To download the source of a package contained inside a Debian repository, whether official, or unofficial, is a straightforward operation using the apt-get support for "source lists". However downloading a package source which is stored upon a remote webserver can be a little fiddly - requiring multiple files to be fetched before the source can be unpacked. Using the dget tool this can be easily automated.

As we've discussed previously a Debian package consists of a collection of files, such as:

xen-shell_1.0-1.diff.gz
xen-shell_1.0-1.dsc
xen-shell_1.0.orig.tar.gz

Here we have, in turn, three files:

  1. The "diff" file, which contains differences between the original software release and the final Debian package.
  2. The "dsc" file, which contains checksum information and other details.
  3. The "orig" file, which is supposed to be the pristine release as downloaded from the project's homepage/site.

If these files were not available to you in a repository from which apt-get could locate them then you would need to download each file in turn - then unpack them manually.

Instead of doing this you can make use of the dget tool which is included within the devscripts package.

The dget command can also unpack the downloaded files, automatically invoking the dpkg-source command.

If you're missing the devscripts package first install it:

apt-get install devscripts

Once installed you can download a source package via a command such as:

dget -x http://example.com/some/path/to/foo_1.0-1.dsc

This will first download the dsc file, then in turn any files referenced within it. Finally, because we specified the -x flag, the resultant package will be extracted, or unpacked.

The dget command is a real time-saver compared to copying and pasting links from a browser window and downloading each one in turn.


This article can be found online at the Debian Administration website at the following bookmarkable URL:

This article is copyright 2007 Steve - please ask for permission to republish or translate.