Skip to content

Make package archives reproducible with deterministic timestamps and entry ordering - #4885

Draft
mosuem wants to merge 1 commit into
use-dart-build-clifrom
reproducible-package-archives
Draft

Make package archives reproducible with deterministic timestamps and entry ordering#4885
mosuem wants to merge 1 commit into
use-dart-build-clifrom
reproducible-package-archives

Conversation

@mosuem

@mosuem mosuem commented Aug 24, 2026

Copy link
Copy Markdown
Member

Summary

Makes dart pub publish --to-archive bit-for-bit deterministic and reproducible by:

  1. Normalizing TAR entry timestamps (modified) to Unix Epoch 0 (DateTime.utc(1970)) or SOURCE_DATE_EPOCH if specified.
  2. Sorting archive entries deterministically by normalized relative path.
  3. Normalizing TAR directory and file permissions/modes.
  4. Adding comprehensive multi-OS unit tests verifying reproducible archives regardless of file mtime and directory iteration order.

@mosuem
mosuem force-pushed the reproducible-package-archives branch 16 times, most recently from 46faa47 to af477f7 Compare August 25, 2026 09:53
@mosuem
mosuem changed the base branch from master to use-dart-build-cli August 25, 2026 10:48
@mosuem
mosuem force-pushed the reproducible-package-archives branch from af477f7 to 215f013 Compare August 25, 2026 15:44
@mosuem
mosuem force-pushed the reproducible-package-archives branch from 215f013 to 700a139 Compare August 25, 2026 16:11
@mosuem
mosuem force-pushed the reproducible-package-archives branch from 700a139 to 51fbcee Compare August 26, 2026 11:06
Comment thread lib/src/io.dart Outdated
ByteStream createTarGz(
List<String> contents, {
required String baseDir,
bool reproducible = false,

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.

Perhaps we just always do this?

Comment thread lib/src/io.dart
return ByteStream(stream);
}

/// Normalizes the GZIP header (RFC 1952) so that `.tar.gz` archives are

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.

I kind of remember we have something in our test setup that overwrites these headers. Perhaps that can be removed in this change?

@mosuem
mosuem force-pushed the reproducible-package-archives branch 3 times, most recently from a980816 to 72fd773 Compare August 27, 2026 09:12
@mosuem
mosuem force-pushed the reproducible-package-archives branch from 72fd773 to 783fbfe Compare August 27, 2026 12:06
@mosuem
mosuem force-pushed the reproducible-package-archives branch from 783fbfe to e8221b7 Compare August 27, 2026 12:21
@mosuem
mosuem force-pushed the reproducible-package-archives branch from e8221b7 to a19a61c Compare August 27, 2026 12:36
Comment thread lib/src/io.dart
);
}

DateTime _archiveEpoch() {

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.

I don't think we need this to be configurable via environment. Can't we always just use epoch?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants