3.4. Unpacking a Debian source package without dpkg-source

dpkg-source -x is the recommended way to unpack a Debian source package. However, if it is not available it is possible to unpack a Debian source archive as follows:

  1. Untar the tarfile, which will create a .orig directory.

  2. Rename the .orig directory to package-version.

  3. Create the subdirectory debian at the top of the source tree.

  4. Apply the diff using patch -p0.

  5. Untar the tarfile again if you want a copy of the original source code alongside the Debian version.

It is not possible to generate a valid Debian source archive without using dpkg-source. In particular, attempting to use diff directly to generate the .diff.gz file will not work.

3.4.1. Restrictions on objects in source packages

The source package may not contain any hard links, 2 3 device special files, sockets or setuid or setgid files. 4

The source packaging tools manage the changes between the original and Debian source using diff and patch. Turning the original source tree as included in the .orig.tar.gz into the Debian package source must not involve any changes which cannot be handled by these tools. Problematic changes which cause dpkg-source to halt with an error when building the source package are:

  • Adding or removing symbolic links, sockets or pipes.

  • Changing the targets of symbolic links.

  • Creating directories, other than debian.

  • Changes to the contents of binary files.

Changes which cause dpkg-source to print a warning but continue anyway are:

  • Removing files, directories or symlinks. 5

  • Changed text files which are missing the usual final newline (either in the original or the modified source tree).

Changes which are not represented, but which are not detected by dpkg-source, are:

  • Changing the permissions of files (other than debian/rules) and directories.

The debian directory and debian/rules are handled specially by dpkg-source - before applying the changes it will create the debian directory, and afterwards it will make debian/rules world-executable.

1

This is so that the control file which is produced has the right permissions

2

This is not currently detected when building source packages, but only when extracting them.

3

Hard links may be permitted at some point in the future, but would require a fair amount of work.

4

Setgid directories are allowed.

5

Renaming a file is not treated specially - it is seen as the removal of the old file (which generates a warning, but is otherwise ignored), and the creation of the new one.