Files
mars_nwe_pcab/cross/package-drivers.py

24 lines
1.5 KiB
Python

#!/usr/bin/env python3
"""Package existing validated cross-builds using Python's standard ZIP library."""
from pathlib import Path
import hashlib, json, zipfile
root=Path(__file__).resolve().parents[1]
out=root/'releases/windows';out.mkdir(parents=True,exist_ok=True)
manifest={}
for os in ('WIN95','WIN98','WINME','WINNT40','WIN2000','WINXP'):
src=root/'build/cross/packages'/os
required=['IPXDIAG.EXE']+(['MARSNDIS.SYS','MARSNDIS.INF','MARSIPX.EXE','MARSTAP.EXE'] if os in ('WIN2000','WINXP') else ['MARSNET3.SYS','MARSNET.EXE','WPCAP31.EXE','INSTALL.BAT','OEMSETUP.INF' if os=='WINNT40' else 'MARSNET.INF'])
for name in required:
if not (src/name).is_file():raise SystemExit(f'Missing {os}/{name}; run build-windows.sh first')
files={p.name:p for p in src.iterdir() if p.is_file()}
for name in ('WINDOWS.md','LEGACY-BUILD.md','COPYING'):files[name]=root/name
hashes={name:hashlib.sha256(p.read_bytes()).hexdigest() for name,p in sorted(files.items())}
dest=out/(os+'.zip')
with zipfile.ZipFile(dest,'w',zipfile.ZIP_DEFLATED) as z:
for name,p in sorted(files.items()):
info=zipfile.ZipInfo(os+'/'+name,(2026,11,27,0,0,0));info.external_attr=0o100644<<16;info.compress_type=zipfile.ZIP_DEFLATED;z.writestr(info,p.read_bytes())
manifest[os]={'sha256':hashlib.sha256(dest.read_bytes()).hexdigest(),'files':hashes}
(out/'manifest.json').write_text(json.dumps(manifest,indent=2)+'\n')
(out/'SHA256SUMS').write_text(''.join(f'{v["sha256"]} {k}.zip\n' for k,v in manifest.items()))
print('Packaged 6 OS ZIPs with file hashes')