Skip to content

Instantly share code, notes, and snippets.

@bachp
Last active October 9, 2017 16:52
Show Gist options
  • Select an option

  • Save bachp/01b988711b9c32ef8db11c059a461644 to your computer and use it in GitHub Desktop.

Select an option

Save bachp/01b988711b9c32ef8db11c059a461644 to your computer and use it in GitHub Desktop.
Fetch hashes for rust
#!/usr/bin/env python3
# Copyright (c) 2017 Pascal Bach
# SPDX-License-Identifier: MIT
# All rust-related downloads can be found at
# https://static.rust-lang.org/dist/index.html. To find the date on
# which a particular thing was last updated, look for the *-date.txt
# file, e.g.
# https://static.rust-lang.org/dist/channel-rust-beta-date.txt
# Usage: ./print-hashes.py 1.20.0
from urllib import request
import sys
PLATFORMS=["i686-unknown-linux-gnu", "x86_64-unknown-linux-gnu", "i686-apple-darwin" ,"x86_64-apple-darwin", "aarch64-unknown-linux-gnu"]
BASEURL="https://static.rust-lang.org/dist"
try:
version = sys.argv[1]
except:
print("No version supplied")
exit(-1)
date = ""
with request.urlopen(f"{BASEURL}/channel-rust-{version}-date.txt") as response:
date = response.read().decode("utf-8")
print("hashes = {");
for platform in PLATFORMS:
with request.urlopen(f"{BASEURL}/{date}/rust-{version}-{platform}.tar.gz.sha256") as response:
line = response.read().decode("utf-8")
(hash,file) = line.split()
print(f' "{platform}" = "{hash}";');
print("};");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment