Two builds, one commit#
This fixture clones one commit twice, two seconds apart, and packs each checkout into a tar.gz the way many release scripts do, with a BUILD_INFO file that records the build time and directory (GNU tar 1.35, gzip 1.13, in the golang:1.25 image):
$ sha256sum a.tar.gz b.tar.gz
8fc50909079f4f2f55ba7c938c4f30f47d597fd289832338b61b3771bb26052a a.tar.gz
537ae27c8eaf59e656ba9c626f909a5d373e1543b2290f06fc084f8b2b7018c4 b.tar.gz
$ per-file content hashes (tar member, sha256)
1c1
< 94917fea92e0209271b9f638ef14dcf7a605b64b9854d9d6e8d2d2f66d21507b ./BUILD_INFO
---
> d2a5f4c29e8321bcb173d330ddd4849743a97bcb44da33b7d4f958ded653ee98 ./BUILD_INFO
Every source file has the same hash in both archives. Only the generated file differs. A file-hash list does not show metadata, so run diffoscope next. It unpacks both sides and reports every difference (diffoscope 338, from its official container image):
[…]
│ ├── file list
│ │ @@ -1,7 +1,7 @@
│ │ -drwxr-xr-x 0 root (0) root (0) 0 2026-12-02 07:39:15.000000 ./
│ │ --rw-r--r-- 0 root (0) root (0) 55 2026-12-02 07:39:15.000000 ./BUILD_INFO
[…]
│ │ +drwxr-xr-x 0 root (0) root (0) 0 2026-12-02 07:39:17.000000 ./
│ │ +-rw-r--r-- 0 root (0) root (0) 55 2026-12-02 07:39:17.000000 ./BUILD_INFO
[…]
│ ├── ./BUILD_INFO
│ │ @@ -1 +1 @@
│ │ -built 2026-12-02T07:39:15Z in /tmp/tmp.Rm2JXX2O8L/co-a
│ │ +built 2026-12-02T07:39:17Z in /tmp/tmp.Rm2JXX2O8L/co-b
The archive members carry the checkout time as their modification time, and BUILD_INFO embeds the clock and the build path. None of it comes from the commit. diffoscope
Remove the build's own differences#
The Reproducible Builds project's SOURCE_DATE_EPOCH specification asks build processes to use this variable "for embedded timestamps in place of the 'current' date and time", and says it should be set to the last modification time of the source. SOURCE_DATE_EPOCH Its archive guide gives the tar options: sort names, fix the modification time, normalize owners and drop the extended header times. Archives
SOURCE_DATE_EPOCH=$(git log -1 --format=%ct); export SOURCE_DATE_EPOCH
tar --sort=name --mtime=@"$SOURCE_DATE_EPOCH" --owner=0 --group=0 --numeric-owner \
--pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime -cf - . | gzip -n > app.tar.gz
With that, and BUILD_INFO written from SOURCE_DATE_EPOCH without the path, two fresh builds of the commit matched:
5397a6a5cc0cd592d7844064c95f9ec5d62a41dc91a40bea4c10e65908879d94 c.tar.gz
5397a6a5cc0cd592d7844064c95f9ec5d62a41dc91a40bea4c10e65908879d94 d.tar.gz
Read the diff#
| diffoscope shows | Likely source | Source difference? |
|---|---|---|
| Only timestamps, member order, owners | Archive tool defaults | No |
| A generated file with a date, host or path | The build script | No, unless the file also carries a version you meant to change |
| Compiled files differ, sources equal | Toolchain, flags or a dependency version | No, but an input differed; compare lockfiles and toolchain versions |
| Source files differ | Different commits, a dirty tree, or a generated source file | Yes. Check which commit each build checked out |
Two matching checksums establish that the bytes are equal. They do not establish that the build was correct, only that it is repeatable for these inputs.
Worked example#
This example is fictional. Chen rebuilds the 2.8 release bundle of a Python service to check it and gets a different checksum. diffoscope shows changed modification times on every member and one changed file, site-packages/urllib3/_version.py. The timestamps are the archive's. The changed file names a newer patch release, because Chen's build installed dependencies from the version ranges in requirements.txt while the release job had installed from the lock file. Rebuilt from the lock file, with SOURCE_DATE_EPOCH set as the release job sets it, the checksum matches the release.
To decide which of two artifacts to ship, read promote the tested artifact. For Go's record of the source tree, read Go binary VCS stamps.