chore: import verified syly2 maintenance baseline without embedded credentials
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Verify the official archive and transfer only required runtime files."""
|
||||
import hashlib,json,re,tarfile
|
||||
from pathlib import Path
|
||||
root=Path(__file__).resolve().parents[1]/'.local/uat-deploy'
|
||||
archive=root/'mysql-5.7.44.tar.gz'
|
||||
def hashfile(p, alg):
|
||||
h=hashlib.new(alg)
|
||||
with p.open('rb') as f:
|
||||
for block in iter(lambda:f.read(1024*1024),b''):h.update(block)
|
||||
return h.hexdigest()
|
||||
expected=re.search(r'\b[0-9a-fA-F]{32}\b',(root/'mysql-5.7.44.tar.gz.md5').read_text()).group().lower()
|
||||
assert hashfile(archive,'md5')==expected
|
||||
out=root/'mysql-5.7.44-runtime.tar.gz'
|
||||
files=[]
|
||||
with tarfile.open(archive,'r|gz') as src,tarfile.open(out,'w:gz',compresslevel=6) as dst:
|
||||
for m in src:
|
||||
rel=m.name.split('/',1)[1] if '/' in m.name else ''
|
||||
take=rel in ['bin/mysqld','bin/mysql','bin/mysqladmin','bin/mysqldump'] or rel.startswith(('lib/','share/'))
|
||||
if take and '/debug/' not in rel and not rel.endswith('.a'):
|
||||
assert '..' not in Path(rel).parts
|
||||
dst.addfile(m,src.extractfile(m) if m.isfile() else None)
|
||||
files.append({'path':rel,'bytes':m.size})
|
||||
manifest={'source_url':'https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.44-linux-glibc2.12-x86_64.tar.gz','source_md5_verified':expected,'source_sha256':hashfile(archive,'sha256'),'runtime_sha256':hashfile(out,'sha256'),'runtime_bytes':out.stat().st_size,'files':files}
|
||||
(root/'mysql-runtime-manifest.json').write_text(json.dumps(manifest,indent=2))
|
||||
print(json.dumps({k:v for k,v in manifest.items() if k!='files'},indent=2))
|
||||
Reference in New Issue
Block a user