Stable order for inputs
If building your software requires processing several inputs at once, make sure the order is stable across builds.
A typical example is creating an archive from the content of a directory. Most filesystems do not guarantee that listing files in a directory will always result in the same order.
Makefile will result in unreproducible
a) List all inputs explicitly and ensure they will be processed in that order.
b) Sort inputs:
Watch out for locale-related issues
When sorting inputs, one must ensure that the sorting order is not affected by the system locale settings. Some locales will not distinguish between uppercase and lowercase characters.
tar will by default use the filesystem order when
A solution is to use
sort but the following might still
have differences when run under different locales:
The locale used to sort files must be specified to avoid any surprises:
This might not be the only change required for Tar and other archive formats as they usually embed more metadata problems.
Achieve deterministic builds
- Deterministic build systems
- Volatile inputs can disappear
- Stable order for inputs
- Value initialization
- Version information
- Archive metadata
- Stable order for outputs
- Build path
- System images
Define a build environment
- What's in a build environment?
- Recording the build environment
- Definition strategies
- Proprietary operating systems
Distribute the environment
Follow us on Twitter @ReproBuilds & Reddit and please consider making a donation. Content licensed under CC BY-SA 4.0, style licensed under MIT. Templates and styles based on the Tor Styleguide. Logos and trademarks belong to their respective owners. Patches welcome via our Git repository (instructions) or via our mailing list.