Skip to content

ENT-14061: Make the source and package tarballs reproducible#3166

Open
larsewi wants to merge 1 commit into
cfengine:masterfrom
larsewi:reproducible-tar-package
Open

ENT-14061: Make the source and package tarballs reproducible#3166
larsewi wants to merge 1 commit into
cfengine:masterfrom
larsewi:reproducible-tar-package

Conversation

@larsewi
Copy link
Copy Markdown
Contributor

@larsewi larsewi commented May 28, 2026

This makes both the make dist source tarball and the make tar-package package tarball reproducible:

  • Add --sort=name to the exported TAR_OPTIONS so $(am__tar) emits members in a stable order for both recipes.
  • In dist-hook, normalize directory permissions to 755 and, when SOURCE_DATE_EPOCH is set, clamp every mtime to it.
  • In tar-package, clamp staged file mtimes to SOURCE_DATE_EPOCH and pass -n to gzip so the gzip header carries no timestamp.

Ticket: ENT-14061

@larsewi larsewi added the cherry-pick? Fixes which may need to be cherry-picked to LTS branches label May 28, 2026
@cfengine cfengine deleted a comment from cf-bottom May 28, 2026
@larsewi larsewi force-pushed the reproducible-tar-package branch from a549186 to 6437978 Compare May 29, 2026 09:50
@larsewi larsewi changed the title ENT-14061: Make tar-package reproducible via SOURCE_DATE_EPOCH ENT-14061: Make the source and package tarballs reproducible May 29, 2026
@cfengine cfengine deleted a comment from cf-bottom May 29, 2026
@cfengine cfengine deleted a comment from cf-bottom May 29, 2026
@cfengine cfengine deleted a comment from cf-bottom May 29, 2026
@cfengine cfengine deleted a comment from cf-bottom Jun 1, 2026
@larsewi larsewi force-pushed the reproducible-tar-package branch 2 times, most recently from ca2bd45 to 5dbc2fb Compare June 1, 2026 12:00
Two builds of the same source tree now produce byte-identical
tarballs, following GNU tar's reproducibility guidance:

* Select tar-pax in configure.ac so $(am__tar) emits --format=posix,
  giving stable, version-independent header encoding for both
  "make dist" and "make tar-package".
* Expand the exported TAR_OPTIONS: --sort=name for stable member
  order, --numeric-owner / --owner=0 / --group=0 to drop buildslave
  identity, --mode=go+u,go-w for deterministic permissions, and the
  --pax-option flags to keep tar's PID out of header names and omit
  atime/ctime (leaving the archive in the ustar subset).
* In dist-hook, normalize directory permissions to 755 and, when
  SOURCE_DATE_EPOCH is set, clamp every mtime to it.
* In tar-package, clamp staged file mtimes to SOURCE_DATE_EPOCH and
  pass -n to gzip so the gzip header carries no timestamp.

Ticket: ENT-14061
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
@larsewi larsewi force-pushed the reproducible-tar-package branch from 5dbc2fb to 77c11ba Compare June 1, 2026 13:30
@cfengine cfengine deleted a comment from cf-bottom Jun 1, 2026
@cfengine cfengine deleted a comment from cf-bottom Jun 2, 2026
@cf-bottom
Copy link
Copy Markdown

Thank you for submitting a PR! Maybe @nickanderson can review this?

@larsewi
Copy link
Copy Markdown
Contributor Author

larsewi commented Jun 2, 2026

@cf-bottom Jenkins please :)

@cf-bottom
Copy link
Copy Markdown

Comment thread Makefile.am
TAR_OPTIONS = --owner=0 --group=0
# Normalize tar header fields so two builds of the same source tree produce a
# byte-identical tarball, following the GNU tar reproducibility guidance:
# https://www.gnu.org/software/tar/manual/html_section/Reproducibility.html
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This page also mentions using the C locale, did you ensure we set that?

Comment thread configure.ac
AC_CANONICAL_TARGET

_AM_SET_OPTION([tar-ustar])
_AM_SET_OPTION([tar-pax])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't seem clear here why to use tar-pax option. Maybe a comment as to "why" here and I see a longer explanation of options later.

Comment thread Makefile.am
Comment on lines +53 to +56
find . -exec touch -d @$$SOURCE_DATE_EPOCH {} + ; \
fi && \
tardir=. && $(am__tar) | \
GZIP=$(GZIP_ENV) gzip -c \
GZIP=$(GZIP_ENV) gzip -nc \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would seem that long options or comments about what the short options do would be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-pick? Fixes which may need to be cherry-picked to LTS branches

Development

Successfully merging this pull request may close these issues.

4 participants