upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMoonEyes <ducoinbenjamin@yahoo.fr>2026-11-28 20:35:08 +0100
committerGitHub <noreply@github.com>2026-11-28 20:35:08 +0100
commitf459c7e0156356ea3a71b4ae3edcf6961a813d5c (patch)
tree0a4827eef0c3d407038c691eab21598e9dc53d0d /scripts
parente0a0e698915dc8b3fc9af19f965c1c7c0cb81f07 (diff)
parent4895588a9339dd906d73b2f27326e60ce6237482 (diff)
Merge pull request #1024 from djrolfes/djrolfes/check-game-data-explicit-paths
check_no_game_data: reject invalid explicit paths (CHECK-NO-GAME-DATA-EXPLICIT-PATHS)
Diffstat (limited to 'scripts')
-rw-r--r--scripts/check_no_game_data.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/scripts/check_no_game_data.py b/scripts/check_no_game_data.py
index 595fc7b1c..92097253c 100644
--- a/scripts/check_no_game_data.py
+++ b/scripts/check_no_game_data.py
@@ -3,6 +3,10 @@
3 python3 -I scripts/check_no_game_data.py # every file `git ls-files` lists 3 python3 -I scripts/check_no_game_data.py # every file `git ls-files` lists
4 python3 -I scripts/check_no_game_data.py PATH... # only these files 4 python3 -I scripts/check_no_game_data.py PATH... # only these files
5 5
6Explicit PATH inputs must be regular files, not directories or symlinks. A missing, unreadable or non-regular
7explicit input is reported on stderr and causes exit 2 unless another input matches game data (exit 1).
8Default git enumeration still skips symlinks, submodules and files deleted from the working tree.
9
6The extension check in .github/workflows/no-game-data.yml misses a renamed file: a DDS saved as .bin, an executable 10The extension check in .github/workflows/no-game-data.yml misses a renamed file: a DDS saved as .bin, an executable
7as .txt. This reads the first bytes of each file and matches the magic numbers of the package's formats and the 11as .txt. This reads the first bytes of each file and matches the magic numbers of the package's formats and the
8files the build extracts from it: RPF9 archives, TTPF texture pools, RAGE resources, XBCH/FSSM/DXBC shader 12files the build extracts from it: RPF9 archives, TTPF texture pools, RAGE resources, XBCH/FSSM/DXBC shader
@@ -25,10 +29,12 @@ exits 1 if there is any. It exits 2 when a file cannot be read or git cannot lis
25repository, or git not installed). Standard library only, no game files. 29repository, or git not installed). Standard library only, no game files.
26""" 30"""
27import bz2 31import bz2
32import errno
28import gzip 33import gzip
29import io 34import io
30import lzma 35import lzma
31import os 36import os
37import stat
32import subprocess 38import subprocess
33import sys 39import sys
34import tarfile 40import tarfile
@@ -274,15 +280,19 @@ def git_error(e):
274 return e.strerror or str(e) 280 return e.strerror or str(e)
275 281
276 282
277def check(paths, unreadable=None): 283def check(paths, unreadable=None, *, explicit=False):
278 """[(path, format)] for every regular file in `paths` that starts like game data. 284 """[(path, format)] for every regular file in `paths` that starts like game data.
279 285
280 A file that exists but cannot be opened or read is appended to `unreadable` (when given) as (path, error).""" 286 Files that cannot be opened or read are appended to `unreadable` (when given) as (path, error).
287 Explicit inputs also report missing paths and non-regular entries instead of silently skipping them."""
281 found = [] 288 found = []
282 for path in paths: 289 for path in paths:
283 if os.path.islink(path) or not os.path.isfile(path):
284 continue # submodules, symlinks, files deleted in the working tree
285 try: 290 try:
291 if explicit:
292 if not stat.S_ISREG(os.lstat(path).st_mode):
293 raise OSError(errno.EINVAL, "not a regular file", path)
294 elif os.path.islink(path) or not os.path.isfile(path):
295 continue # submodules, symlinks, files deleted in the working tree
286 name = classify_file(path) 296 name = classify_file(path)
287 except OSError as e: 297 except OSError as e:
288 if unreadable is not None: 298 if unreadable is not None:
@@ -311,7 +321,7 @@ def main(argv):
311 print(f"check_no_game_data: cannot list the tracked files with git: {git_error(e)}", file=sys.stderr) 321 print(f"check_no_game_data: cannot list the tracked files with git: {git_error(e)}", file=sys.stderr)
312 return 2 # not 1: that is the 'game data found' code 322 return 2 # not 1: that is the 'game data found' code
313 unreadable = [] 323 unreadable = []
314 found = check(paths, unreadable) 324 found = check(paths, unreadable, explicit=bool(argv))
315 for path, name in found: 325 for path, name in found:
316 print(f"{display(path)}: {name}") 326 print(f"{display(path)}: {name}")
317 for path, e in unreadable: 327 for path, e in unreadable: