From 000877689ffb492d675372dc10e71ad7dee6b329 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Thu, 5 Nov 2026 11:50:44 +0100 Subject: [PATCH] fix: name the split directory by the pack stem The prefix was assembled by hand and kept a '/' or ':' the full pack name makes safe (finding 17). --- scripts/generate_pack.py | 9 +++++---- tests/test_target_verify.py | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/scripts/generate_pack.py b/scripts/generate_pack.py index 9939aea38..8d9ba9a7e 100644 --- a/scripts/generate_pack.py +++ b/scripts/generate_pack.py @@ -1919,7 +1919,6 @@ def generate_split_packs( ) -> list[str]: """Generate split packs (one ZIP per system or manufacturer).""" config = load_platform_config(platform_name, platforms_dir) - platform_display = config.get("platform", platform_name) # The split directory carries the same tags as the packs inside it, or two # differently narrowed runs write into one another. split_tags = "".join( @@ -1935,9 +1934,11 @@ def generate_split_packs( # The parts carry the version, so the directory does too: a rescrape that # moves the version would otherwise leave the old parts beside the new # under one SHA256SUMS.txt. - version = config.get("version", config.get("dat_version", "")) - ver_tag = f"_{version.replace(' ', '')}" if version else "" - part_prefix = f"{platform_display.replace(' ', '_')}{ver_tag}{split_tags}" + # Named by the stem the full pack reads: assembled here by hand, a '/' in + # a version nested the directory where the check never looked for it. + part_prefix = ( + f"{_platform_pack_stem([platform_name], platform_name, platforms_dir)}{split_tags}" + ) split_dir = os.path.join(output_dir, f"{part_prefix}{group_tag}_Split") os.makedirs(split_dir, exist_ok=True) diff --git a/tests/test_target_verify.py b/tests/test_target_verify.py index a909b6d9d..ee42f854b 100644 --- a/tests/test_target_verify.py +++ b/tests/test_target_verify.py @@ -10,6 +10,7 @@ out of a targeted --all run, and the check refuses it as the build does. from __future__ import annotations +import os import sys import contextlib import io @@ -196,5 +197,29 @@ class APlatformWithoutTheSystemIsOutOfScope(unittest.TestCase): self.assertEqual(ctx.exception.code, 1) +class TheSplitDirectoryReadsThePackStem(unittest.TestCase): + """The split prefix was assembled by hand: a version 'release/1.22' made + 'RetroArch_release/1.22_Split', a nested directory the check never + found, beside a full pack named 'RetroArch_release-1.22_BIOS_Pack.zip'.""" + + def test_a_reserved_character_is_made_safe_as_in_the_full_pack(self): + from unittest import mock + + import generate_pack + + config = {"platform": "Foo: Bar", "version": "release/1.22", "systems": {}} + with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as out, \ + mock.patch.object(generate_pack, "load_platform_config", + return_value=config), \ + mock.patch.object(generate_pack, "_collect_emulator_extras", + return_value=[]): + generate_pack.generate_split_packs( + "foo", "platforms", {"files": {}}, "bios", out, emu_profiles={}, + ) + stem = generate_pack._platform_pack_stem(["foo"], "foo", "platforms") + self.assertEqual(os.listdir(out), [f"{stem}_Split"]) + self.assertEqual(stem, "Foo-_Bar_release-1.22") + + if __name__ == "__main__": unittest.main()