We have seen variations related to the time of the build, the order of files on the filesystem, the current user, the system hostname, the uname output, (pseudo-)-randomness, and the CPU features or load. Such aspects must not be captured by the build process to make a package reproducible.

Note: for the time being this omits certain variations compared to our test infrastructure, but we're working on it. Specically, these are: domain/host, bash-vs-dash, num_cpus, linux-namespace. If you need to test these, then either wait or use the "older method" below.

If your package is unreproducible (after 2 builds), --auto-build will run further builds with different variations to try to identify which ones are causing the non-determinism.

Look for a fat big “reproducible” banner if test is successful. Otherwise, look for logs and diffoscope output in the logs directory.

First steps to make a package reproducible

Currently a plain sid environment is not enough to build packages reproducibly. An experimental toolchain is available while changes are waiting to be integrated in the main archive.

The first steps needed to make a package build reproducibly depends on the packaging style. With this, the basics should be covered and simple packages should build reproducible. See the next chapter for a discussion of common reproducibility issues and their solutions.

dh

No changes required.

cdbs

No changes required.

Explicit calls to dh_*

Please consider migrating the package to dh.

If the packages is not reproducible, start by adding dh_strip_nondeterminism before dh_compress.

Do It Yourself

Please consider migrating the package to dh.

Usual fixes are:

Make sure that the mtime of the files in binary packages are deterministic. Example patch

Identified problems, and possible solutions

Once applied the basic recommendations, a package might still not build reproducibly.

diffoscope has been written to help one understanding the sources of unreproducibility. It compares two files and output their differences, recursively unpacking archives or using transformation tool to generates meaningful diffs. In the Debian context, it's usually called on the .changes files of two different builds.

What follows is a list of common issues and known solutions. For reference, we keep documentation on old issues that should not happen with the current experimental toolchain.

Other umask related variations

Symlinks in data.tar contain varying file mode

POSIX says that the file mode on symlinks is undefined, so this ends up being system dependent behavior. On Linux the umask is ignored when creating symlinks, but on other systems such as kFreeBSD or Hurd the umask is honored, which can produce varying file modes. This is at least a problem for architecture independent packages which are built on different operating systems.

A way to always get the same file mode for symlinks is to set umask to 0 before creating them, and restore the previous umask afterwards, but this might be unfeasible in general.

Members of control.tar and data.tar have varying mtimes

dpkg-deb will record the mtime of files it packs in control.tar and data.tar. Files generated during the build process will get a different mtime with each build. Best solution is to change their mtime to the date of the latest debian/changelog entry.