-
Notifications
You must be signed in to change notification settings - Fork 44
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
generate individual checksum file for each target #84
generate individual checksum file for each target #84
Conversation
@cocoa-xu the main purpose of checksum.exs in my opinion is to avoid supply chain attacks, so I don't think we should avoid it. If we want to improve this, I think we should send pull requests to Hex.pm to allow metadata to be attached to packages. I will add a TODO list for the Dashbit team to tackle it (but most likely only Q3-Q4). However, to address your CI issues, we can download the .sha256 files when building the checksum.exs itself, but that's it. WDYT? |
Yeah, that's what this PR is doing/adding to elixir_make.
True, I also kinda hesitated when suggesting the idea of ditching away
No problem! Let's discuss this later/ |
Perfect then, I dropped some suggestions and you can merge whenever. :) Once it has tested a bit, please let me know and I can do a new release :) |
Co-authored-by: José Valim <[email protected]>
Thank you Jose! I don't have write access to this repository but I can do some tests first and let you know if this PR is ready. ;) |
Hi Jose I fixed a minor issue and tested this PR here using the following script: mix deps.get
mix elixir_make.checksum --all
targets=(
aarch64-apple-darwin
aarch64-linux-gnu
armv7l-linux-gnueabihf
i686-linux-gnu
powerpc64le-linux-gnu
riscv64-linux-gnu
s390x-linux-gnu
x86_64-apple-darwin
x86_64-linux-gnu
x86_64-windows-msvc
)
echo "%{" > manual-checksum.exs
for target in "${targets[@]}"; do
export FILENAME=stb_image-nif-2.16-${target}-0.6.9.tar.gz
curl -fSsL https://github.com/cocoa-xu/stb_image/releases/download/v0.6.9/${FILENAME}.sha256 -o ${FILENAME}.sha256
curl -fSsL https://github.com/cocoa-xu/stb_image/releases/download/v0.6.9/${FILENAME} -o ${FILENAME}
sha256sum -c ${FILENAME}.sha256 && echo " \"${FILENAME}\" => \"sha256:$(sha256sum ${FILENAME} | cut -d' ' -f1)\"," >> manual-checksum.exs
done
echo "}" >> manual-checksum.exs
cat checksum.exs
cat manual-checksum.exs
diff checksum.exs manual-checksum.exs And the result looks okay to me. :)
|
💚 💙 💜 💛 ❤️ |
Hi this PR improves user experience by generating a checksum file for each target and assembling the final
checksum.exs
file using the generated checksum files over the actual binary files.This can be useful because if the binaries need to be compiled in different CI runners, for example, separate runners for Linux, macOS and Windows, where we cannot produce the final
checksum.exs
right away on CI -- currently we have to download all precompiled binaries just to build the finalchecksum.exs
file, and it costs disk space and time to do so especially when the binaries are huge.This feature is on by default but it requires users to include the generated
.sha256
files in the GitHub release. If the.sha256
file cannot be downloaded (no matter it's because of a network error or it's missing in the GitHub release), the precompiled binaries will be downloaded to calculate the checksum (as what we're currently doing on the master branch).In addition to that, this PR opens a chance for us to (maybe optionally) ditch away the
checksum.exs
file (somewhat a double edged sword), because it cannot be changed after it's released to hex.pm (IIRC it's 30 minutes or 1 hour-ish); so if the library author missed anything, they have to release a new version which means to go through the whole process again.Of course, one of the pros of using a
checksum.exs
file is that it prevents situations like network error or supply chain attacks (e.g., attackers re-upload these binaries with malicious code).