Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use SOURCE_DATE_EPOCH for zip, tar, xz, gzip, rpm, msi #1547

Merged
merged 2 commits into from
Jul 24, 2023

Conversation

stevedlawrence
Copy link
Contributor

SOURCE_DATE_EPOCH is a standardized environment variable that can be set to create reproducbile builds:

https://reproducible-builds.org/docs/source-date-epoch/

If the SOURCE_DATE_EPOCH environment variable is defined, its value is used during the creation of zip, tar, gzip, xz, rpm, and msi files in places where timestamp information is embedded in the resulting file.

To support this capability, a new sourceDateEpoch file utility is added which executes the touch command to set the mtime of the provided file/directory and all children. This utility is called on all source files for the listed packages.

For zip, this also adds the -o option to native zip, and calls setTime() for the non-native zip.

For rpm, this also sets the %use_source_date_epoch_as_buildtime and %clamp_mtime_to_source_date_epoch tunables to 1 to ensure the build time and timestamps embedded in the RPM are set to the epoch.

For msi, the SOURCE_DATE_EPOCH variable is also used to generate reproducible name-based UUIDs, using a combination of an identifier and the epoch value. Note that this does not change the "Product" GUID or the build time that is embedded in the MSI. There does not seem to be a way to change these, so MSI builds are not 100% reproducible. However, with these changes the output of tools like msidiff is much smaller and easier to confirm similar builds.

If SOURCE_DATE_EPOCH is not set then the current behavior is used. Archives and rpms use timestamps of when the files are modified/created, and MSI uses random GUIDs.

@lightbend-cla-validator

Hi @stevedlawrence,

Thank you for your contribution! We really value the time you've taken to put this together.

We see that you have signed the Lightbend Contributors License Agreement before, however, the CLA has changed since you last signed it.
Please review the new CLA and sign it before we proceed with reviewing this pull request:

https://www.lightbend.com/contribute/cla

SOURCE_DATE_EPOCH is a standardized environment variable that can be set
to create reproducbile builds:

  https://reproducible-builds.org/docs/source-date-epoch/

If the SOURCE_DATE_EPOCH environment variable is defined, its value is
used during the creation of zip, tar, gzip, xz, rpm, and msi files in
places where timestamp information is embedded in the resulting file.

To support this capability, a new sourceDateEpoch file utility is added
which executes the touch command to set the mtime of the provided
file/directory and all children. This utility is called on all source
files for the listed packages.

For zip, this also adds the -o option to native zip, and calls setTime()
for the non-native zip.

For rpm, this also sets the %use_source_date_epoch_as_buildtime and
%clamp_mtime_to_source_date_epoch tunables to 1 to ensure the build time
and timestamps embedded in the RPM are set to the epoch.

For msi, the SOURCE_DATE_EPOCH variable is also used to generate
reproducible name-based UUIDs, using a combination of an identifier and
the epoch value. Note that this does not change the "Product" GUID or
the build time that is embedded in the MSI. There does not seem to be a
way to change these, so MSI builds are not 100% reproducible. However,
with these changes the output of tools like msidiff is much smaller and
easier to confirm similar builds.

If SOURCE_DATE_EPOCH is not set then the current behavior is used.
Archives and rpms use timestamps of when the files are modified/created,
and MSI uses random GUIDs.
Copy link
Contributor

@muuki88 muuki88 left a comment

Choose a reason for hiding this comment

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

Thanks a lot @stevedlawrence for this contribution. This is super useful.

@muuki88 muuki88 merged commit 62414fe into sbt:master Jul 24, 2023
@stevedlawrence stevedlawrence deleted the source_date_epoch branch July 26, 2023 12:13
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.

3 participants