#!/usr/bin/env python3 """ Test PS3 Update Application with Ace Combat: Assault Horizon This game has 8 compatibility packs in the NoPayStation database. """ import sys from pathlib import Path import shutil import subprocess # Add ROM Groomer to path sys.path.insert(0, str(Path(__file__).parent.parent / 'rom-groomer-python' / 'src')) from romgroomer.stages.apply_ps3_updates import ApplyPS3UpdatesStage from romgroomer.stages.base import StageContext def main(): """Test update application.""" # Paths source_game = Path("/data/emu/ps3netsrv/GAMES/Ace Combat - Assault Horizon (USA) (En,Fr,Es).ps3") test_game = Path("/tmp/Ace Combat - Assault Horizon (USA) (Test - No Updates).ps3") nps_database = "/data/emu/source/nopaystation/PS3_DLCS.tsv" pkg_archive = "/data/emu/source/nopaystation/downloads-ps3-dlc" pkg2zip_path = "/data/emu/rom-groomer-python/tools/bin/pkg2zip" print("=" * 70) print("Ace Combat: Assault Horizon Update/DLC Test") print("=" * 70) print() # Check source if not source_game.exists(): print(f"Error: Source game not found: {source_game}") return 1 # Remove old test if exists if test_game.exists(): print(f"Removing old test copy...") shutil.rmtree(test_game) # Create test copy print("Creating test copy...") print(f" Source: {source_game.name}") print(f" Test: {test_game.name}") shutil.copytree(source_game, test_game) print(" ✓ Copied") print() # Remove existing PS3_UPDATE folder to simulate base game update_folder = test_game / 'PS3_UPDATE' if update_folder.exists(): print("Removing existing PS3_UPDATE folder...") shutil.rmtree(update_folder) print(" ✓ Removed (simulating base game)") else: print("No PS3_UPDATE folder found (base game)") print() # Show BEFORE state print("=" * 70) print("BEFORE: Test Game State") print("=" * 70) for item in sorted(test_game.iterdir()): if item.is_file(): size = item.stat().st_size print(f" {item.name} ({size:,} bytes)") elif item.is_dir(): count = sum(1 for _ in item.rglob('*')) size = sum(f.stat().st_size for f in item.rglob('*') if f.is_file()) print(f" {item.name}/ ({count} items, {size:,} bytes)") print() # Run update stage print("=" * 70) print("Running ApplyPS3UpdatesStage...") print("=" * 70) stage = ApplyPS3UpdatesStage( nps_database=nps_database, pkg_archive=pkg_archive, pkg2zip_path=pkg2zip_path, apply_updates=True, apply_dlc=False ) context = StageContext( platform_name="ps3", platform_config={}, # Dummy config for testing target_name="test", source_dir=Path("/tmp"), work_dir=Path("/tmp"), output_dir=Path("/tmp/output") ) result = stage.execute(context) print() # Show AFTER state print("=" * 70) print("AFTER: Test Game State") print("=" * 70) for item in sorted(test_game.iterdir()): if item.is_file(): size = item.stat().st_size print(f" {item.name} ({size:,} bytes)") elif item.is_dir(): count = sum(1 for _ in item.rglob('*')) size = sum(f.stat().st_size for f in item.rglob('*') if f.is_file()) print(f" {item.name}/ ({count} items, {size:,} bytes)") print() # Show PS3_UPDATE contents if it exists if update_folder.exists(): print("=" * 70) print("PS3_UPDATE folder contents:") print("=" * 70) for item in sorted(update_folder.rglob('*')): if item.is_file(): rel_path = item.relative_to(update_folder) size = item.stat().st_size print(f" {rel_path} ({size:,} bytes)") print() else: print("⚠ No PS3_UPDATE folder created") print() print("=" * 70) print("Test Complete!") print("=" * 70) print() print("You can now see both versions in WebMAN:") print(f" Original: {source_game.name}") print(f" Test: {test_game.name}") print() print("The test version should now have updates applied.") print() return 0 if __name__ == '__main__': sys.exit(main())