opam icon indicating copy to clipboard operation
opam copied to clipboard

is there a command to add a `checksum` to an opam file?

Open Khady opened this issue 1 year ago • 2 comments

There's a command which is able to check if an opam file has a correct checksum

opam lint --check-upstream path/to/the/file

But is there one to add a checksum to an opam file?

For the record it would be convenient at ahrefs where we have a repo with overlays or unreleased versions of packages. We can usually start from opam show --raw name-of-the-package > patch/to/the/file and set the url of the archive we want to use. But then we need to do something by hand to compute and add the checksum, which people tend to forget about.

echo "checksum: [ \"sha512=$(curl -L $(opam show -f url.src --raw path/to/the/file | sed 's/^"\(.*\)"$/\1/') | sha512sum | awk '{print $1}')\" ]"

Khady avatar Apr 24 '24 03:04 Khady

(ftr doing curl | checksum is kind of meh from the not trusting the infrastructure pov, should be doing checksum on the local file before uploading)

rr0gi avatar Apr 30 '24 16:04 rr0gi

This part already exists as part of tools like dune-release and opam publish I believe. The use case here is a bit different.

Khady avatar May 01 '24 01:05 Khady