Restore direct-installation Classic baseline for OpenBMH 1.0 (by Codex)
This commit is contained in:
1 parent
c8f04d0099
commit
c3704878d6
255 files changed
+311
-21131
No files matched your search
@@ -1,127 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
"""Package the standalone editor, its native assets and corresponding source.
|
||||
|
||||
This deliberately includes no imported world or original game artwork.
|
||||
"""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
import zipfile
|
||||
from make_source_package import COMPONENTS, MINIZ_FILES, git, copy_files
|
||||
|
||||
EXTRA = {
|
||||
'editor_json': ('v3.12.0', 'https://github.com/nlohmann/json'),
|
||||
'editor_http': ('v0.63.0', 'https://github.com/yhirose/cpp-httplib'),
|
||||
'editor_images': ('release-2.8.8', 'https://github.com/libsdl-org/SDL_image'),
|
||||
'editor_svg': ('v3.5.0', 'https://github.com/sammycage/lunasvg'),
|
||||
'editor_xml': ('v1.15', 'https://github.com/zeux/pugixml'),
|
||||
}
|
||||
|
||||
|
||||
def zip_tree(root, target):
|
||||
with zipfile.ZipFile(target, 'w', zipfile.ZIP_DEFLATED, compresslevel=6) as archive:
|
||||
for file in sorted(root.rglob('*')):
|
||||
if file.is_file():
|
||||
info = zipfile.ZipInfo.from_file(file, Path(root.name) / file.relative_to(root))
|
||||
archive.writestr(info, file.read_bytes(), compress_type=zipfile.ZIP_DEFLATED)
|
||||
|
||||
|
||||
def copy_dependency(directory, target, name, reference):
|
||||
if name == 'miniz' and not (directory / '.git').exists():
|
||||
for file, expected in MINIZ_FILES.items():
|
||||
if hashlib.sha256((directory / file).read_bytes()).hexdigest() != expected:
|
||||
raise RuntimeError('Unexpected miniz source')
|
||||
copy_files(directory, target, list(map(Path, MINIZ_FILES)), required=True)
|
||||
return {'archive': reference}
|
||||
commit = git(directory, 'rev-parse', 'HEAD').decode().strip()
|
||||
expected = git(directory, 'rev-parse', reference + '^{commit}').decode().strip()
|
||||
if commit != expected or git(directory, 'diff', '--name-only', '--ignore-submodules=all').strip():
|
||||
raise RuntimeError('Modified dependency: ' + name)
|
||||
files, modules = [], {}
|
||||
for entry in git(directory, 'ls-files', '--stage', '-z').split(b'\0'):
|
||||
if not entry:
|
||||
continue
|
||||
meta, file = entry.split(b'\t', 1); file = Path(file.decode())
|
||||
if meta.startswith(b'160000 '):
|
||||
# Only this codec is enabled. Freetype's dlg is unused by CMake.
|
||||
required = name == 'editor_images' and file.as_posix() == 'external/libwebp'
|
||||
if required:
|
||||
module_commit = meta.split()[1].decode()
|
||||
modules[str(file)] = copy_dependency(directory / file, target / file, name + '/libwebp', module_commit)
|
||||
else:
|
||||
modules[str(file)] = {'unbuilt': True, 'commit': meta.split()[1].decode()}
|
||||
else:
|
||||
files.append(file)
|
||||
if name == 'lzma_sdk':
|
||||
files = [f for f in files if f.parts[0] == 'C' or f == Path('DOC/License.txt')]
|
||||
hashes = copy_files(directory, target, files, required=True)
|
||||
return {'commit': commit, 'files': hashes, 'submodules': modules}
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--source', type=Path, default=Path(__file__).resolve().parents[2])
|
||||
parser.add_argument('--build', type=Path, required=True)
|
||||
parser.add_argument('--out', type=Path, required=True)
|
||||
parser.add_argument('--platform', required=True, choices=['linux-x64', 'windows-x64', 'macos-arm64'])
|
||||
parser.add_argument('--source-package', action='store_true')
|
||||
args = parser.parse_args()
|
||||
source, build = args.source.resolve(), args.build.resolve()
|
||||
args.out.mkdir(parents=True, exist_ok=True)
|
||||
commit = git(source, 'rev-parse', 'HEAD').decode().strip()
|
||||
version = json.loads((build / 'editor-version.json').read_text())['version']
|
||||
if not re.fullmatch(r'\d+\.\d+\.\d+', version):
|
||||
raise RuntimeError('Invalid editor version')
|
||||
name = 'OpenBMHEditor-' + version + '-' + args.platform
|
||||
with tempfile.TemporaryDirectory(prefix='editor-package-') as td:
|
||||
stage = Path(td) / name; stage.mkdir()
|
||||
exe = 'OpenBMHEditor.exe' if args.platform.startswith('windows') else 'OpenBMHEditor'
|
||||
subprocess.run(['cmake', '--install', str(build), '--component', 'Editor', '--config', 'Release',
|
||||
'--prefix', str(stage)], check=True)
|
||||
shutil.copytree(source / 'docs/licenses', stage / 'licenses')
|
||||
for file in ('LICENSE', 'THIRD_PARTY_NOTICES.md'):
|
||||
shutil.copy2(source / file, stage / file)
|
||||
shutil.copy2(source / 'docs/EDITOR.md', stage / 'EDITOR.md')
|
||||
shutil.copy2(source / 'docs/release/editor-0.5/RELEASE_NOTES.md', stage / 'RELEASE_NOTES.md')
|
||||
if args.platform.startswith('windows'):
|
||||
# Uses the same app-local CRT/UCRT installation as the main game.
|
||||
# A successful runner launch alone does not prove deployability.
|
||||
for dll in ('vcruntime140.dll', 'msvcp140.dll'):
|
||||
if not (stage / dll).is_file():
|
||||
raise RuntimeError('Required Windows runtime missing: ' + dll)
|
||||
(stage / 'BUILD.json').write_text(json.dumps({'commit': commit, 'platform': args.platform, 'version': version,
|
||||
'editor_profile': 'editor-world-v1', 'game_data_included': False}, indent=2) + '\n')
|
||||
zip_tree(stage, args.out / (name + '.zip'))
|
||||
print(args.out / (name + '.zip'))
|
||||
if args.source_package:
|
||||
deps = {**json.loads((build / 'package-dependencies.json').read_text()),
|
||||
**json.loads((build / 'editor-dependencies.json').read_text())}
|
||||
components = {**{n: (v[0], v[1]) for n, v in COMPONENTS.items()}, **EXTRA}
|
||||
with tempfile.TemporaryDirectory(prefix='editor-source-') as td:
|
||||
source_name = 'OpenBMHEditor-' + version + '-source'
|
||||
stage = Path(td) / source_name; stage.mkdir()
|
||||
project = [Path(f.decode()) for f in git(source, 'ls-files', '-z').split(b'\0') if f]
|
||||
manifest = {'project_commit': commit, 'editor_version': version, 'project_files': copy_files(source, stage / 'project', project, required=True), 'dependencies': {}}
|
||||
cache = ['set(OPENBMH_BUILD_EDITOR ON CACHE BOOL "" FORCE)']
|
||||
for name, (ref, url) in components.items():
|
||||
result = copy_dependency(Path(deps[name]), stage / 'dependencies' / name, name, ref)
|
||||
manifest['dependencies'][name] = {'reference': ref, 'upstream': url, **result}
|
||||
cache.append('set(FETCHCONTENT_SOURCE_DIR_' + name.upper() + ' "${CMAKE_CURRENT_LIST_DIR}/dependencies/' + name + '" CACHE PATH "" FORCE)')
|
||||
(stage / 'dependencies.cmake').write_text('\n'.join(cache) + '\n')
|
||||
(stage / 'SOURCE_MANIFEST.json').write_text(json.dumps(manifest, indent=2) + '\n')
|
||||
(stage / 'BUILD_SOURCE.txt').write_text('cmake -S project -B build -C dependencies.cmake -G Ninja -DCMAKE_BUILD_TYPE=Release\n'
|
||||
'cmake --build build --target openbmh_editor editor_core_tests editor_comparison_tests editor_regulations_tests\n'
|
||||
'ctest --test-dir build -R "^editor_(core_tests|comparison_tests|regulations_tests|version)$" --output-on-failure\n'
|
||||
'Native compiler, CMake and OS development libraries: see project/docs/EDITOR.md.\n')
|
||||
zip_tree(stage, args.out / (source_name + '.zip'))
|
||||
print(args.out / (source_name + '.zip'))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -10,17 +10,11 @@ import zipfile
|
||||
|
||||
|
||||
def validate(directory, windows):
|
||||
products = {name + ('.exe' if windows else '') for name in ('OpenBMH', 'openbmh_cli', 'openbmh_import')}
|
||||
products = {'openbmh_play.exe', 'openbmh_cli.exe'} if windows else {'openbmh_play', 'openbmh_cli'}
|
||||
documents = {'README.md', 'LICENSE', 'THIRD_PARTY_NOTICES.md', 'ACKNOWLEDGEMENTS.md', 'CONTRIBUTING.md'}
|
||||
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',
|
||||
'RmlUi.txt', 'RmlUi-containers.txt', 'RmlUi-fonts.txt', 'RmlUi-Khronos.txt',
|
||||
'FreeType.txt', 'FreeType-FTL.txt', 'FreeType-BDF.txt', 'FreeType-PCF.txt', 'FreeType-zlib.txt',
|
||||
'nlohmann-json.txt', 'cpp-httplib.txt', 'SDL2_image.txt', 'stb-image.txt',
|
||||
'libwebp.txt', 'libwebp-PATENTS.txt', 'LunaSVG.txt', 'PlutoVG.txt', 'pugixml.txt'}
|
||||
launcher_assets = {'assets/launcher/' + name for name in
|
||||
('launcher.rml', 'theme.rcss', 'stadium.tga', 'LatoLatin-Regular.ttf', 'LatoLatin-Bold.ttf')}
|
||||
'SDL2.txt', 'miniz-source-notices.txt', 'miniz.txt', 'nativefiledialog-extended.txt'}
|
||||
present = set()
|
||||
for file in directory.rglob('*'):
|
||||
if not file.is_file():
|
||||
@@ -28,22 +22,18 @@ def validate(directory, windows):
|
||||
relative = file.relative_to(directory)
|
||||
present.add(relative.as_posix())
|
||||
allowed = (len(relative.parts) == 1 and file.name in products | documents)
|
||||
allowed |= relative.as_posix() in launcher_assets
|
||||
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))
|
||||
# Versioned OBW schemas are authored format documentation, not game data.
|
||||
allowed |= bool(re.fullmatch(r'docs/formats/obw/schema/[1-9][0-9]*\.[0-9]+/[a-z][a-z0-9_-]*\.json',
|
||||
relative.as_posix()))
|
||||
# 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 | launcher_assets | {'docs/licenses/' + name for name in licenses}
|
||||
required.add('docs/release/0.2/RELEASE_NOTES.md')
|
||||
required = products | documents | {'docs/licenses/' + name for name in licenses}
|
||||
required.add('docs/release/0.1/RELEASE_NOTES.md')
|
||||
if required - present:
|
||||
raise RuntimeError('Missing package entries: ' + ', '.join(sorted(required - present)))
|
||||
if windows and not {'vcruntime140.dll', 'msvcp140.dll'} <= present:
|
||||
|
||||
@@ -16,8 +16,6 @@ COMPONENTS = {
|
||||
'miniz': ('3.0.2', 'https://github.com/richgel999/miniz', ['miniz.c', 'miniz.h', 'LICENSE']),
|
||||
'lzma_sdk': ('24.09', 'https://github.com/ip7z/7zip', ['C/7zDec.c', 'C/7z.h', 'DOC/License.txt']),
|
||||
'nfd': ('v1.2.1', 'https://github.com/btzy/nativefiledialog-extended', ['CMakeLists.txt', 'src/nfd_cocoa.m', 'LICENSE']),
|
||||
'rmlui': ('6.3', 'https://github.com/mikke89/RmlUi', ['CMakeLists.txt', 'Include/RmlUi/Core.h', 'LICENSE.txt']),
|
||||
'freetype': ('VER-2-13-3', 'https://github.com/freetype/freetype', ['CMakeLists.txt', 'include/ft2build.h', 'LICENSE.TXT']),
|
||||
}
|
||||
# Verified against the archive SHA256 pinned in CMakeLists.txt. These are free
|
||||
# dependency source files, not game data. Refuse modified archive-cache inputs.
|
||||
@@ -34,26 +32,6 @@ def git(directory, *arguments):
|
||||
return subprocess.check_output(['git', '-C', str(directory), *arguments])
|
||||
|
||||
|
||||
def unbuilt_submodules(component, staged):
|
||||
"""Only FreeType's unused make/autotools logging dependency is omitted.
|
||||
|
||||
The pinned CMake font-engine target does not compile dlg. Every other
|
||||
submodule, or a changed revision, still needs explicit source packaging.
|
||||
"""
|
||||
excluded = {}
|
||||
for record in staged.split(b'\0'):
|
||||
if not record.startswith(b'160000 '):
|
||||
continue
|
||||
metadata, path = record.split(b'\t', 1)
|
||||
commit = metadata.split()[1].decode()
|
||||
name = path.decode()
|
||||
if (component != 'freetype' or name != 'subprojects/dlg' or
|
||||
commit != '72dfcc858c040c54a6a0b88fcb7e70ee186d3167'):
|
||||
raise RuntimeError('Dependency submodules require explicit packaging: ' + component)
|
||||
excluded[name] = commit
|
||||
return excluded
|
||||
|
||||
|
||||
def copy_files(source, destination, files, required=False, materialized_links=None):
|
||||
"""Copy only the explicit source inventory, materializing internal links.
|
||||
|
||||
@@ -186,16 +164,15 @@ def main():
|
||||
if not dependencies.get(name) or not all((directory / marker).is_file() for marker in markers):
|
||||
raise RuntimeError('Actual dependency source unavailable: ' + name)
|
||||
commit = None
|
||||
excluded = {}
|
||||
if (directory / '.git').exists():
|
||||
commit = git(directory, 'rev-parse', 'HEAD').decode().strip()
|
||||
tag = git(directory, 'rev-parse', reference + '^{commit}').decode().strip()
|
||||
if commit != tag or git(directory, 'status', '--porcelain', '--untracked-files=no').strip():
|
||||
raise RuntimeError('Dependency differs from its pinned source: ' + name)
|
||||
excluded = unbuilt_submodules(name, git(directory, 'ls-files', '--stage', '-z'))
|
||||
if git(directory, 'ls-files', '--stage').find(b'160000 ') != -1:
|
||||
raise RuntimeError('Dependency submodules require explicit packaging: ' + name)
|
||||
if commit:
|
||||
files = [Path(p.decode('utf-8')) for p in git(directory, 'ls-files', '-z').split(b'\0') if p]
|
||||
files = [p for p in files if p.as_posix() not in excluded]
|
||||
if name == 'lzma_sdk':
|
||||
files = [p for p in files if p.parts[0] == 'C' or p == Path('DOC/License.txt')]
|
||||
else:
|
||||
@@ -211,7 +188,6 @@ def main():
|
||||
materialized_links=dependency_links)
|
||||
manifest['dependencies'][name] = {'upstream': url, 'reference': reference,
|
||||
'commit': commit, 'files': hashes,
|
||||
'unbuilt_submodules': excluded,
|
||||
'materialized_links': dependency_links}
|
||||
initial_cache.append('set(FETCHCONTENT_SOURCE_DIR_' + name.upper() +
|
||||
' "${CMAKE_CURRENT_LIST_DIR}/dependencies/' + name + '" CACHE PATH "" FORCE)')
|
||||
|
||||
@@ -7,7 +7,6 @@ from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import dataclasses
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path, PurePosixPath
|
||||
import re
|
||||
@@ -27,7 +26,7 @@ ASSET_SUFFIXES = {
|
||||
".fbm", ".vga", ".blk", ".col", ".lbm", ".fnt", ".wap", ".ein", ".men", ".dat",
|
||||
".exe", ".dll", ".so", ".dylib", ".wav", ".mp3", ".ogg", ".flac",
|
||||
".avi", ".mov", ".mp4", ".png", ".jpg", ".jpeg", ".bmp", ".gif",
|
||||
".bin", ".zip", ".7z", ".dmg", ".tar", ".gz", ".pdf", ".tga",
|
||||
".bin", ".zip", ".7z", ".dmg", ".tar", ".gz", ".pdf",
|
||||
}
|
||||
PRIVATE_PREFIXES = (
|
||||
("data", "original"), ("docs", "manuals"), ("docs", "analyses"),
|
||||
@@ -41,155 +40,6 @@ PRIVATE_DOCUMENTS = {
|
||||
}
|
||||
SOURCE_SUFFIXES = {".cpp", ".hpp", ".h", ".c", ".inc"}
|
||||
SKIP_DIRECTORIES = {".git", "__pycache__", ".cache", "_deps", "node_modules"}
|
||||
# Exact independently generated artwork and synthetic native-editor captures.
|
||||
# The latter are reviewed against docs/qa/editor-poc/README.md; no game material.
|
||||
# Keep prior reviewed hashes if an asset is intentionally revised in history.
|
||||
PROJECT_ARTWORK = {
|
||||
"docs/qa/editor-dropdown-arrow/after-dropdown.png": {
|
||||
"5c89970a44ee114e5cf65b38d7972493fbc3ed125ff7a0e83c86a05b8a66be06",
|
||||
},
|
||||
"docs/qa/editor-dropdown-arrow/after-matchday-1440x900.png": {
|
||||
"c92fcdce42ea9b34e6e149e36ff49af57d15d863c0455fbd41dce0807d59d29b",
|
||||
},
|
||||
"docs/qa/editor-dropdown-arrow/after-midnight-1080x720.png": {
|
||||
"b32c186f678a11c1f7da13cbaed22ebcadf12fa6f1bd41c248b2d63a73a5bd3e",
|
||||
},
|
||||
"docs/qa/editor-dropdown-arrow/after-midnight-1440x900.png": {
|
||||
"ae8d8790e4c00ab09b98b1f1e3f1e22acd6a8103bf5104c4e0d690d6bf1cdcfd",
|
||||
},
|
||||
"docs/qa/editor-dropdown-arrow/after-midnight-2560x1600.png": {
|
||||
"ae3fc896f391cbfa2443a9c896a734e98564d0e260e5f60bb8ad0b2e39a97f38",
|
||||
"67283d8a4e9be4f779ef1482016059febbb6be7d94242b074bbafa6f1ce5e18f",
|
||||
},
|
||||
"docs/qa/editor-dropdown-arrow/after-silver-1440x900.png": {
|
||||
"ea6ee3852468ff684362fcc65b06fff0a1bcccd0190673185620e36b03f8dc6e",
|
||||
},
|
||||
"docs/qa/editor-dropdown-arrow/after-toolbar.png": {
|
||||
"ca1db2ddc6a4b764c9715f9f17c5d370906eb6668c7a0770f0d674efd5724a96",
|
||||
},
|
||||
"docs/qa/editor-dropdown-arrow/before-0.5.4.png": {
|
||||
"d642c323a4601d167c4b8f5f24549332889215de1dc98ff929f2beb9f5d69eaa",
|
||||
},
|
||||
"docs/qa/editor-navigation/before-options-0.5.3.png": {
|
||||
"493984e53b85c516a3a541ae879fdd18fdc7ec54a4d6478c571865bee15a9b44",
|
||||
},
|
||||
"docs/qa/editor-navigation/dropdown-matchday-de.png": {
|
||||
"594bdce386a91e2ef24fbab72d4910eed0899d8c108087b1cf00f9750e949b58",
|
||||
},
|
||||
"docs/qa/editor-navigation/dropdown-midnight-de.png": {
|
||||
"42cc11138163ce0a030c85fc5cb5c1204dbb7c05cfd7f8ef16cff8f6f6eeb422",
|
||||
},
|
||||
"docs/qa/editor-navigation/dropdown-silver-en.png": {
|
||||
"4ec9bf9a7af979c1c72f5cc6cd1b8a969f579a9680d8afc00837fff71da87a22",
|
||||
},
|
||||
"docs/qa/editor-navigation/history-midnight-de.png": {
|
||||
"7f141a6283ee946e17caa5d82a37503776133090fe86f82f0f9b2180b6444706",
|
||||
},
|
||||
"docs/qa/editor-navigation/options-midnight-de.png": {
|
||||
"3facf3da00290e5d39f0eeb210f657ae1040fce54f3e48e81529875e5d6f3fc9",
|
||||
},
|
||||
'docs/qa/editor-images/before-club-image.png': {
|
||||
'ac57bbbce2b8b7f71dad1d9e94d7b7baf182cb337d3800b5aac7a7f65db456bc',
|
||||
},
|
||||
'docs/qa/editor-images/linked-asset.png': {
|
||||
'76717df021e0c6db9a4afcab283923a20c2bf47d43f7e111303dca66041d3bf8',
|
||||
},
|
||||
'docs/qa/editor-images/preview-matchday-de.png': {
|
||||
'b7c0fad929fb28d25ef9e104e4ee90e62ab1d6e5ff8746bd0e8805bc2204d410',
|
||||
},
|
||||
'docs/qa/editor-images/preview-midnight-de.png': {
|
||||
'cc0ba1b7a1e4ea21f06fa9eb254a8b523da79bfa495a5068e345651619ab0407',
|
||||
},
|
||||
'docs/qa/editor-images/preview-silver-en.png': {
|
||||
'8704055293f58796b92057bc8a0c111b4db8bcaca297e45b7cb8d4bcacdd9a92',
|
||||
},
|
||||
"docs/qa/editor-regulations/before-competitions-0.5.1.png": {
|
||||
"cffa594e4d5ee942e086ab24fe7744a53dab4d5083dc1659f5e4b3ebdaee1f0b",
|
||||
},
|
||||
"docs/qa/editor-regulations/game-rules-midnight-de.png": {
|
||||
"b8778c35f4c94c327086198f765296698a401f4ef43029bb018e88c05fc7848f",
|
||||
},
|
||||
"docs/qa/editor-regulations/qualification-midnight-de.png": {
|
||||
"c1fa59f416db2ee56ac661b1c21101da645bc6d00ca2c1656438455a48b55295",
|
||||
},
|
||||
"docs/qa/editor-regulations/rules-matchday-de.png": {
|
||||
"45d09f05a7a4cf86bf465775f276c4f71790a053fa85a0e4bc42124d34702a34",
|
||||
},
|
||||
"docs/qa/editor-regulations/rules-midnight-de.png": {
|
||||
"f067fe69dd08c6f849fba3bae518727cc1252702494d077d2b7561c9aee3ed01",
|
||||
},
|
||||
"docs/qa/editor-regulations/rules-silver-en.png": {
|
||||
"e4e0f5269f23b4757b1bded384eb37857212236b626df7bc1352281f5eb5da1d",
|
||||
},
|
||||
"docs/qa/editor-comparison/before-players-0.5.0.png": {
|
||||
"e061cf1fcbafffc2950037f2f4bf24f28c00fe835988b56b198d88bce33b97e2",
|
||||
},
|
||||
"docs/qa/editor-comparison/players-midnight-de.png": {
|
||||
"ab1debb1e282d5462eab1a570137477884b2c773a900ec45a74783d50693367d",
|
||||
},
|
||||
"docs/qa/editor-comparison/teams-silver-en.png": {
|
||||
"ad8e8274f21465686b8c499ad44344ea4705cbec520560b12f8d7dde878204ea",
|
||||
},
|
||||
"docs/qa/editor-comparison/leagues-matchday-de.png": {
|
||||
"f24cd278b30ce3ccecc7320ae105ea5d0394e759c8045a76e75851259a487ada",
|
||||
},
|
||||
"docs/qa/editor-comparison/columns-midnight-de.png": {
|
||||
"74d825609b862c7dc60dc5182a32c010df73177b10d849079b02a2b4dc2d1620",
|
||||
},
|
||||
"docs/qa/editor-comparison/players-scroll-midnight-de.png": {
|
||||
"8e23a0fe6ea31ca6050fd5f157016948e0bad2f83093dcc3c53a3ba855c3bb40",
|
||||
},
|
||||
"docs/qa/editor-poc/clubs-midnight-de.png": {
|
||||
"2921aa67a870633c96f46328a82bc3022e5489b38d551c5314f13c7e59446070",
|
||||
"aa53e9cdd9ac8f6bf18b514862ac704ff9003bd1b62466cad2ebc329b09703dc",
|
||||
"ace9a5d491994592d4e87e8e1bce10af648a9c307645ace2f188c11d2b4f2fea",
|
||||
},
|
||||
"docs/qa/editor-poc/gui-search.png": {
|
||||
"48dc00d03c01d5bbec35683ff65672c12af4be6aecc8a84e5fece243c56643f4",
|
||||
"ef1780e91034dab96a7b23c638cdc8476f09be701b892f77e94e2fc2874cbd19",
|
||||
},
|
||||
"docs/qa/editor-poc/image-editor-midnight-de.png": {
|
||||
"44a89dfd84d7ee5b2acb54ae749e69051ae71ce192885dbe1a9311aba778c8ca",
|
||||
"eb01bd8fd8eaadfbc8e2b3f634bcdafbbb084dc4592d849e102a6f8c70ab0ad4",
|
||||
},
|
||||
"docs/qa/editor-poc/options-midnight-de.png": {
|
||||
"7075957db2d5f5a166bb71adb97d8208cb051a72b555202c212fae4f7e5c402c",
|
||||
"be483ad35a8912766611fd63dcc7cde6f820ed9a78441ad49554102a096633ab",
|
||||
},
|
||||
"docs/qa/editor-poc/players-silver-en.png": {
|
||||
"0d463d74a78072dda5b830c1d8c5e12d7e4588f6a743a95cc2ca4a327278928c",
|
||||
"d965a904663f3a30e5410f5d33539f6247737293625039fb9e3028337bbc088c",
|
||||
},
|
||||
"docs/qa/editor-poc/roster-matchday-de.png": {
|
||||
"547acb1b03ee68a3cee217fc5c96f4b960c64a5e48d1074e4f19045d98559647",
|
||||
"937829bb31b7452aa15d4a54cd03ad5de6a42d630b83cce279f22da09dfe180b",
|
||||
},
|
||||
"assets/launcher/stadium.tga": {
|
||||
"08f82783a357d5b0722f3737de54844150bc14d98036845f1aaee3211608e1c8",
|
||||
"fb8e5f1f86afe60de87b70a2f533690d1ef470241fa24ee4384ff000149edaab",
|
||||
"8bd89b7db8dbd0e92707240c5367cb92f8f32c2903e08157d0f278ac2599d6cf",
|
||||
},
|
||||
"docs/qa/editor-poc/clubs-silver-de.png": {
|
||||
"3e557f68bf8d0e8186dc237f9e92f6b9c7743d7df79fd29c3a5838ba01c116f2",
|
||||
"4f5dbe76b86097d306d2c982ce48093cce0fc95e9f35853493779b3116399239",
|
||||
},
|
||||
"docs/qa/editor-poc/options-silver-de.png": {
|
||||
"e406dca9058569f91fb314f0ff548ff349190c13ef1ed90c0051e44899634493",
|
||||
},
|
||||
"docs/qa/editor-poc/image-editor-silver-de.png": {
|
||||
"8d6ead6fd0e2fddc8e23de0a71abe519fa4f19ede0676823892d2568481bf68c",
|
||||
},
|
||||
"docs/qa/editor-poc/clubs-matchday-de.png": {
|
||||
"ddc5461068bdff4c0e3b468315cf03ef7cd203354941c586c030d3f3e80ae6ef",
|
||||
"e74d0b9acd07f6a48537616c28d74e53b8f69e20bb15fc3f6fcd0c10484b4f58",
|
||||
},
|
||||
"docs/qa/editor-poc/options-matchday-de.png": {
|
||||
"c0b2a8b936dccdcbac72169e2985ca91221ec605dd4ad96a624be23f225b608a",
|
||||
},
|
||||
"docs/qa/editor-poc/image-editor-matchday-de.png": {
|
||||
"e0f5fb9f986d01c27ce04da8bd8ac7623ee3b2afcbf8a8677c3580dcb0465c36",
|
||||
},
|
||||
}
|
||||
|
||||
LEGACY_SYMBOLS = re.compile(
|
||||
r"(?<![A-Za-z0-9])(?:" + "FUN" + r"_?[0-9a-f]{4,8}|" + "DAT" +
|
||||
@@ -200,8 +50,8 @@ LEGACY_SYMBOLS = re.compile(
|
||||
PRIVATE_TEXT = re.compile(
|
||||
r"(?:(?<![\w}./\\])/" + r"tools/|[A-Z]:[/\\]Users[/\\]|[A-Z]:[/\\]OpenBMH[/\\]|"
|
||||
r"docs/(?:analyses|agents)/|src/ui/(?:validation|reference)/|"
|
||||
+ "bmh" + r"-work|matter" + r"most|\bMich" + r"ael\b|"
|
||||
r"(?<![\w}./\\])/" + r"root/[^\s]+|https?://(?:10\.|192\.168\.|172\.(?:1[6-9]|2[0-9]|3[01])\.)|"
|
||||
+ "bmh" + r"-work|matter" + r"most|\bMich" + r"ael\b|\bDIA" +
|
||||
r"MOND\b|(?<![\w}./\\])/" + r"root/[^\s]+|https?://(?:10\.|192\.168\.|172\.(?:1[6-9]|2[0-9]|3[01])\.)|"
|
||||
r"github\.com/[^/\s]+/openbmh[_-]dc\b)",
|
||||
re.IGNORECASE,
|
||||
)
|
||||
@@ -306,7 +156,7 @@ def path_findings(name: str) -> list[Finding]:
|
||||
result = []
|
||||
if path.is_absolute() or ".." in parts:
|
||||
result.append(Finding(name, 0, "unsafe-path"))
|
||||
if path.suffix.lower() in ASSET_SUFFIXES and name not in PROJECT_ARTWORK:
|
||||
if path.suffix.lower() in ASSET_SUFFIXES:
|
||||
result.append(Finding(name, 0, "binary-or-game-asset"))
|
||||
if path.name in PRIVATE_DOCUMENTS or any(parts[:len(p)] == p for p in PRIVATE_PREFIXES):
|
||||
result.append(Finding(name, 0, "private-material-path"))
|
||||
@@ -317,10 +167,6 @@ def path_findings(name: str) -> list[Finding]:
|
||||
|
||||
def scan_blob(name: str, blob: bytes) -> list[Finding]:
|
||||
result = path_findings(name)
|
||||
if name in PROJECT_ARTWORK:
|
||||
if hashlib.sha256(blob).hexdigest() not in PROJECT_ARTWORK[name]:
|
||||
result.append(Finding(name, 0, "unreviewed-project-artwork"))
|
||||
return result
|
||||
if len(blob) > 2_000_000:
|
||||
result.append(Finding(name, 0, "oversized-source-file"))
|
||||
if b"\0" in blob:
|
||||
@@ -384,12 +230,11 @@ def scan_tree(root: Path):
|
||||
return findings, len(names)
|
||||
|
||||
|
||||
def scan_history(root: Path, revision=None):
|
||||
def scan_history(root: Path):
|
||||
findings = []
|
||||
references = subprocess.check_output(["git", "-C", str(root), "for-each-ref", "--format=%(refname)"])
|
||||
findings.extend(scan_blob("ref-names", references))
|
||||
selection = [revision] if revision else ["--all"]
|
||||
refs = subprocess.check_output(["git", "-C", str(root), "rev-list", *selection], text=True).splitlines()
|
||||
refs = subprocess.check_output(["git", "-C", str(root), "rev-list", "--all"], text=True).splitlines()
|
||||
seen = set()
|
||||
checked = 0
|
||||
for revision in refs:
|
||||
@@ -421,18 +266,15 @@ def main(argv=None):
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--root", type=Path, default=Path.cwd())
|
||||
parser.add_argument("--history", action="store_true", help="also check all reachable commits and their blobs")
|
||||
parser.add_argument("--revision", help="with --history, inspect this revision's ancestry instead of unrelated refs")
|
||||
parser.add_argument("--json", type=Path, help="write a report containing rule names and locations only")
|
||||
args = parser.parse_args(argv)
|
||||
if args.revision and (not args.history or args.revision.startswith('-')):
|
||||
parser.error("--revision requires --history and a revision, not an option")
|
||||
if args.history and shutil.which("git") is None:
|
||||
parser.error("Git is required for history checks")
|
||||
root = args.root.resolve(strict=True)
|
||||
findings, files = scan_tree(root)
|
||||
commits = blobs = 0
|
||||
if args.history:
|
||||
extra, commits, blobs = scan_history(root, args.revision)
|
||||
extra, commits, blobs = scan_history(root)
|
||||
findings.extend(extra)
|
||||
findings = sorted(set(findings))
|
||||
def display_path(name):
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
"""Synthetic checks for the source-distribution guard; no game input is used."""
|
||||
|
||||
import contextlib
|
||||
import hashlib
|
||||
import io
|
||||
import json
|
||||
from pathlib import Path
|
||||
@@ -18,22 +17,6 @@ import check_public_tree as guard
|
||||
|
||||
|
||||
class BlobChecks(unittest.TestCase):
|
||||
def test_only_exact_reviewed_project_artwork_is_accepted(self):
|
||||
name = "assets/launcher/synthetic.tga"
|
||||
payload = b"synthetic\0pixels"
|
||||
with mock.patch.dict(guard.PROJECT_ARTWORK, {name: {hashlib.sha256(payload).hexdigest()}}):
|
||||
self.assertEqual(guard.scan_blob(name, payload), [])
|
||||
rules = {f.rule for f in guard.scan_blob(name, payload + b"changed")}
|
||||
self.assertIn("unreviewed-project-artwork", rules)
|
||||
self.assertIn("binary-or-game-asset", self.rules("assets/other.tga", "unreviewed"))
|
||||
self.assertIn("binary-content", {f.rule for f in guard.scan_blob("other.tga", payload)})
|
||||
self.assertIn("binary-or-game-asset", self.rules(name, "unreviewed"))
|
||||
|
||||
def test_public_edition_name_is_not_private_provenance(self):
|
||||
edition = "DIA" + "MOND"
|
||||
self.assertNotIn("private-provenance", self.rules("docs/ENGINE_SPLIT.md", "a later " + edition + " release"))
|
||||
self.assertIn("private-provenance", self.rules("README.md", "/" + "tools/versions/" + edition))
|
||||
|
||||
def rules(self, name, text):
|
||||
return {finding.rule for finding in guard.scan_blob(name, text.encode())}
|
||||
|
||||
|
||||
Reference in new issue
Block a user