Created
April 19, 2023 09:50
-
-
Save zaddach/92949ce6e820323d20dfbdf81bb72c31 to your computer and use it in GitHub Desktop.
Script for generating current rust package descriptions for vcpkg package vcpkg-rust
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import tomli | |
import requests | |
import hashlib | |
STABLE_CHANNEL_MANIFEST_URL = "https://static.rust-lang.org/dist/channel-rust-stable.toml" | |
ARCHITECTURES = [ | |
"i686-pc-windows-msvc", | |
"x86_64-pc-windows-msvc", | |
"i686-unknown-linux-gnu", | |
"x86_64-unknown-linux-gnu", | |
] | |
PACKAGES = ["rustc", "rust-std", "cargo"] | |
def get_url_sha512(url): | |
data = requests.get(url, stream = True) | |
hasher = hashlib.sha512() | |
for chunk in data.iter_content(chunk_size = None): | |
hasher.update(chunk) | |
return hasher.hexdigest() | |
def main(args): | |
response = requests.get(STABLE_CHANNEL_MANIFEST_URL) | |
manifest = tomli.loads(response.text) | |
data = {} | |
for arch in ARCHITECTURES: | |
data[arch] = {} | |
for package in PACKAGES: | |
target = manifest[f"pkg"][package]["target"][arch] | |
assert(target["available"]) | |
url = target["xz_url"] | |
data[arch][package] = {"url": url, "sha512": get_url_sha512(url)} | |
for arch in data: | |
print(f" # {arch}") | |
for package in data[arch]: | |
info = data[arch][package] | |
print(f" z_vcpkg_rust_acquire_declare_package(\n URL \"{info['url']}\"\n SHA512 {info['sha512']}\n )") | |
print("") | |
def parse_args(): | |
parser = argparse.ArgumentParser() | |
return parser.parse_args() | |
if __name__ == "__main__": | |
main(parse_args()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment