initial commit
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Fetch only the fixed Linux GN, Clang and sysroot inputs for the isolated build."""
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import time
|
||||
import urllib.request
|
||||
|
||||
ROOT=Path(__file__).resolve().parents[2]
|
||||
|
||||
|
||||
def sha(path):
|
||||
with path.open('rb') as stream: return hashlib.file_digest(stream,'sha256').hexdigest()
|
||||
|
||||
|
||||
def main():
|
||||
pins=json.loads((ROOT/'tests/results/source-correspondence/pdfium/dependency-pins.json').read_text())
|
||||
source=ROOT/'build-pdfium-intent/source'
|
||||
clang=next(row for row in pins['root']['deps']['third_party/llvm-build/Release+Asserts']['objects']
|
||||
if row['object_name'].startswith('Linux_x64/clang-llvmorg-'))
|
||||
sysroot=json.loads((source/'build/linux/sysroot_scripts/sysroots.json').read_text())['bullseye_amd64']
|
||||
gn_version=pins['root']['vars']['gn_version']
|
||||
inputs=[{'name':'clang.tar.xz','url':'https://commondatastorage.googleapis.com/chromium-browser-clang/'+clang['object_name']+'?generation='+str(clang['generation']),
|
||||
'expectedSha256':clang['sha256sum'],'expectedBytes':clang['size_bytes']},
|
||||
{'name':'sysroot.tar.xz','url':sysroot['URL']+'/'+sysroot['Sha256Sum'],'expectedSha256':sysroot['Sha256Sum']},
|
||||
{'name':'gn.zip','url':'https://chrome-infra-packages.appspot.com/dl/gn/gn/linux-amd64/+/'+gn_version,
|
||||
'cipdPackage':'gn/gn/linux-amd64','cipdVersion':gn_version}]
|
||||
cache=ROOT/'build-pdfium-intent/downloads'; cache.mkdir(parents=True,exist_ok=False)
|
||||
def fetch(row):
|
||||
path=cache/row['name']; total=0; started=time.monotonic()
|
||||
with urllib.request.urlopen(row['url'],timeout=60) as response, path.open('xb') as stream:
|
||||
content_length=response.headers.get('Content-Length')
|
||||
if content_length: assert int(content_length)<=512*1024**2
|
||||
for chunk in iter(lambda:response.read(1024*1024),b''):
|
||||
total+=len(chunk)
|
||||
assert total<=512*1024**2 and time.monotonic()-started<=600
|
||||
stream.write(chunk)
|
||||
digest=sha(path)
|
||||
if 'expectedSha256' in row: assert row['expectedSha256']==digest
|
||||
if 'expectedBytes' in row: assert row['expectedBytes']==total
|
||||
print(row['name']+' '+str(total)+' bytes; SHA-256 '+digest,flush=True)
|
||||
return {**row,'path':str(path.relative_to(ROOT)),'bytes':total,'sha256':digest}
|
||||
with ThreadPoolExecutor(max_workers=3) as pool: rows=list(pool.map(fetch,inputs))
|
||||
record={'success':True,'fetcherSha256':sha(Path(__file__)),'inputs':rows,
|
||||
'scope':'Clang and sysroot checked against source-pinned SHA-256. GN fetched from the official CIPD fixed Git-revision selector; archive SHA-256 recorded. No downloaded executable or installer has been run.'}
|
||||
(ROOT/'tests/results/pdfium-intent-build/tool-downloads.json').write_text(json.dumps(record,indent=2)+'\n')
|
||||
|
||||
|
||||
if __name__=='__main__':main()
|
||||
Reference in New Issue
Block a user