22 lines
934 B
Python
22 lines
934 B
Python
#!/usr/bin/env python3
|
|
"""Preserve Unix executable permissions in each ZIP and in the aggregate."""
|
|
import hashlib
|
|
from pathlib import Path
|
|
from zipfile import ZipFile, ZIP_DEFLATED
|
|
root = Path(__file__).resolve().parent.parent
|
|
out = root / 'dist'
|
|
archives=[]
|
|
for folder in sorted(out.glob('wswg-*')):
|
|
if not folder.is_dir(): continue
|
|
target = out / (folder.name + '.zip')
|
|
with ZipFile(target, 'w', ZIP_DEFLATED, compresslevel=6) as z:
|
|
for p in sorted(folder.rglob('*')):
|
|
if p.is_file(): z.write(p, p.relative_to(out))
|
|
archives.append(target)
|
|
all_zip = out / 'wswg-all.zip'
|
|
with ZipFile(all_zip, 'w', ZIP_DEFLATED, compresslevel=1) as z:
|
|
for p in archives: z.write(p, p.name)
|
|
with (out/'SHA256SUMS').open('w') as f:
|
|
for p in archives+[all_zip]:
|
|
f.write(hashlib.file_digest(p.open('rb'),'sha256').hexdigest()+' '+p.name+'\n')
|
|
print(f'{len(archives)} platform archives + {all_zip}')
|