Files
Dreierpack-Manager/tools/package/make_package.py
T
ClaudeandClaude Sonnet 5.5 9e593f921f Move the game texts out of the source into openbmh.dat
The numbers of the Diamond 3.7 executable and of Football Limited stay built in,
the game texts go into data/openbmh.dat, which the release ships next to the
programs (found in OPENBMH_DAT, the game folder, the program folder, the current
folder). Without the file those texts are empty. A replay of a recorded session
gives the same output as with the real BMH.exe when the file is there, and differs
only in the seven text lines when it is missing. week_check no longer counts its
probe re-rating of the team as draws of the port (the apparent deviation from
minute 10 of the DOSBox recording was this measuring error).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 14:32:27 +01:00

72 lines
3.9 KiB
Python

#!/usr/bin/env python3
"""Install the Runtime component and make an allowlisted release ZIP."""
# SPDX-License-Identifier: GPL-3.0-only
import argparse
from pathlib import Path
import re
import subprocess
import tempfile
import zipfile
def validate(directory, windows):
products = {'OpenBMH.exe', 'openbmh_cli.exe'} if windows else {'OpenBMH', 'openbmh_cli'}
documents = {'README.md', 'LICENSE', 'THIRD_PARTY_NOTICES.md', 'ACKNOWLEDGEMENTS.md', 'CONTRIBUTING.md', 'openbmh.dat'}
licenses = {'README.md', 'LGPL-2.1.txt', 'Nuked-OPL3-notices.txt', 'LZMA-SDK.txt', 'SDL2-HIDAPI-BSD.txt',
'SDL2-HIDAPI-options.txt', 'SDL2-HIDAPI-original.txt', 'SDL2-yuv2rgb.txt',
'SDL2.txt', 'miniz-source-notices.txt', 'miniz.txt', 'nativefiledialog-extended.txt', 'stb_image.txt'}
present = set()
for file in directory.rglob('*'):
if not file.is_file():
continue
relative = file.relative_to(directory)
present.add(relative.as_posix())
allowed = (len(relative.parts) == 1 and file.name in products | documents)
allowed |= len(relative.parts) == 3 and relative.parts[:2] == ('docs', 'licenses') and file.name in licenses
allowed |= (len(relative.parts) >= 2 and relative.parts[0] == 'docs' and
'licenses' not in relative.parts and file.suffix in {'.md', '.txt', '.csv'} and
all(part not in {'analyses', 'agents', 'manuals', 'validation'} for part in relative.parts))
# App-local UCRT deployment must ship the whole redist set, core forwarders included.
allowed |= (windows and len(relative.parts) == 1 and
bool(re.fullmatch(r'(?:vcruntime\d+(?:_\d+)?|msvcp\d+(?:_\d+|_atomic_wait|_codecvt_ids)?|'
r'concrt\d+|ucrtbase|api-ms-win-(?:crt|core)-[a-z0-9-]+)\.dll', file.name, re.I)))
if not allowed:
raise RuntimeError('Unexpected package entry: ' + relative.as_posix())
required = products | documents | {'docs/licenses/' + name for name in licenses}
required.add('docs/release/1.0/RELEASE_NOTES.md')
if required - present:
raise RuntimeError('Missing package entries: ' + ', '.join(sorted(required - present)))
if windows and not {'vcruntime140.dll', 'msvcp140.dll'} <= present:
raise RuntimeError('App-local Microsoft runtime libraries missing')
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--build', required=True, type=Path)
parser.add_argument('--out', required=True, type=Path)
parser.add_argument('--platform', required=True, choices=['windows-x64', 'linux-x64', 'macos-arm64'])
parser.add_argument('--config', default='Release')
args = parser.parse_args()
args.out.mkdir(parents=True, exist_ok=True)
with tempfile.TemporaryDirectory(prefix='openbmh-package-', dir=args.out) as temp:
stage = Path(temp) / 'runtime'
subprocess.run(['cmake', '--install', str(args.build), '--config', args.config,
'--component', 'Runtime', '--prefix', str(stage)], check=True)
windows = args.platform == 'windows-x64'
validate(stage, windows)
cli = stage / ('openbmh_cli.exe' if windows else 'openbmh_cli')
version = subprocess.check_output([str(cli.resolve()), '--version'], text=True).strip().split()[-1]
if not re.fullmatch(r'\d+\.\d+\.\d+(?:[-+][A-Za-z0-9.-]+)?', version):
raise RuntimeError('Invalid product version')
name = 'OpenBMH-' + version + '-' + args.platform
destination = args.out / (name + '.zip')
with zipfile.ZipFile(destination, 'w', compression=zipfile.ZIP_DEFLATED) as archive:
for file in sorted(stage.rglob('*')):
if file.is_file():
archive.write(file, Path(name) / file.relative_to(stage))
print(destination)
if __name__ == '__main__':
main()