Repository navigation
feat(tools): add a Zig CPK tool that needs no .NET - #73
Merged
Merged
Conversation
tools/cpk lists and extracts CPK archives straight from the ISO or a loose mod.cpk, and checks --io-trace reads, as one executable. Inputs are community files: every offset is checked, and output paths are validated before the first write. experiments/cpk-check stays as the oracle. On Windows stdout goes through WriteFile: the Zig 0.17.1 file writers panic when an asynchronous Git Bash pipe fills up. Verified on ULUS-10512 against CriFsV2Lib: 6,198 files listed the same and extracted byte-identical, same check-trace verdict on the 20M replay and on a trace with a changed hash. tools/cpk/check.py: 18/18 CLI tests, including 250 damaged archives. Linux: cross-build only, run by CI.
endercodezz
disabled auto-merge
November 6, 2026 14:43
zig fmt needs LF, so tools/cpk gets the eol=lf rule of tools/bindiff for Windows checkouts. The CLI tests decoded output strictly: a damaged name is not valid UTF-8, which only showed on Linux. Verified: tools/cpk/check.py passes locally, CI reruns both platforms.
Verified: CI job CPK tool passes on ubuntu-24.04 and windows-2022.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
New
tools/cpk(Zig 0.17.1, host only): one executable for CPK inspection, with no .NET SDK or NuGet restore.list <iso> <cpk path> [substring]orlist <file.cpk> [substring]: directory, name, offset, stored and extracted size, compressed flag.extract ... <out dir>: files under their CPK directories, with CRILAYLA decompression. All output paths are checked before the first write;.., absolute paths and names unsafe on Windows stop the extraction.check-trace <iso> <io-trace.csv> [prefix=hostdir ...]: the cpk-check verification of--io-tracereads.experiments/cpk-checkstays as the independent oracle. CI gets aCPK tooljob on Linux and Windows, like BinDiff. It is not a required check.tools/cpk/check.py --downloadreuses BinDiff's pinned, hash-checked Zig download.Verification
Against CriFsV2Lib on the local ULUS-10512 ISO:
listofumd0.cpkandumd1.cpkextract, all files, not a samplecheck-traceon the 20M replaycpk reads=40 header/toc=4 file_matched=36 mismatched=0 unclassified=0 non_cpk=2493check-tracewith one hash changedMISMATCHline,mismatched=1, exit 1python tools/cpk/check.py: format check, Debug and safe unit tests, 18/18 CLI tests on synthetic fixtures (stored and CRILAYLA files, masked tables, an ISO, path traversal, truncated tables, 250 damaged archives throughlistandextract: exit 0 or 2, never a panic).Found while testing
list | anythingfrom Git Bash panicked once the pipe filled: those pipes are asynchronous, and the writers treatPENDINGasunreachable. stdout now goes throughWriteFileon Windows. Python's pipes are synchronous, so the regression test builds an overlapped pipe; the build before the fix fails it with exit 3.list. Reading each file's magic made one coldlisttake 33 s, against 0.13 s warm [INFERRED: seeks across the image, seen once]. The flag now comes from the TOC, which gives the same 5,018 files.extractstill decides by the magic.tools/bindiffhad the same panic: #74, fixed in #75.Not verified
mod.cpkfiles: only the game's two archives and synthetic fixtures so far (Mods on the 3DS: verify fan translations, add texture replacement #23).NoToc, not read.Closes #65