Skip to content

Commit

Permalink
oci_tarball: set time, user and group to reproducible values for Linux
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gergelyfabian committed Oct 3, 2023
1 parent 4e125bf commit f27f47d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion oci/private/tarball.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,15 @@ layers="${LAYERS}" \
--null-input '.[0] = {"Config": env(config), "RepoTags": "${repo_tags}" | envsubst | split("%") | map(select(. != "")) , "Layers": env(layers) | map( "blobs/" + . + ".tar.gz") }' \
--output-format json > "${STAGING_DIR}/manifest.json"

if [[ "$OSTYPE" == "linux-gnu"* ]]; then
reproducible_flags="--mtime=2000-01-01 --owner=0 --group=0 --numeric-owner"
elif [[ "$OSTYPE" == "darwin"* ]]; then
# FIXME: add necessary attributes or wait for tar toolchain.
reproducible_flags=""
else
# FIXME: add necessary attributes or wait for tar toolchain.
reproducible_flags=""
fi

# TODO: https://github.com/bazel-contrib/rules_oci/issues/217
tar -C "${STAGING_DIR}" -cf "${TARBALL_PATH}" manifest.json blobs
tar -C "${STAGING_DIR}" -cf "${TARBALL_PATH}" $reproducible_flags manifest.json blobs

0 comments on commit f27f47d

Please sign in to comment.