#!/usr/bin/env python3 """Assemble a versioned local bundle; never install services or publish remotely.""" from pathlib import Path import hashlib,json,zipfile,sys root=Path(__file__).resolve().parents[1];out=root/'releases' version=sys.argv[1] if len(sys.argv)>1 else '0.9.1-3' if not version or any(c not in '0123456789.-' for c in version):raise SystemExit('Invalid version') name='MARS_NWE-'+version src=out/(name+'-source.zip') folders=['src','native','websetup','browser','clients','cross','packaging','tests','upstream-adapter','nds'] allowed={'.c','.h','.cpp','.js','.cjs','.mjs','.py','.sh','.html','.css','.md','.json','.txt','.example','.service','.timer','.pa','.r','.patch','.cmake','.bat','.inf','.asm','.s','.rc','.def','.mak'} with zipfile.ZipFile(src,'w',zipfile.ZIP_DEFLATED) as z: for p in root.iterdir(): if p.is_file() and (p.suffix.lower() in allowed or p.name in ['Makefile','COPYING']):z.write(p,'mars_nwe/'+p.name) for folder in folders: for p in (root/folder).rglob('*'): if p.is_file() and (p.suffix.lower() in allowed or p.name in ['Makefile','CMakeLists.txt']) and '__pycache__' not in p.parts:z.write(p,'mars_nwe/'+str(p.relative_to(root))) files=[out/'README.md',src,out/('deb/mars-vme_'+version+'_amd64.deb')] for folder in ['browser','windows','dos']:files.extend(p for p in (out/folder).iterdir() if p.is_file()) manifest=out/('BUILD-'+version+'.json') manifest.write_text(json.dumps({'version':version,'runtime_status':'Mac audio and XP connectivity unverified; no native 68k binary','existing_database':'LP64 Bindery requires reviewed migration; installation guarded','artifacts':{str(p.relative_to(out)):hashlib.sha256(p.read_bytes()).hexdigest() for p in files}},indent=2)+'\n') files.append(manifest) bundle=out/(name+'.zip') with zipfile.ZipFile(bundle,'w',zipfile.ZIP_DEFLATED) as z: for p in files:z.write(p,name+'/'+str(p.relative_to(out))) with zipfile.ZipFile(bundle) as z:assert z.testzip() is None (out/(name+'.sha256')).write_text(''.join(hashlib.sha256(p.read_bytes()).hexdigest()+' '+p.name+'\n' for p in [bundle,src])) print(bundle)