Source for a apt package can be obtained with the command:

apt-get source foo

This produces a directory with four entries in it: a directory of source and three files, foo*****.dsc, foo*****.tar.gz and foo*****.diff.gz.

Assume that the directory of source is corrupted, can these files be used to recreate it? ( As I assume it can. )


1 Answer 1


To re-create the source directory, delete it and run

dpkg-source -x foo...dsc

This will extract everything using the .dsc and the two tarballs (or the tarball and patch as in your example).

  • Which is a thin wrapper around extracting the tar and applying the diff, which can be done manually if necessary.
    – bahamat
    Apr 6, 2015 at 19:03
  • 1
    Indeed, for old-style packages with a .diff.gz. But other packages can be more complex to extract manually (take a look at libreoffice for example), and dpkg-source handles any Debian source package you can find. Apr 6, 2015 at 21:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .