Reputation: 2616
When updating one of my ports in my custom overlay registry for vcpkg, the "portfile.cmake" file requires me to provide the "SHA512" hash of the Github project archive, example:
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO dennisferron/antlr4-testrig-runner
REF 4c0f384236c8b555b3b3a156a91af7cd43d695dc
SHA512 aad0471dcd8aa947a894a1536be28b9aa801fea3f4ef0a3e635f9329756dca9ef4cf34b1c1a167b604400849c3b31a3bc87561b7ee89e0f9b6dc82b50857a5dc
HEAD_REF main
)
I usually use the following commands to get this value (example):
wget https://github.com/dennisferron/antlr4-testrig-runner/archive/4c0f384236c8b555b3b3a156a91af7cd43d695dc.tar.gz
dferr@LAPTOP-CIRFVD7D MSYS ~
$ wget https://github.com/dennisferron/antlr4-testrig-runner/archive/4c0f384236c8b555b3b3a156a91af7cd43d695dc.tar.gz
--2024-07-02 16:51:27-- https://github.com/dennisferron/antlr4-testrig-runner/archive/4c0f384236c8b555b3b3a156a91af7cd43d695dc.tr.gz
(... snip ...)
--2024-07-02 16:51:27-- https://codeload.github.com/dennisferron/antlr4-testrig-runner/tar.gz/4c0f384236c8b555b3b3a156a91af7cd43695dc
(... snip ...)
2024-07-02 16:51:27 (3.27 MB/s) - ‘4c0f384236c8b555b3b3a156a91af7cd43d695dc.tar.gz’ saved [6666]
dferr@LAPTOP-CIRFVD7D MSYS ~
$ vcpkg hash 4c0f384236c8b555b3b3a156a91af7cd43d695dc.tar.gz
aad0471dcd8aa947a894a1536be28b9aa801fea3f4ef0a3e635f9329756dca9ef4cf34b1c1a167b604400849c3b31a3bc87561b7ee89e0f9b6dc82b50857a5dc
Is there a way to obtain this hash value without actually downloading the entire tar.gz file? E.g. by using libgit, the Github API, or manually tar'ing the local copy of the repository (which is also present on disk)? I'm working on a program or scripts to automate these steps, and:
It seems wasteful to download the archive from Github just to hash the file and then delete it after.
On Windows I can't just assume the system has wget so not needing it will be one less dependency to require or bundle.
Upvotes: 1
Views: 144