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
support SOURCE_DATE_EPOCH to make gem spec reproducible #2278
Conversation
I'm not familiar with SOURCE_DATE_EPOCH environment variable. Is it major on the linux distribution like debian, fedora, archlinux? |
Yes, actually Debian folks invented it. Every bigger distro uses it in its (reproducible) build tools. Arch Linux will properly support it in makepkg with the upcoming release of pacman.
S_D_E became a defacto standard to deal with dates in build artifacts, adopted by tons of programs like gcc itself.
|
Does this actually make the generated tar files byte for byte equal? If that’s the goal, should we add test coverage for that? |
That could be a good general goal. For this PR I only targeted the generated gemspec stuff as that's what made the packages we ship in arch Linux unreproducible. We don't ship any tarballs directly just extract the final gem into a DESTDIR like folder to package it with the distro specific tools.
If you want to investigate further also on tarballs stuff, you should give "diffoscope" a shot it helps find what makes an artifact not reproducible bit by bit by analyzing its content.
|
@hsbt @segiddins So i took a look at the TarHeader and TarWriter stuff and I think its not hard to make it fully reproducible. |
lib/rubygems/specification.rb
Outdated
# The date this gem was created. Lazily defaults to the current UTC date. | ||
# The date this gem was created. Lazily defaults to the current UTC date or if | ||
# SOURCE_DATE_EPOCH is set as an environment variable (unix timestamp) to | ||
# support reproducible builds. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anthraxx Thoughts on changing this to something like the following?
# The date this gem was created.
#
# If SOURCE_DATE_EPOCH is set as an environment variable, use that to support
# reproducible builds; otherwise, default to the current UTC date.
#
# Details on SOURCE_DATE_EPOCH:
# https://reproducible-builds.org/specs/source-date-epoch/
Optionally respect the SOURCE_DATE_EPOCH environment variable to be used instead of TODAY to allow reproducible builds of created gem specs. In case none is specified, fall back to the current time.
@anthraxx Thanks for your explanation. I prefer your idea. |
👍🏻 |
@bundlerbot r+ thanks for the PR, @anthraxx! |
📌 Commit 9fc4ca4 has been approved by |
support SOURCE_DATE_EPOCH to make gem spec reproducible Optionally respect the SOURCE_DATE_EPOCH environment variable to be used instead of TODAY to allow reproducible builds of created gem specs. In case none is specified, fall back to the current time. ______________ The problem is that using TODAY will change during time which makes created artifacts not reproducible (bit by bit identical). Spec: https://reproducible-builds.org/specs/source-date-epoch/ Buy-in: https://reproducible-builds.org/docs/buy-in/ # Tasks: - [x] Describe the problem / feature - [x] Write tests - [x] Write code to solve the problem - [x] Get code review from coworkers / friends I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md).
💔 Test failed - status-travis |
^ tm that doesn't look like i broke it 😼 |
@bundlerbot retry ¯\(ツ)/¯ |
support SOURCE_DATE_EPOCH to make gem spec reproducible Optionally respect the SOURCE_DATE_EPOCH environment variable to be used instead of TODAY to allow reproducible builds of created gem specs. In case none is specified, fall back to the current time. ______________ The problem is that using TODAY will change during time which makes created artifacts not reproducible (bit by bit identical). Spec: https://reproducible-builds.org/specs/source-date-epoch/ Buy-in: https://reproducible-builds.org/docs/buy-in/ # Tasks: - [x] Describe the problem / feature - [x] Write tests - [x] Write code to solve the problem - [x] Get code review from coworkers / friends I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md).
support SOURCE_DATE_EPOCH to make gem spec reproducible Optionally respect the SOURCE_DATE_EPOCH environment variable to be used instead of TODAY to allow reproducible builds of created gem specs. In case none is specified, fall back to the current time. ______________ The problem is that using TODAY will change during time which makes created artifacts not reproducible (bit by bit identical). Spec: https://reproducible-builds.org/specs/source-date-epoch/ Buy-in: https://reproducible-builds.org/docs/buy-in/ # Tasks: - [x] Describe the problem / feature - [x] Write tests - [x] Write code to solve the problem - [x] Get code review from coworkers / friends I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md).
☀️ Test successful - status-travis |
…hsbt support SOURCE_DATE_EPOCH to make gem tar reproducible Optionally respect the SOURCE_DATE_EPOCH environment variable to be used instead of Time.now to allow reproducible builds of created gem tarballs. In case none is specified, fall back to the current time. # Description: The problem is that using Time.now will change during time which makes created gem tarballs not reproducible (bit by bit identical). This is related to making the .gemspec file's itself reproducible: #2278 Spec: https://reproducible-builds.org/specs/source-date-epoch/ Buy-in: https://reproducible-builds.org/docs/buy-in/ ______________ # Tasks: - [x] Describe the problem / feature - [x] Write tests - [x] Write code to solve the problem - [x] Get code review from coworkers / friends I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md).
Optionally respect the SOURCE_DATE_EPOCH environment variable to be used
instead of TODAY to allow reproducible builds of created gem specs.
In case none is specified, fall back to the current time.
The problem is that using TODAY will change during time which makes created artifacts not reproducible (bit by bit identical).
Spec:
https://reproducible-builds.org/specs/source-date-epoch/
Buy-in:
https://reproducible-builds.org/docs/buy-in/
Tasks:
I will abide by the code of conduct.