Skip to content

Decode SRI checksums in Starlark so apk_import is reproducible - #423

Open
alexander-scott wants to merge 1 commit into
chainguard-dev:mainfrom
alexander-scott:starlarkify_sri_checksum
Open

alexander-scott wants to merge 1 commit into
chainguard-dev:mainfrom
alexander-scott:starlarkify_sri_checksum

Conversation

@alexander-scott

Copy link
Copy Markdown
Contributor

apk_import names the cached control and data segments after their checksums, which normalize_sri converted from SRI with base64 -d | xxd -p | tr -d '\n'. On a host without xxd that pipeline prints nothing and still exits 0, because its status is tr's, so the segments were written as .ctl.tar.gz and .dat.tar.gz instead of <sha1>.ctl.tar.gz and <sha256>.dat.tar.gz.

The repository is marked reproducible, so whichever host populated the repo contents cache decided the names everyone else got, and every machine ended up with its own mix. The apko_image cache staging action and apko build take those files as inputs, so their action keys differed between machines building the same lockfile and rarely hit the remote cache. apko also only finds the expanded segments in its offline cache under the hashed names; with empty names it falls back to the concatenated .apk.

Decode the base64 in Starlark instead, and bump RULES_APKO_CACHE_KEY so cached repositories with the empty names are refetched.

apk_import names the cached control and data segments after their
checksums, which normalize_sri converted from SRI with
`base64 -d | xxd -p | tr -d '\n'`. On a host without xxd that pipeline
prints nothing and still exits 0, because its status is tr's, so the
segments were written as `.ctl.tar.gz` and `.dat.tar.gz` instead of
`<sha1>.ctl.tar.gz` and `<sha256>.dat.tar.gz`.

The repository is marked reproducible, so whichever host populated the
repo contents cache decided the names everyone else got, and every
machine ended up with its own mix. The apko_image cache staging action
and `apko build` take those files as inputs, so their action keys
differed between machines building the same lockfile and rarely hit
the remote cache. apko also only finds the expanded segments in its
offline cache under the hashed names; with empty names it falls back to
the concatenated .apk.

Decode the base64 in Starlark instead, and bump RULES_APKO_CACHE_KEY so
cached repositories with the empty names are refetched.
@alexander-scott
alexander-scott marked this pull request as ready for review November 9, 2026 04:56
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.

1 participant