Skip to content

The Mac app pack ignores the AppleDouble files of an exFAT drive - #991

Closed
lucaszhongsj wants to merge 1 commit into
seedds:mainfrom
lucaszhongsj:mac-app-exfat-pack
Closed

lucaszhongsj wants to merge 1 commit into
seedds:mainfrom
lucaszhongsj:mac-app-exfat-pack

Conversation

@lucaszhongsj

Copy link
Copy Markdown
Contributor

What and why

pack_app.py breaks when the build folder or the app is on exFAT or FAT, which is what an external drive gives you when the internal one cannot hold an 8 GB RomFS and a 19 GB app per game.

Such a file system has no extended attributes, so macOS keeps each file's attributes in an AppleDouble file ._<name> beside it. That is the same thing #476 met in scan_nsps and #555 in the shader build, and the pack trips over it three times:

  • selected_inputs globs take ._main.patched.bin and ._<key>_b.metallib for modules and shaders, so the build stops with no rewriter fixups for …/._main.patched.bin or no input file at …/._<key>_b.metallib;
  • shutil.copy2 of the host cannot set the copy's flags (chflags: Operation not permitted), and cp -R carries a folder's sidecars into the bundle, where DMModuleFiles lists them;
  • codesign reads Contents/MacOS/._nxnative as a nested code object that is not signed and refuses the whole bundle (code object is not signed at all), which is the report that reads like a broken launcher build.

The change skips those names in the input globs, copies without extended attributes (-X where cp copies, shutil.copy for the host), and strips what a copy or the compiler leaves from the staged bundle before codesign reads it, retrying once with the attributes cleared when it still refuses one, and once more after signing, because signing sets an attribute on what it signs. On APFS nothing changes: no sidecar exists there and both passes are a stat walk over the staged tree.

The finding is in docs/reference/packing.md, under "External drives", and docs_symptoms.py was run.

The same change is carried in NX2Apple as a patch for now, with LNPANDY/NX2Apple#486 and LNPANDY/NX2Apple#487 as the report and the fork-side pull request.

Checked

  • Tests: dm/tools/tests/test_nsp_mac_app.py — 45 tests pass on this branch, including the new test_finder_detritus_is_not_an_input_and_never_reaches_the_bundle, which puts a ._ file in every input folder and checks that it is not selected, does not reach the bundle and is not in DMModuleFiles. python3 dm/tools/docs_symptoms.py reports 717 symptoms and its only change is the new line.
  • Games run, with title ID and version: none played. The pack step is the one under test: The Legend of Zelda: Echoes of Wisdom, 01008CF01BAAC000, update 1.1.0 (v196608), packed on an exFAT USB volume. Before the change the step stops at no input file at …/._1785f88868f76e74_b.metallib, after it the same inputs pack, sign ad hoc, and the bundle passes codesign --verify --strict with no ._ file left in it.
  • Devices and OS: MacBook Pro 18,3 (M1 Pro), macOS 27.2. The three failures were also reproduced on an exFAT disk image (hdiutil create -fs ExFAT) with stand-in inputs, where the script without the change stops in each of the three places and the one with it succeeds.
  • Not checked: an iPhone target (the pack is the Mac app step only), and scripts/regress.py — no chain tool, no host code and no tool every game uses is touched, so nothing under the shader chain changes.

Docs

  • The finding is in its docs/reference/packing.md entry, and python3 dm/tools/docs_symptoms.py was run (the symptom index)
  • A chain tool changed: dmsh_chain.py --header was run and dm/gfx/nvn/dmsh_chain.h is part of the change
  • No game files, keys or data extracted from a game in the change or the attachments

With the build folder or the app on an exFAT or FAT drive, pack_app.py took
"._name" files for modules and shaders ("no input file at
.../._<key>_b.metallib", "no rewriter fixups for .../._main.patched.bin"),
copy2 could not set the copy's flags ("chflags: Operation not permitted"),
and codesign read "Contents/MacOS/._nxnative" as a nested code object that
is not signed, which failed the whole bundle.

Such a file system keeps each file's attributes in a "._name" file beside
it. The input globs now skip those names, the copies carry no attributes
("-X" where cp copies, and shutil.copy for the host), and the staged
bundle is stripped before codesign reads it, again after "xattr -cr" when
it still refuses one, and once more after signing, which creates one by
itself.

Checked on an exFAT disk image made with "hdiutil create -fs ExFAT": the
same inputs pack, sign and pass "codesign --verify --strict", and the
script without the change stops in each of the three places.
dm/tools/tests/test_nsp_mac_app.py covers a "._" file in every input
folder, out of the selection, out of the bundle and out of DMModuleFiles.
lucaszhongsj added a commit to lucaszhongsj/NX2Apple that referenced this pull request Nov 2, 2026
Dino0005 pushed a commit to Dino0005/NX2Apple that referenced this pull request Nov 2, 2026
@github-actions github-actions Bot added packing Building an IPA or a Mac app: the NSP script, extraction, the shader split, the packers mac The Mac front end and app (dm/mac, front_mac.m) tools Tools and scripts (dm/tools, scripts) docs Documentation labels Nov 3, 2026
Marceloalexandregoncalves pushed a commit to Marceloalexandregoncalves/nxnative that referenced this pull request Nov 3, 2026
On a volume without native extended attributes (exFAT, the build folder or
the output on an external drive) each file's attributes live in a "._name"
file beside it, which breaks the pack four ways: the input globs take those
names for modules, shaders and fonts and the fixups check fails on one,
copystat cannot set the flags of a copy (chflags: Operation not permitted),
a recursive copy carries the sidecars into the app, and codesign reads the
one beside the launcher as a code object that is not signed and refuses the
whole bundle: "code object is not signed at all", In subcomponent.

Skip them in the globs, copy without extended attributes (-X, cp rejects
it together with -c) and with shutil.copy instead of copy2 for the host,
and strip what a copy or the compiler leaves from the staged bundle before
codesign reads it, retrying with the attributes cleared if it refuses one.
Strip again afterwards: codesign sets an attribute on what it signs.

Upstream-Status: forwarded seedds#991
Reason: a build folder or an app on exFAT keeps every file's attributes in a ._name file beside it: the inputs, the copies and codesign all break on them (issue seedds#486)
Issue: LNPANDY/NX2Apple#486
seedds added a commit that referenced this pull request Nov 3, 2026
… inputs skip "._name" files, copies leave extended attributes out, and the bundle is stripped of them before codesign reads it (#991)

Co-authored-by: lucaszhongsj <[email protected]>
@seedds

seedds commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Landed on main as 998896a, with you credited as co-author. test_nsp_mac_app passes (45 tests) along with the docs tests. Thanks!

@seedds seedds closed this Nov 3, 2026
Know-It-All-Brother pushed a commit to Know-It-All-Brother/nxnative that referenced this pull request Nov 9, 2026
… inputs skip "._name" files, copies leave extended attributes out, and the bundle is stripped of them before codesign reads it (seedds#991)

Co-authored-by: lucaszhongsj <[email protected]>
@lucaszhongsj
lucaszhongsj deleted the mac-app-exfat-pack branch November 16, 2026 06:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation mac The Mac front end and app (dm/mac, front_mac.m) packing Building an IPA or a Mac app: the NSP script, extraction, the shader split, the packers tools Tools and scripts (dm/tools, scripts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants