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

oci_tarball: set time, user and group to reproducible values for Linux #381

Conversation

gergelyfabian
Copy link
Contributor

@gergelyfabian gergelyfabian commented Oct 2, 2023

Applied suggestion for Linux from:

http://h2.jaguarpaw.co.uk/posts/reproducible-tar/

Left out MacOS and other systems for now (waiting for tar toolchain).
MacOS does not have the same options for tar, for now fixing this only
for Linux.

@gergelyfabian
Copy link
Contributor Author

Follow up for #380.

@chancila
Copy link

chancila commented Oct 2, 2023

this is a gnu tar flag, this won't work on other tars...for reference bsd/mac tar uses --uname and --gname

@alexeagle
Copy link
Collaborator

We'll fix this after we have bazel-contrib/bazel-lib#468 so the same hermetic tar is used everywhere.

Applied suggestion for Linux from:

http://h2.jaguarpaw.co.uk/posts/reproducible-tar/

Left out MacOS and other systems for now (waiting for tar toolchain).
MacOS does not have the same options for tar, for now fixing this only
for Linux.
@gergelyfabian gergelyfabian force-pushed the oci_tarball_fix_username_and_group branch from 005a4d4 to f27f47d Compare October 3, 2023 07:45
@gergelyfabian gergelyfabian changed the title oci_tarball: fix user and group to numeric 0 oci_tarball: set time, user and group to reproducible values for Linux Oct 3, 2023
@gergelyfabian
Copy link
Contributor Author

Rebased PR with the revert for #380.
Updated to set parameters only for Linux (I could also set parameters for Mac, but I don't have a way to test it, so preferred to leave the functionality unchanged for Mac). Optimally it would be better to use the tar toolchain (bazel-contrib/bazel-lib#468), but not having reproducible tars is a regression when migrating from rules_docker to rules_oci, so I'd personally prefer to have it fixed in the meantime.

@alexeagle
Copy link
Collaborator

Sorry, I'd rather not merge a fix that's only for one platform, that just leaves both the original bug and also some tech debt for us to remove. #385 is probably the better change, though it may take a couple weeks to land. I suggest you apply this patch in your own repo for now.

@alexeagle alexeagle closed this Oct 4, 2023
@gergelyfabian
Copy link
Contributor Author

gergelyfabian commented Oct 4, 2023 via email

@alexeagle
Copy link
Collaborator

alexeagle commented Oct 4, 2023

The tar rule in bazel-lib should already be reproducible, that's part of its API contract.

However in that PR I'm just using the toolchain directly, so it will need some flags set, you're right.

@alexeagle
Copy link
Collaborator

okay I updated that PR with halfway working implementation that uses an mtree file to exactly specify deterministic content of the tar file.

Not sure when @thesayyn or I will get time to finish it...

@gergelyfabian
Copy link
Contributor Author

gergelyfabian commented Oct 4, 2023 via email

@gergelyfabian
Copy link
Contributor Author

Can confirm that #385 already implements reproducible tars.

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