Scroll to navigation



reprotest - Build packages and check them for reproducibility.


reprotest --help [<virtual_server_name>]
reprotest [options] auto  <source_file_or_dir> [[more options] --|--] [<virtual_server_args> [<virtual_server_args> ...]]
reprotest [options] <build_command> <artifact> [[more options] --|--] [<virtual_server_args> [<virtual_server_args> ...]]


reprotest builds the same source code twice in different environments, and then checks the binaries produced by each build for differences. If any are found, then diffoscope(1) (or if unavailable then diff(1)) is used to display them in detail for later analysis.

See the COMMAND-LINE EXAMPLES section further below to get you started, as well as more detailed explanations of all the command-line options. The same information is also available in /usr/share/doc/reprotest/README.rst or similar.

positional arguments:

Build command to execute, or "auto" to guess this. In the latter case, the next argument 'artifact' will not be interpreted that way but instead as the source to build, e.g. "." or some other path.
Build artifact to test for reproducibility. May be a shell pattern such as "*.deb *.changes".
Arguments to pass to the virtual_server, the first argument being the name of the server. If this itself contains options (of the form -xxx or --xxx), you should put a "--" between these arguments and reprotest's own options. Default: "null", to run directly in /tmp. Choices: chroot, lxc, lxd, null, qemu, schroot, ssh

optional arguments:

Show this help message and exit. When given an argument, show instead the help message for that virtual server and exit.
--verbosity VERBOSITY
An integer. Control which messages are displayed.
--config-file CONFIG_FILE
File to load configuration from. (Default: .reprotestrc)
--source-root SOURCE_ROOT
Root of the source tree, if not the current working directory.
--store-dir STORE_DIR
Save the artifacts in this directory, which must be empty or non-existent. Otherwise, the artifacts will be deleted and you only see their hashes (if reproducible) or the diff output (if not).
--testbed-pre COMMANDS
Shell commands to run before starting the test bed, in the context of the current system environment. This may be used to e.g. compute information needed by the build, where the computation needs packages you don't want installed in the testbed itself.
--testbed-init COMMANDS
Shell commands to run after starting the test bed, but before applying variations. Used to e.g. install disorderfs in a chroot.
--auto-preset-expr PYTHON_EXPRESSION
This may be used to transform the presets returned by the auto-detection feature. The value should be a python expression that transforms the _ variable, which is of type reprotest.presets.ReprotestPreset. See that class's documentation for ways you can write this expression. Default: _
--variations VARIATIONS
Build variations to test as a comma-separated list (without spaces). Default is to test all available variations: environment, build_path, fileordering, home, kernel, locales, exec_path, time, timezone, umask.
--dont-vary DONT_VARY
Build variations *not* to test as a comma-separated list (without spaces). These take precedence over what you set for "variations". Default is nothing, i.e. test whatever you set for "variations".
--diffoscope-arg DIFFOSCOPE_ARG
Give extra arguments to diffoscope when running it.
Don't run diffoscope; instead run diff(1). Useful if you don't want to install diffoscope and/or just want a quick answer on whether the reproduction was successful or not, without spending time to compute all the detailed differences.
Don't clean the virtual_server if there was an error. Useful for debugging, but WARNING: this is currently not implemented very well and may leave cruft on your system.


The easiest way to run reprotest is via our presets:

# Build the current directory in a null server (/tmp)
$ reprotest auto .
$ reprotest auto . -- null -d # for more verbose output
# Build the given Debian source package in an schroot
# See for instructions on setting that up.
$ reprotest auto reprotest_0.3.3.dsc -- schroot unstable-amd64-sbuild

Currently, we only support this for Debian packages, but are keen on adding more. If we don't have knowledge on how to build your file or directory, you can send a patch to us on adding this intelligence - see the reprotest.presets python module, and adapt the existing logic.

In the meantime, you can use the more advanced CLI to build arbitrary things. This takes two mandatory arguments, the build command to run and the build artifact file/pattern to test after running the build. For example:

$ reprotest 'python3 bdist' 'dist/*.tar.gz'

When using this from a shell:

If the build command has spaces, you will need to quote them, e.g. reprotest "debuild -b -uc -us" [..].

If you want to use several build artifact patterns, or if you want to use shell wildcards as a pattern, you will also need to quote them, e.g. reprotest [..] "*.tar.gz *.tar.xz".

If your build artifacts have spaces in their names, you will need to quote these twice, e.g. '"a file with spaces.gz"' for a single artifact or '"dir 1"/* "dir 2"/*' for multiple patterns.

To get more help for the CLI, including documentation on optional arguments and what they do, run:

$ reprotest --help


You can also run the build inside what is called a "virtual server". This could be a container, a chroot, etc. You run them like this:

$ reprotest 'python3 bdist_wheel' 'dist/*.whl' qemu    /path/to/qemu.img
$ reprotest 'debuild -b -uc -us'           '../*.deb'   schroot unstable-amd64

There are different server types available. See --help for a list of them, which appears near the top, in the "virtual_server_args" part of the "positional arguments" section.

For each virtual server (e.g. "schroot"), you see which extra arguments it supports:

$ reprotest --help schroot

When running builds inside a virtual server, you will probably have to give extra commands, in order to set up your build dependencies inside the virtual server. For example, to take you through what the "Debian directory" preset would look like, if we ran it via the advanced CLI:

# "Debian directory" preset
$ reprotest auto . -- schroot unstable-amd64-sbuild
# In the advanced CLI, this is equivalent to roughly:
$ reprotest \
    --testbed-init 'apt-get -y --no-install-recommends install \
                    util-linux disorderfs 2>/dev/null; \
                    test -c /dev/fuse || mknod -m 666 /dev/fuse c 10 229' \
    'PATH=/sbin:/usr/sbin:$PATH apt-get -y --no-install-recommends build-dep ./; \
     dpkg-buildpackage -uc -us -b' \
    '../*.deb' \
    -- \
    schroot unstable-amd64-sbuild

The --testbed-init argument is needed to set up basic tools, which reprotest needs in order to make the variations in the first place. This should be the same regardless of what package is being built, but might differ depending on what virtual_server is being used.

Next, we have the build_command. For our Debian directory, we install build-dependencies using apt-get, then we run the actual build command itself using dpkg-buildpackage(1).

Then, we have the artifact pattern. For reproducibility, we're only interested in the binary packages.

Finally, we specify that this is to take place in the "schroot" virtual_server with arguments "unstable-amd64-sbuild".

Of course, all of this is a burden to remember, if you must run the same thing many times. So that is why adding new presets for new files would be good.

Here is a more complex example. It tells reprotest to store the build products into ./artifacts to analyse later; and also tweaks the "Debian dsc" preset so that it uses our experimental toolchain.

$ reprotest --store-dir=artifacts \
    --auto-preset-expr '_.prepend.testbed_init("apt-get install -y wget 2>/dev/null; \
        echo deb ./ >> /etc/apt/sources.list; \
        wget -q -O- | apt-key add -; \
        apt-get update; apt-get upgrade -y 2>/dev/null; ")' \
    auto ./bash_4.4-4.0~reproducible1.dsc \
    -- \
    schroot unstable-amd64-sbuild

(Yes, this could be a lot nicer to achieve; we're working on it.)


You can also give options to reprotest via a config file. This is a time-saving measure similar to auto presets; the difference is that these are more suited for local builds that are suited to your personal purposes. (You may use both presets and config files in the same build.)

The config file has one section, basics, and the same options as the CLI, except there's no dont_vary option, and there are build_command and artifact fields. If build_command and/or artifact are set in the config file, reprotest can be run without passing those as command-line arguments. Command-line arguments always override config file options.

Reprotest by default loads ./.reprotestrc, or you can tell it to load another file with the --config-file command line option.

A sample config file is below.

build_command = sdist
artifact = dist/reprotest-0.2.tar.gz
source_root = reprotest/
variations =


The "time" variation uses faketime which sometimes causes weird and hard-to-diagnose problems. In the past, this has included:
  • builds taking an infinite amount of time; though this should be fixed in recent versions of reprotest.
  • builds with implausibly huge differences caused by ./configure scripts producing different results with and without faketime. This still affects bash and probably certain other packages using autotools.

If you see a difference that you really think should not be there, try passing --dont-vary time to reprotest, and/or check our results on which use a different (more reliable) mechanism to vary the system time.

May 2017 reprotest 0.6.2