Skip to content

Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.

Bundle zbic and require it in the dependency probe

v0lumehi9a4d167bb05e
diff --git a/.github/workflows/build-mac-app.yml b/.github/workflows/build-mac-app.yml
index d3e9b7b0..042c3e0f 100644
--- a/.github/workflows/build-mac-app.yml
+++ b/.github/workflows/build-mac-app.yml
@@ -105,7 +105,7 @@ jobs:
run: |
set -euo pipefail
# zstd, glslangValidator, spirv-cross and xcodegen run by their bundle paths with a PATH of /usr/bin:/bin; the Python imports
- # lz4, capstone, fontTools and nsz; no Mach-O file links into /opt/homebrew; the signature verifies.
+ # lz4, capstone, fontTools, zbic (system 22.0.0+ modules) and nsz, so a release without one of them fails here; no Mach-O file links into /opt/homebrew; the signature verifies.
tools/check_bundle.sh NX2Apple.app
codesign -v --deep --strict NX2Apple.app
diff --git a/BUILDING.md b/BUILDING.md
index d0cd7cd0..9b5d7811 100644
--- a/BUILDING.md
+++ b/BUILDING.md
@@ -11,7 +11,7 @@ git clone https://github.com/<you>/NX2Apple.git
cd NX2Apple
brew bundle --file=Brewfile # xcodegen, zstd, spirv-cross, glslang (the NSP script checks for it), .NET SDK
python3 -m venv .venv # Homebrew's Python refuses global pip installs (PEP 668)
-.venv/bin/python -m pip install lz4 capstone fonttools nsz "backports.zstd; python_version < '3.14'"
+.venv/bin/python -m pip install lz4 capstone fonttools zbic nsz "backports.zstd; python_version < '3.14'"
source .venv/bin/activate # so that python3 below is the venv's (in each new terminal)
```
diff --git a/BUILDING.zh-CN.md b/BUILDING.zh-CN.md
index f37e71aa..fb470380 100644
--- a/BUILDING.zh-CN.md
+++ b/BUILDING.zh-CN.md
@@ -12,7 +12,7 @@ git clone https://github.com/<you>/NX2Apple.git
cd NX2Apple
brew bundle --file=Brewfile # xcodegen, zstd, spirv-cross, glslang(打包脚本会检查它), .NET SDK
python3 -m venv .venv # Homebrew 的 Python 不允许全局 pip 安装(PEP 668)
-.venv/bin/python -m pip install lz4 capstone fonttools nsz "backports.zstd; python_version < '3.14'"
+.venv/bin/python -m pip install lz4 capstone fonttools zbic nsz "backports.zstd; python_version < '3.14'"
source .venv/bin/activate # 之后的 python3 即 venv 的(每个新终端都要执行)
```
diff --git a/frontend-qt/README.md b/frontend-qt/README.md
index 62cd6820..10d39cf8 100644
--- a/frontend-qt/README.md
+++ b/frontend-qt/README.md
@@ -117,7 +117,7 @@ Run this first if you prefer the command line. It lists what is missing and wher
python -m nspb_qt.win.doctor
```
-1. **Python 3.10+**, then `pip install PySide6 lz4 capstone fonttools pillow`
+1. **Python 3.10+**, then `pip install PySide6 lz4 capstone fonttools zbic pillow`
(and `backports.zstd` before Python 3.14).
2. **.NET SDK 10** — the app downloads it (the zip, not the installer: no administrator rights,
about 287 MB), or get it from <https://dotnet.microsoft.com/download/dotnet/10.0> (SDK, x64).
diff --git a/frontend-qt/nspb_qt/build_failure.py b/frontend-qt/nspb_qt/build_failure.py
index a5622231..bcbe1bc3 100644
--- a/frontend-qt/nspb_qt/build_failure.py
+++ b/frontend-qt/nspb_qt/build_failure.py
@@ -15,6 +15,7 @@ from dataclasses import dataclass
ROSETTA = 'rosetta'
TRANSLATOR = 'translator'
+ZBIC = 'zbic'
IOS_SDK = 'iosSDK'
CLT_SELECTED = 'cltSelected'
OTHER_METAL = 'otherMetal'
@@ -32,6 +33,7 @@ TABLE: list[tuple[str, str, str]] = [
('rosetta.intel', ROSETTA, r'is an Intel one running under Rosetta'),
('translator.run', TRANSLATOR, r'the shader translator does not run'),
('translator.start', TRANSLATOR, r'the shader translator does not start'),
+ ('zbic.missing', ZBIC, r'need the zbic package'),
('ios.sdk', IOS_SDK, r'the iOS SDK is not installed'),
('clt.selected', CLT_SELECTED, r'the selected developer folder is the Command Line Tools'),
('metal.other', OTHER_METAL, r'Metal compiler is not the one the shaders were tested with'),
@@ -52,7 +54,7 @@ OVERRIDE_FLAGS = {
DAMAGED_NSP: '--allow-damaged',
}
-KINDS = [ROSETTA, TRANSLATOR, IOS_SDK, CLT_SELECTED, OTHER_METAL, SHADER_REGRESSION, DAMAGED_NSP, A32_PROGRAM,
+KINDS = [ROSETTA, TRANSLATOR, ZBIC, IOS_SDK, CLT_SELECTED, OTHER_METAL, SHADER_REGRESSION, DAMAGED_NSP, A32_PROGRAM,
KEYS, SEVERAL_GAMES, NO_TITLE_ID, DISK_FULL]
# The Swift app has four more rows that no log line sets (a drive that is gone, a signing team, a device transfer):
# they belong to the Mac launcher's install on a device and to /Volumes, which this front end does not have.
diff --git a/frontend-qt/nspb_qt/localization.py b/frontend-qt/nspb_qt/localization.py
index d0fa8274..f23163db 100644
--- a/frontend-qt/nspb_qt/localization.py
+++ b/frontend-qt/nspb_qt/localization.py
@@ -718,6 +718,9 @@ TABLE: dict[str, tuple[str, str, str]] = {
'fail.translator.what': ('着色器翻译器无法运行,它需要适合这台 Mac 架构的 .NET 10 运行时。', "The shader translator does not run. It needs the .NET 10 runtime for this Mac's architecture.", "The shader translator does not run. It needs the .NET 10 runtime for this Mac's architecture."),
'fail.translator.next': ('用下面的按钮重新安装 .NET,然后再构建。如果环境变量 DOTNET_ROOT 指向了别的运行时,请取消设置。', 'Reinstall .NET with the button below, then build again. If DOTNET_ROOT names another runtime, unset it.', 'Reinstall .NET with the button below, then build again. If DOTNET_ROOT names another runtime, unset it.'),
'fail.translator.button': ('重新安装 .NET', 'Reinstall .NET', 'Reinstall .NET'),
+ 'fail.zbic.what': ("这个游戏的模块用了 Nintendo 的 zstd 变体压缩(系统 22.0.0 起),读取它需要 Python 包 zbic,而它没有安装。", "This game's modules use Nintendo's zstd variant (system 22.0.0 and later), and reading them needs the Python package zbic, which is not installed.", 'Spelets moduler använder Nintendos zstd-variant (system 22.0.0 och senare) och för att läsa dem behövs Python-paketet zbic, som inte är installerat.'),
+ 'fail.zbic.next': ('点下面的按钮安装 zbic,然后再构建。也可以在终端里运行 python3 -m pip install zbic,用的是构建所用的那个 Python。', 'Install zbic with the button below, then build again. Or run python3 -m pip install zbic in a terminal, with the Python the build uses.', 'Installera zbic med knappen nedan och bygg sedan igen. Eller kör python3 -m pip install zbic i en terminal, med den Python som bygget använder.'),
+ 'fail.zbic.button': ('安装 zbic', 'Install zbic', 'Installera zbic'),
'fail.iosSDK.what': ('没有安装 iOS SDK,构建 iPhone 版本需要它。', 'The iOS SDK is not installed. An iPhone build needs it.', 'The iOS SDK is not installed. An iPhone build needs it.'),
'fail.iosSDK.next': ('打开 Xcode → 设置 → 组件,安装 iOS,或者点下面的按钮运行 xcodebuild -downloadPlatform iOS。', 'Open Xcode → Settings → Components and install iOS, or press the button to run xcodebuild -downloadPlatform iOS.', 'Open Xcode → Settings → Components and install iOS, or press the button to run xcodebuild -downloadPlatform iOS.'),
'fail.iosSDK.button': ('下载 iOS 平台', 'Download iOS platform', 'Download iOS platform'),
diff --git a/frontend-qt/nspb_qt/model.py b/frontend-qt/nspb_qt/model.py
index 3871095a..54e4eabe 100644
--- a/frontend-qt/nspb_qt/model.py
+++ b/frontend-qt/nspb_qt/model.py
@@ -227,7 +227,7 @@ class Model(QObject):
return Dep('python', 'dep.python', 'dep.python.hint', DepState.MISSING,
f'dep.python.missing:{py} ({py_ver})',
install=[py, '-m', 'pip', 'install', 'lz4', 'capstone', 'fonttools',
- 'backports.zstd', 'nsz'])
+ 'zbic', 'backports.zstd', 'nsz'])
if pu.IS_WIN:
return Dep('python', 'dep.python', 'dep.python.hint', DepState.MISSING,
f'dep.python.none:{py or "python3"}',
@@ -877,9 +877,9 @@ class Model(QObject):
self.log('venv creation failed\n')
return False
ver = pu._ver_tuple(pu._python_version(vpy))
- pkgs = ['lz4', 'capstone', 'fonttools', 'nsz']
+ pkgs = ['lz4', 'capstone', 'fonttools', 'zbic', 'nsz']
if ver < (3, 14):
- pkgs.insert(3, 'backports.zstd')
+ pkgs.insert(4, 'backports.zstd')
self.log(f'$ {vpy} -m pip install {" ".join(pkgs)}\n')
try:
p = subprocess.Popen([vpy, '-m', 'pip', 'install'] + pkgs, stdout=subprocess.PIPE,
@@ -1183,6 +1183,10 @@ class Model(QObject):
row = next((d for d in self.deps if d.id == 'dotnet'), None)
if row:
self.install_dep(row)
+ elif f.kind == bf.ZBIC:
+ # the python row's own fix (a venv with the packages, zbic among them): the row may read OK, so the command is built here
+ self.install_dep(Dep('python', 'dep.python', 'dep.python.hint', DepState.MISSING,
+ install=[self.python_path, '-m', 'pip', 'install', 'zbic']))
elif f.kind == bf.IOS_SDK and not pu.IS_WIN:
self.install_dep(Dep('xcode', 'dep.xcode', 'dep.xcode.hint', DepState.MISSING,
install=['/usr/bin/xcodebuild', '-downloadPlatform', 'iOS']))
diff --git a/frontend-qt/nspb_qt/platform_util.py b/frontend-qt/nspb_qt/platform_util.py
index bd121477..2ac85cd9 100644
--- a/frontend-qt/nspb_qt/platform_util.py
+++ b/frontend-qt/nspb_qt/platform_util.py
@@ -131,12 +131,12 @@ def python_candidates(extra_candidates: list[str] | None = None) -> list[str]:
def find_python(extra_candidates: list[str] | None = None) -> tuple[str, bool, str]:
"""The interpreter to build with: (path, has_packages, version_or_empty).
- The build scripts need lz4, capstone, fontTools, zstd and (for compressed dumps) nsz. A
+ The build scripts need lz4, capstone, fontTools, zbic, zstd and (for compressed dumps) nsz. A
system interpreter rarely has them, so the venv the app manages is checked first, then
every python on the machine (see python_candidates for the order).
"""
probe = (
- "import lz4, capstone, fontTools\n"
+ "import lz4, capstone, fontTools, zbic\n"
"try:\n"
" from compression import zstd\n"
"except ImportError:\n"
diff --git a/frontend-qt/nspb_qt/ui.py b/frontend-qt/nspb_qt/ui.py
index e2c3deeb..5beea0ad 100644
--- a/frontend-qt/nspb_qt/ui.py
+++ b/frontend-qt/nspb_qt/ui.py
@@ -352,7 +352,7 @@ class MainWindow(QMainWindow):
self.failure_box.hide()
outer.addWidget(self.failure_box)
- _FIX_BUTTONS = {'translator': 'fail.translator.button', 'iosSDK': 'fail.iosSDK.button',
+ _FIX_BUTTONS = {'translator': 'fail.translator.button', 'zbic': 'fail.zbic.button', 'iosSDK': 'fail.iosSDK.button',
'keys': 'fail.keys.button', 'severalGames': 'fail.showFolder', 'noTitleID': 'fail.showFolder',
'diskFull': 'fail.showFolder'}
diff --git a/frontend-qt/nspb_qt/win/fetch.py b/frontend-qt/nspb_qt/win/fetch.py
index 3014969b..55c449ac 100644
--- a/frontend-qt/nspb_qt/win/fetch.py
+++ b/frontend-qt/nspb_qt/win/fetch.py
@@ -384,7 +384,7 @@ def install_python(dest: Path | None = None,
survives app updates like every other tool the app fetches.
`Include_pip=1` matters: the interpreter alone is not enough, the build needs lz4, capstone,
- fonttools and nsz, and the front end installs those into a venv made from this interpreter.
+ fonttools, zbic and nsz, and the front end installs those into a venv made from this interpreter.
The bootstrapper blocks until the install finishes, so the caller can probe the result.
"""
log = log or (lambda s: None)
diff --git a/frontend-qt/tests/test_build_failure_hints.py b/frontend-qt/tests/test_build_failure_hints.py
index 006de102..5879a626 100644
--- a/frontend-qt/tests/test_build_failure_hints.py
+++ b/frontend-qt/tests/test_build_failure_hints.py
@@ -119,6 +119,20 @@ class Rows(unittest.TestCase):
self.assertIn(key, TABLE)
self.assertTrue(TABLE[key][2] and TABLE[key][2] != TABLE[key][1], key) # Swedish present
+ def test_a_missing_zbic_package_is_its_own_row(self):
+ log = '[3/9] extract\n' + fixture('zbic.missing')['text'] + '\n'
+ self.assertEqual(bf.classify(log).kind, bf.ZBIC)
+ self.assertEqual(bf.classify('[RED] the zbic package decoded it').kind, bf.UNKNOWN)
+ self.assertIn('pip install zbic', TABLE['fail.zbic.next'][1])
+ self.assertIn('zbic', TABLE['fail.zbic.button'][1])
+
+ def test_the_python_probe_and_the_venv_install_name_zbic(self):
+ pkg = ROOT / 'frontend-qt/nspb_qt'
+ self.assertIn('import lz4, capstone, fontTools, zbic', (pkg / 'platform_util.py').read_text(encoding='utf-8'))
+ model = (pkg / 'model.py').read_text(encoding='utf-8')
+ self.assertIn("pkgs = ['lz4', 'capstone', 'fonttools', 'zbic', 'nsz']", model)
+ self.assertIn("'zbic', 'backports.zstd', 'nsz'", model)
+
@unittest.skipIf(importlib.util.find_spec('PySide6') is None, 'PySide6 is not installed')
def test_show_folder_opens_the_game_folder_and_for_a_full_disk_the_build_folder(self):
import tempfile
diff --git a/frontend/README.md b/frontend/README.md
index 24a37320..0355230e 100644
--- a/frontend/README.md
+++ b/frontend/README.md
@@ -255,7 +255,7 @@ A GUI app does not inherit the shell's PATH. On a machine where a terminal sees
actually are (`~/.dotnet`, `/usr/local/share/dotnet`, the Python framework
installs), verifies `.NET` with `--list-sdks` (the extractor targets `net10.0`),
and picks the first interpreter that can really import
-`lz4 capstone fontTools backports.zstd`. That same interpreter then runs the
+`lz4 capstone fontTools zbic backports.zstd`. That same interpreter then runs the
build.
The interpreters uv installs (`uv python install`) count as well: they live in
@@ -269,7 +269,7 @@ found, **Install** creates the app's venv from the newest one that does run at
The release app (`NX2Apple.app`) carries `zstd`, `glslangValidator`, `spirv-cross`, `xcodegen` (in
`Contents/Resources/tools/bin`) and a relocatable CPython 3.13 with `lz4 capstone fonttools
-backports.zstd nsz` (`Contents/Resources/python`), so a player needs no Homebrew and no Python.
+zbic backports.zstd nsz` (`Contents/Resources/python`), so a player needs no Homebrew and no Python.
`tools/bundle_tools.sh` fills them in during the release workflow (pinned versions and sha256 of the
sources, built for macOS 13 with static libraries, and the Python packages come from
`tools/bundled-python-requirements.txt`) and `tools/check_bundle.sh` runs each tool from the bundle
diff --git a/frontend/Sources/NSPortBuilder/BuildFailure.swift b/frontend/Sources/NSPortBuilder/BuildFailure.swift
index 7498b526..a64e683f 100644
--- a/frontend/Sources/NSPortBuilder/BuildFailure.swift
+++ b/frontend/Sources/NSPortBuilder/BuildFailure.swift
@@ -5,7 +5,7 @@ import Foundation
/// the log, cut to 200 characters. The classifier reads the whole log tail, because for a damaged NSP the
/// last line is only "nx_extract exit code 3" and the message is a few lines above it.
enum BuildFailureKind: String, CaseIterable {
- case rosetta, translator, iosSDK, cltSelected, otherMetal, shaderRegression, damagedNSP, a32Program
+ case rosetta, translator, zbic, iosSDK, cltSelected, otherMetal, shaderRegression, damagedNSP, a32Program
/// The inputs: the keys file, the game folder, a drive that is gone.
case keys, severalGames, noTitleID, driveMissing
/// The build's and the install's own steps.
@@ -46,6 +46,7 @@ enum BuildFailureClassifier {
("rosetta.intel", .rosetta, "is an Intel one running under Rosetta"),
("translator.run", .translator, "the shader translator does not run"),
("translator.start", .translator, "the shader translator does not start"),
+ ("zbic.missing", .zbic, "need the zbic package"),
("ios.sdk", .iosSDK, "the iOS SDK is not installed"),
("clt.selected", .cltSelected, "the selected developer folder is the Command Line Tools"),
("metal.other", .otherMetal, "Metal compiler is not the one the shaders were tested with"),
diff --git a/frontend/Sources/NSPortBuilder/BuildFailureView.swift b/frontend/Sources/NSPortBuilder/BuildFailureView.swift
index fe97188f..f0865f68 100644
--- a/frontend/Sources/NSPortBuilder/BuildFailureView.swift
+++ b/frontend/Sources/NSPortBuilder/BuildFailureView.swift
@@ -37,6 +37,8 @@ struct BuildFailureCard: View {
switch kind {
case .translator:
fix(kind, "fail.translator.button")
+ case .zbic:
+ fix(kind, "fail.zbic.button")
case .iosSDK:
fix(kind, "fail.iosSDK.button")
case .cltSelected:
diff --git a/frontend/Sources/NSPortBuilder/BundledTools.swift b/frontend/Sources/NSPortBuilder/BundledTools.swift
index c6fdf72f..a858ec2f 100644
--- a/frontend/Sources/NSPortBuilder/BundledTools.swift
+++ b/frontend/Sources/NSPortBuilder/BundledTools.swift
@@ -3,7 +3,7 @@ import Foundation
/// The build tools and the Python that the release app carries in Contents/Resources (frontend/tools/bundle_tools.sh fills them in):
///
/// tools/bin zstd, glslangValidator, spirv-cross, xcodegen
-/// python/ a relocatable CPython with lz4, capstone, fontTools and nsz installed
+/// python/ a relocatable CPython with lz4, capstone, fontTools, zbic and nsz installed
///
/// Every function takes the resources folder as a parameter (the tests pass a fake bundle) and defaults to this app's own. There is
/// none under `swift run` or in a build that predates the bundle, and each function then answers nil, so everything else behaves as
diff --git a/frontend/Sources/NSPortBuilder/ContentView.swift b/frontend/Sources/NSPortBuilder/ContentView.swift
index f72a1cc5..3a57b6eb 100644
--- a/frontend/Sources/NSPortBuilder/ContentView.swift
+++ b/frontend/Sources/NSPortBuilder/ContentView.swift
@@ -1424,6 +1424,8 @@ final class BuildModel: ObservableObject {
if let xcode = Self.installedXcode() {
installDep(Dep(id: "xcode", name: "dep.xcode", hint: "dep.xcode.hint", present: false, installCmd: Self.selectXcodeCmd(xcode)))
}
+ case .zbic:
+ if let d = deps.first(where: { $0.id == "python" }) { installDep(d) } // the venv install, which now names zbic
case .keys:
if let chooseKeys { chooseKeys() } else { pickFiles(kind: .keys) } // the same picker as the keys row
case .severalGames, .noTitleID, .diskFull:
@@ -1457,8 +1459,9 @@ final class BuildModel: ObservableObject {
/// Whether the card's fix button is already running its command.
func fixBusy(_ kind: BuildFailureKind) -> Bool {
- guard [.translator, .iosSDK, .cltSelected].contains(kind) else { return false }
- return deps.first { $0.id == (kind == .translator ? "dotnet" : "xcode") }?.installing ?? false
+ guard [.translator, .iosSDK, .cltSelected, .zbic].contains(kind) else { return false }
+ let id = kind == .translator ? "dotnet" : kind == .zbic ? "python" : "xcode"
+ return deps.first { $0.id == id }?.installing ?? false
}
/// (file count, bytes) of a RomFS tree — the reuse fingerprint's content part.
@@ -2285,7 +2288,7 @@ final class BuildModel: ObservableObject {
paths.first { FileManager.default.isExecutableFile(atPath: $0) }
}
- /// The Python that actually has lz4/capstone/fontTools/backports.zstd — the one
+ /// The Python that actually has lz4/capstone/fontTools/zbic/backports.zstd — the one
/// the build must run under, not whatever /usr/bin/python3 happens to be.
/// The minimum the build scripts need. /usr/bin/python3 is 3.9 on a stock Mac and has none of
/// the packages; picking it made a build fail with a syntax error deep inside the script
@@ -2308,15 +2311,17 @@ final class BuildModel: ObservableObject {
("glslang", "glslangValidator", "dep.glslang"),
]
- /// The interpreter probe: lz4 / capstone / fontTools always, and zstd from either source —
+ /// The interpreter probe: lz4 / capstone / fontTools / zbic always, and zstd from either source —
/// `compression.zstd` is built in from Python 3.14 and `backports.zstd` (which declares
/// Python < 3.14) is the only option before that. Requiring the backport unconditionally
/// rejected an otherwise working Homebrew Python 3.15 (issue #1).
+ /// zbic is required although only a game with system 22.0.0+ modules (ZBIC segments, Nintendo's zstd variant) needs it:
+ /// the launcher cannot know that before the extraction, and the build stops late without it (issue #251).
/// nsz is deliberately not required here: it is only needed for NSZ / XCZ dumps, and the
/// pipeline says so by name when one shows up. The venv installs it anyway so that a player
/// who downloads a compressed dump never meets that error.
nonisolated static let importProbe = """
- import lz4, capstone, fontTools
+ import lz4, capstone, fontTools, zbic
try:
from compression import zstd
except ImportError:
@@ -2363,8 +2368,8 @@ final class BuildModel: ObservableObject {
/// nsz is always installed: NSZ / XCZ dumps are accepted by the pipeline now, and a player who
/// downloads one should not have to run pip by hand (it is a few hundred KB).
nonisolated static func pipPackages(_ version: (Int, Int)) -> [String] {
- version < (3, 14) ? ["lz4", "capstone", "fonttools", "backports.zstd", "nsz"]
- : ["lz4", "capstone", "fonttools", "nsz"]
+ version < (3, 14) ? ["lz4", "capstone", "fonttools", "zbic", "backports.zstd", "nsz"]
+ : ["lz4", "capstone", "fonttools", "zbic", "nsz"]
}
/// Create the venv (reusing an existing one) and install the packages into it. Returns the
@@ -2781,7 +2786,7 @@ final class BuildModel: ObservableObject {
let pyDetail = pythonDetail(py: py, ok: pyOK)
out.append(Dep(id: "python", name: "dep.python", hint: "dep.python.hint",
present: pyOK, detail: pyDetail,
- installCmd: [py, "-m", "pip", "install", "--user", "lz4", "capstone", "fonttools", "backports.zstd"]))
+ installCmd: [py, "-m", "pip", "install", "--user", "lz4", "capstone", "fonttools", "zbic", "backports.zstd"]))
return out
}
diff --git a/frontend/Sources/NSPortBuilder/Localization.swift b/frontend/Sources/NSPortBuilder/Localization.swift
index cc2957a1..ab34aeac 100644
--- a/frontend/Sources/NSPortBuilder/Localization.swift
+++ b/frontend/Sources/NSPortBuilder/Localization.swift
@@ -780,7 +780,7 @@ enum L10n {
"dep.phase.download": ("下载", "Download"),
"dep.phase.unpack": ("解压", "Unpack"),
"dep.python": ("Python + 包", "Python + packages"),
- "dep.python.hint": ("lz4 capstone fonttools backports.zstd", "lz4 capstone fonttools backports.zstd"),
+ "dep.python.hint": ("lz4 capstone fonttools zbic backports.zstd", "lz4 capstone fonttools zbic backports.zstd"),
"dep.fix.brewOwner": ("Homebrew 的目录属于其他用户,安装写不进去:在终端运行 sudo chown -R $(whoami) /opt/homebrew,然后重新安装。",
"Homebrew's folder belongs to another user, so nothing can be installed: run sudo chown -R $(whoami) /opt/homebrew in Terminal, then install again."),
"dep.fix.brewMissing": ("没装 Homebrew:从 brew.sh 安装(安装程序会要你的密码),再点「重新检测」。",
@@ -870,6 +870,12 @@ enum L10n {
"Reinstall .NET with the button below, then build again. If DOTNET_ROOT names another runtime, unset it."),
"fail.translator.button": ("重新安装 .NET",
"Reinstall .NET"),
+ "fail.zbic.what": ("这个游戏的模块用了 Nintendo 的 zstd 变体压缩(系统 22.0.0 起),读取它需要 Python 包 zbic,而它没有安装。",
+ "This game's modules use Nintendo's zstd variant (system 22.0.0 and later), and reading them needs the Python package zbic, which is not installed."),
+ "fail.zbic.next": ("点下面的按钮安装 zbic,然后再构建。也可以在终端里运行 python3 -m pip install zbic,用的是构建所用的那个 Python。",
+ "Install zbic with the button below, then build again. Or run python3 -m pip install zbic in a terminal, with the Python the build uses."),
+ "fail.zbic.button": ("安装 zbic",
+ "Install zbic"),
"fail.iosSDK.what": ("没有安装 iOS SDK,构建 iPhone 版本需要它。",
"The iOS SDK is not installed. An iPhone build needs it."),
"fail.iosSDK.next": ("打开 Xcode → 设置 → 组件,安装 iOS,或者点下面的按钮运行 xcodebuild -downloadPlatform iOS。",
@@ -1525,7 +1531,7 @@ enum L10n {
"dep.phase.download": "Hämta",
"dep.phase.unpack": "Packa upp",
"dep.python": "Python + paket",
- "dep.python.hint": "lz4 capstone fonttools backports.zstd",
+ "dep.python.hint": "lz4 capstone fonttools zbic backports.zstd",
"dep.python.missing": "%@ saknar paket",
"dep.install.begin": "Installerar %@ …",
"dep.install.fail": "Installationen misslyckades: %@ (se loggen)",
@@ -1708,6 +1714,9 @@ enum L10n {
"section.tools": "Byggverktyg",
"section.app": "App",
"build.setup": "Slutför inställningen",
+ "fail.zbic.what": "Spelets moduler använder Nintendos zstd-variant (system 22.0.0 och senare) och för att läsa dem behövs Python-paketet zbic, som inte är installerat.",
+ "fail.zbic.next": "Installera zbic med knappen nedan och bygg sedan igen. Eller kör python3 -m pip install zbic i en terminal, med den Python som bygget använder.",
+ "fail.zbic.button": "Installera zbic",
"fail.keys.what": "Nyckelfilen hittades inte eller går inte att läsa.",
"fail.keys.next": "Välj din prod.keys igen. Ligger den på en extern disk ansluter du disken först. Bygg sedan igen.",
"fail.keys.button": "Välj nyckelfil",
diff --git a/frontend/Tests/Fixtures/build_failures.json b/frontend/Tests/Fixtures/build_failures.json
index 7ff1a6ca..c41fc0a4 100644
--- a/frontend/Tests/Fixtures/build_failures.json
+++ b/frontend/Tests/Fixtures/build_failures.json
@@ -20,6 +20,13 @@
"fragment": "the shader translator does not start (",
"text": "[RED] the shader translator does not start ([Errno 8] Exec format error: '/r/dm/gfx/tools/dmsh_xlate_bin'): /r/dm/gfx/tools/dmsh_xlate_bin"
},
+ {
+ "id": "zbic.missing",
+ "kind": "zbic",
+ "source": "dm/tools/nso.py",
+ "fragment": "need the zbic package",
+ "text": "[RED] text segment: ZBIC (zstd) segments need the zbic package (python3 -m pip install zbic)"
+ },
{
"id": "ios.sdk",
"kind": "iosSDK",
diff --git a/frontend/Tests/NSPortBuilderTests/BuildFailureRowsTests.swift b/frontend/Tests/NSPortBuilderTests/BuildFailureRowsTests.swift
index bec2c714..10e865f6 100644
--- a/frontend/Tests/NSPortBuilderTests/BuildFailureRowsTests.swift
+++ b/frontend/Tests/NSPortBuilderTests/BuildFailureRowsTests.swift
@@ -38,6 +38,19 @@ final class BuildFailureRowsTests: XCTestCase {
XCTAssertEqual(BuildFailureClassifier.classify("[RED] the iOS SDK is not installed", inputs: inputs).kind, .iosSDK, "a known stop keeps its own row")
}
+ func testAMissingZbicPackageIsItsOwnRowWithAnInstallButton() throws {
+ let log = "[3/9] extract\n" + (try fixture("zbic.missing").text) + "\n"
+ XCTAssertEqual(BuildFailureClassifier.classify(log).kind, .zbic)
+ XCTAssertEqual(BuildFailureClassifier.classify("[RED] the zbic package decoded it").kind, .unknown)
+ XCTAssertTrue(L10n.table["fail.zbic.next"]?.en.contains("pip install zbic") ?? false)
+ XCTAssertEqual(L10n.table["fail.zbic.button"]?.en, "Install zbic")
+ let m = BuildModel()
+ m.logTail = log
+ m.noteFailure()
+ XCTAssertEqual(m.failure?.kind, .zbic)
+ XCTAssertFalse(m.fixBusy(.zbic))
+ }
+
func testSeveralGamesAndNoTitleID() throws {
XCTAssertEqual(BuildFailureClassifier.classify(try fixture("games.several").text).kind, .severalGames)
let none = try fixture("games.noTitleID")
diff --git a/frontend/Tests/NSPortBuilderTests/BundledToolsTests.swift b/frontend/Tests/NSPortBuilderTests/BundledToolsTests.swift
index 1ab8843e..4fb8b5ee 100644
--- a/frontend/Tests/NSPortBuilderTests/BundledToolsTests.swift
+++ b/frontend/Tests/NSPortBuilderTests/BundledToolsTests.swift
@@ -209,6 +209,32 @@ final class BundledToolsTests: XCTestCase {
XCTAssertNotEqual(next.path, bundled)
}
+ // ---- the interpreter probe ----
+
+ func testTheProbeRequiresZbicAndThePipPackagesInstallIt() {
+ XCTAssertTrue(BuildModel.importProbe.contains("zbic"))
+ for v in [(3, 12), (3, 13), (3, 14), (3, 15)] { XCTAssertTrue(BuildModel.pipPackages(v).contains("zbic"), "\(v)") }
+ }
+
+ func testAPythonWithoutZbicFailsTheProbe() throws {
+ let py = "/usr/bin/python3"
+ try XCTSkipUnless(FileManager.default.isExecutableFile(atPath: py))
+ let dir = FileManager.default.temporaryDirectory.appendingPathComponent("nspb-probe-" + UUID().uuidString)
+ defer { try? FileManager.default.removeItem(at: dir) }
+ for pkg in ["lz4", "capstone", "fontTools", "backports", "compression"] {
+ try FileManager.default.createDirectory(at: dir.appendingPathComponent(pkg), withIntermediateDirectories: true)
+ try Data().write(to: dir.appendingPathComponent(pkg + "/__init__.py"))
+ }
+ try Data().write(to: dir.appendingPathComponent("backports/zstd.py"))
+ try Data().write(to: dir.appendingPathComponent("compression/zstd.py"))
+ let old = ProcessInfo.processInfo.environment["PYTHONPATH"]
+ setenv("PYTHONPATH", dir.path, 1)
+ defer { if let old { setenv("PYTHONPATH", old, 1) } else { unsetenv("PYTHONPATH") } }
+ XCTAssertFalse(BuildModel.importsOK(py), "zbic is missing")
+ try Data().write(to: dir.appendingPathComponent("zbic.py"))
+ XCTAssertTrue(BuildModel.importsOK(py), "everything the probe names is there")
+ }
+
// ---- the pinned packages ----
func testBundledPackagePinsCoverThePipPackages() throws {
diff --git a/frontend/tools/bundle_tools.sh b/frontend/tools/bundle_tools.sh
index 788e8e77..1014bc88 100755
--- a/frontend/tools/bundle_tools.sh
+++ b/frontend/tools/bundle_tools.sh
@@ -127,7 +127,7 @@ for d in "$SITE/site-packages/"*.dist-info; do
find "$d" -maxdepth 2 \( -iname 'LICEN[SC]E*' -o -iname 'COPYING*' -o -iname 'NOTICE*' \) -type f -exec cp {} "$LIC/python-packages/$n/" \;
done
"$PY" -I - <<'PYEOF'
-import lz4.block, capstone, fontTools, nsz, ssl, sqlite3, zlib, lzma, bz2
+import lz4.block, capstone, fontTools, zbic, nsz, ssl, sqlite3, zlib, lzma, bz2
try: from compression import zstd
except ImportError: from backports import zstd
PYEOF
diff --git a/frontend/tools/bundled-python-requirements.txt b/frontend/tools/bundled-python-requirements.txt
index f0f2300c..af1107e9 100644
--- a/frontend/tools/bundled-python-requirements.txt
+++ b/frontend/tools/bundled-python-requirements.txt
@@ -1,10 +1,11 @@
# The Python packages bundled into the launcher (bundle_tools.sh installs them with --only-binary into the bundled CPython).
-# The first five are what BuildModel.pipPackages names (BundledToolsTests keeps them equal); backports.zstd is for Python before 3.14 and
+# The first six are what BuildModel.pipPackages names (BundledToolsTests keeps them equal); backports.zstd is for Python before 3.14 and
# the bundled one is 3.13. The rest are what nsz needs, pinned as resolved on 2026-10-28 (pip freeze of a clean install).
backports.zstd==1.8.0
capstone==5.0.9
fonttools==4.68.0
lz4==4.4.5
+zbic==1.0.1.post1
nsz==5.0.0
blessed==1.52.0
enlighten==1.14.1
diff --git a/frontend/tools/check_bundle.sh b/frontend/tools/check_bundle.sh
index 36944982..7d4dd85c 100755
--- a/frontend/tools/check_bundle.sh
+++ b/frontend/tools/check_bundle.sh
@@ -20,8 +20,8 @@ for t in zstd glslangValidator spirv-cross xcodegen; do
p=$(env -i PATH="$T:/usr/bin:/bin" /usr/bin/which "$t") && [ "$p" = "$T/$t" ] && ok "PATH finds $t in the bundle" || bad "PATH finds $t at '$p'"
done
PY="$RES/python/bin/python3"
-v=$(clean "$PY" -I -c "import sys, lz4.block, capstone, fontTools, nsz; from compression import zstd" 2>&1 \
- || clean "$PY" -I -c "import lz4.block, capstone, fontTools, nsz; from backports import zstd" 2>&1) && ok "python imports lz4, capstone, fontTools, nsz, zstd" || bad "python imports: $v"
+v=$(clean "$PY" -I -c "import sys, lz4.block, capstone, fontTools, zbic, nsz; from compression import zstd" 2>&1 \
+ || clean "$PY" -I -c "import lz4.block, capstone, fontTools, zbic, nsz; from backports import zstd" 2>&1) && ok "python imports lz4, capstone, fontTools, zbic, nsz, zstd" || bad "python imports: $v"
v=$(clean "$PY" -I -c "import sys; print(sys.version.split()[0], sys.prefix)" 2>&1); echo "$v" | grep -q "$RES/python" && ok "python runs from the bundle: $v" || bad "python prefix is not the bundle: $v"
# load paths: only the system's (a library's or extension's own install name is not a dependency)