fix: write a group's pack under the group's name

The RetroArch and Lakka pack was built under RetroArch's own name and
renamed afterwards, which overwrote then carried away a --platform
retroarch pack in the same directory, and failed on Windows where
os.rename refuses an existing target.
This commit is contained in:
Abdessamad Derraz committed 2026-10-17 01:58:15 +02:00
1 parent 29fb1a58e4
commit e26516fc0e
2 files changed
+37 -22

No files matched your search

+25 -22
View File
@@ -2427,6 +2427,30 @@ def _run_platform_packs(
)
print(f" Split into {len(zip_paths)} packs")
else:
# A group's pack is written under the group's name from
# the start: built under the representative's and then
# renamed, it overwrote and carried away a
# `--platform retroarch` pack already in the directory,
# and os.rename refused an existing target on Windows.
group_name = None
if aliases:
narrow_tags = "".join(
tag
for tag, _label in _narrowings(
source,
getattr(args, "regions", None),
args.target,
args.one_per_slot,
required_only,
)
)
stem = _platform_pack_stem(
group_platforms, representative, args.platforms_dir
)
group_name = (
f"{stem}{narrow_tags}_BIOS_Pack"
f"{_system_tag(system_filter)}.zip"
)
zip_path = generate_pack(
representative,
args.platforms_dir,
@@ -2445,29 +2469,8 @@ def _run_platform_packs(
target_name=args.target,
one_per_slot=args.one_per_slot,
offline=args.offline,
pack_name=group_name,
)
if not args.split and zip_path and aliases:
narrow_tags = "".join(
tag
for tag, _label in _narrowings(
source,
getattr(args, "regions", None),
args.target,
args.one_per_slot,
required_only,
)
)
stem = _platform_pack_stem(
group_platforms, representative, args.platforms_dir
)
combined = (
f"{stem}{narrow_tags}_BIOS_Pack"
f"{_system_tag(system_filter)}.zip"
)
new_path = os.path.join(os.path.dirname(zip_path), combined)
if new_path != zip_path:
os.rename(zip_path, new_path)
print(f" Renamed -> {os.path.basename(new_path)}")
except (FileNotFoundError, OSError, yaml.YAMLError) as e:
print(f" ERROR: {e}")
failed.append(representative)
+12
View File
@@ -2207,6 +2207,18 @@ class APackNameFitsAFileName(unittest.TestCase):
self.assertIn("pack_name=final_name", source)
class AGroupPackIsWrittenUnderItsOwnName(unittest.TestCase):
"""The RetroArch + Lakka pack was written as RetroArch_..._BIOS_Pack.zip
and renamed: a `--platform retroarch` pack already in the directory was
overwritten then carried away, and os.rename refuses an existing target
on Windows."""
def test_no_pack_is_renamed_after_its_build(self):
source = (ROOT / "scripts" / "generate_pack.py").read_text(encoding="utf-8")
self.assertNotIn("os.rename(", source)
self.assertIn("pack_name=group_name", source)
class TheDatabaseCacheIsWrittenWhole(unittest.TestCase):
"""A crash while serializing left a truncated db_cache.json behind, and
the next run rehashed the whole collection from scratch."""