from pathlib import Path import hashlib,json,urllib.request O=Path(__file__).resolve().parent records=[] def get(url,name): with urllib.request.urlopen(urllib.request.Request(url,headers={'User-Agent':'Arcadia-runtime-provenance/1'}),timeout=45) as r: b=r.read(); records.append({'url':url,'final_url':r.url,'status':r.status,'file':name,'bytes':len(b),'sha256':hashlib.sha256(b).hexdigest()}) with (O/name).open('xb') as f:f.write(b) return b tag=json.loads(get('https://api.github.com/repos/mstorsjo/llvm-mingw/git/tags/bdd1c28943bc0aaa4e33ebf7a42408a81d69380c','distribution-tag-object.json')) commit=tag['object']['sha'];assert tag['object']['type']=='commit' for path,name in [('build-llvm.sh','build-llvm.sh'),('build-libcxx.sh','build-libcxx.sh'),('build-all.sh','build-all.sh'),('build-cross-tools.sh','build-cross-tools.sh'),('.github/workflows/release.yml','release-workflow.yml'),('Dockerfile','Dockerfile'),('release.sh','release.sh')]: get(f'https://raw.githubusercontent.com/mstorsjo/llvm-mingw/{commit}/{path}',name) llvmref=json.loads(get('https://api.github.com/repos/llvm/llvm-project/git/ref/tags/llvmorg-23.1.1','llvm-tag-ref.json')) obj=llvmref['object'] if obj['type']=='tag':obj=json.loads(get(obj['url'],'llvm-tag-object.json'))['object'] assert obj['type']=='commit';llvm=obj['sha'] get(f'https://raw.githubusercontent.com/llvm/llvm-project/{llvm}/libunwind/LICENSE.TXT','llvm-libunwind-LICENSE.TXT') get(f'https://raw.githubusercontent.com/llvm/llvm-project/{llvm}/libunwind/CMakeLists.txt','libunwind-CMakeLists.txt') with (O/'source-evidence.json').open('x',encoding='utf-8') as f:json.dump({'distribution_commit':commit,'llvm_commit':llvm,'records':records},f,indent=2) print(json.dumps({'distribution_commit':commit,'llvm_commit':llvm,'records':records},indent=2))