PSAR: let the caller pick which PSP model to unpack for

An updater carries one file list per hardware revision, and which one you
resolve names against decides both what a file is called and whether it's part
of that model's firmware at all. That was hardcoded to "first list that names
it", which is right for extracting everything but wrong for reproducing what a
particular console would have installed.

PSARUnpackOptions::model takes a PSPModelGeneration now, and the lists are kept
per model rather than merged. Any (the default) keeps the old behaviour;
anything else uses only that model's list and skips what it doesn't name.
--unpack-updater-model on headless takes "01g".."12g" or "any".

On the 6.61 updater: any gives 411 files, 03g gives 330 with 81 belonging to
other models, 01g gives 313 with 98. The difference is what it should be - 03g
has the _03g.prx variants and arib.pgf, 01g has neither.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9
This commit is contained in:
Henrik RydgårdandClaude Opus 5 committed 2026-08-20 22:50:01 +02:00
1 parent d8481eab79
commit a58f54ba53
6 files changed
+131 -19

No files matched your search

+8 -2
View File
@@ -623,14 +623,20 @@ int main(int argc, const char* argv[]) {
PSARUnpackOptions unpackOptions;
unpackOptions.verbose = testOptions.verbose;
if (cmdLineOptions.unpackUpdaterModel.has_value() &&
!PSPModelGenerationFromString(cmdLineOptions.unpackUpdaterModel.value(), &unpackOptions.model)) {
fprintf(stderr, "Unknown PSP model '%s' - expected 01g..12g or any\n", cmdLineOptions.unpackUpdaterModel.value().c_str());
return 1;
}
PSARUnpackStats stats;
std::string unpackError;
const bool ok = UnpackUpdaterPBP(Path(cmdLineOptions.bootFilenames[0]), Path(cmdLineOptions.unpackUpdater.value()), unpackOptions, &stats, &unpackError);
if (!ok) {
fprintf(stderr, "Unpacking failed: %s\n", unpackError.c_str());
}
printf("Firmware %s: %d entries, %d files written, %d directories, %d unresolved names, %d failed\n",
stats.firmwareVersion.c_str(), stats.entries, stats.written, stats.directories, stats.unnamed, stats.failed);
printf("Firmware %s (model %s): %d entries, %d files written, %d directories, %d unresolved names, %d for other models, %d failed\n",
stats.firmwareVersion.c_str(), PSPModelGenerationToString(unpackOptions.model), stats.entries, stats.written,
stats.directories, stats.unnamed, stats.otherModel, stats.failed);
printf("Compression: none=%d zlib=%d KL4E=%d KL3E=%d LZR=%d unknown=%d\n",
stats.compressionCounts[(int)PSARCompression::None],
stats.compressionCounts[(int)PSARCompression::Zlib],