Files
pbz-cppbypass/tools/package.py
T
KintaroModding be97b1b716 Relicense under GPL-3.0 with section 7 terms and contribution files
Replace the MIT license with the GNU General Public License, version 3 (LICENSE),
mirroring KintaroModding/uemodmanager. Add NOTICE.md (the copyright line, the
section 7 credit/marking/name terms, and the library notices, folding in the
former THIRD_PARTY_NOTICES.md), CONTRIBUTING.md and CONTRIBUTORS.md. Update the
README license and contributing sections and the build and package file lists.
2026-11-04 15:06:55 +01:00

32 lines
1.7 KiB
Python

"""Prepare local binary/source archives; performs no publishing or deployment."""
from pathlib import Path
import hashlib
import json
import zipfile
ROOT=Path(__file__).resolve().parents[1]
out=ROOT/'dist'
version=json.loads((ROOT/'mod.json').read_text())['version']
stem=f'phantombladezero_scriptcompat_{version}_experimental'
binary=out/(stem+'.zip')
source=out/(stem+'_source.zip')
binary_files=[out/'README.md',out/'LICENSE',out/'NOTICE.md',out/'CONTRIBUTORS.md',
out/'MINHOOK-LICENSE.txt',out/'UE4SS-SDK-LICENSE.txt']
binary_files+=list((out/'ue4ss').rglob('*'))
with zipfile.ZipFile(binary,'w',zipfile.ZIP_DEFLATED) as z:
for path in sorted(binary_files):
if path.is_file():z.write(path,path.relative_to(out).as_posix())
files=[ROOT/name for name in ['README.md','LICENSE','NOTICE.md','CONTRIBUTING.md','CONTRIBUTORS.md','mod.json','.gitignore','.gitattributes']]
for folder in ['src','tests','tools/vendor/minhook-1.3.4','tools/vendor/ue4ss-sdk']:
files.extend(p for p in (ROOT/folder).rglob('*') if p.is_file())
files.append(ROOT/'tools/build.py')
with zipfile.ZipFile(source,'w',zipfile.ZIP_DEFLATED) as z:
for path in sorted(files):z.write(path,path.relative_to(ROOT).as_posix())
for archive in [binary,source]:
with zipfile.ZipFile(archive) as z:
assert z.testzip() is None
assert all('\\' not in n and not n.startswith('/') and '..' not in Path(n).parts for n in z.namelist())
print(archive.name,archive.stat().st_size,hashlib.sha256(archive.read_bytes()).hexdigest())
(out/'SHA256SUMS.txt').write_text(''.join(
f'{hashlib.sha256(a.read_bytes()).hexdigest()} {a.name}\n' for a in [binary,source]),encoding='ascii')