Skip to content

Import the console's original Lua files instead of shipping them - #2

Open
DefKorns wants to merge 5 commits into
development/avaloniafrom
feature/import-originals
Open

DefKorns wants to merge 5 commits into
development/avaloniafrom
feature/import-originals

Conversation

@DefKorns

@DefKorns DefKorns commented Nov 1, 2026

Copy link
Copy Markdown
Owner

Stacked on #1: it targets development/avalonia, so the diff is only this change. After #1 is merged, retarget it to master.

Why

The 613 Lua files under Lib/original are Nintendo's firmware scripts. The open source packages Nintendo publishes for the consoles (Linux, busybox, glibc, SDL2, LuaJIT...) contain no .lua file, so the license in Nintendo's OSS notice does not cover them, and they should not be in the repository or inside the executable. The user's own files also match their firmware version: the base-ui folder I checked has 11 more Lua files per console than the copies we shipped.

What

The app asks for the original Lua files once per console (a dialog opens the first time a console is clicked), like MiniThemeStudio does. Only the Lua files are read, never images, fonts or sounds:

  • From the console, over SSH (hakchi, 169.254.13.37 by default): the untouched /var/squashfs/<ui folder> first, then the live one; only the Lua files travel.
  • From a firmware file: squashfs / .hsqs (xz), .tar or .tar.gz.
  • From a folder: the console's UI folder, its resources folder, or a folder with several consoles side by side (takes the one named like the console).

Details:

  • Files are checked by their LuaJIT bytecode header (a decoded theme in text is refused) and by a file only that family of consoles has (colors_nes.lua, scripts/env/colors_*.lua, constants.lua for the Shonen Jump edition), so a NES is not imported as a SNES by mistake.
  • Everything is read into a staging folder first: a failed or cancelled import keeps the originals already there.
  • Kept in %AppData%/SNESMiniLuaCompiler/Originals (Linux: ~/.config/...).
  • Lib/original is removed (−3 MB in the executable); README and TODO updated.
  • New packages: LTRData.DiscUtils.SquashFs and SharpCompress (squashfs reading), both work with Native AOT.
  • Also: GitVersion.yml feature-branch regex had no BranchName group, so the Windows build of every feature/* branch failed with the version 2.1.0-{BranchName}.1.

Tests

  • CI: build, build-linux and pre-commit pass
  • 22 checks of the importer on Windows and Linux: squashfs/xz, tar, tar.gz, folders (whole tree, UI folder, resources folder), the user's six-console base-ui folder, other-console files refused, text Lua refused, a failed import keeps the originals, SSH (against a test host: only the Lua files come over, a missing folder, an unreachable host), an option-like address refused
  • The window: the dialog on the first click (Windows JIT and Native AOT, Linux), the error shown in the dialog, Cancel deselects the console, decode from imported originals (90 files)
  • Import from a real console or a real firmware: not done. The tests used a firmware image I built from the Famicom files and a test host. Check that the firmware keeps the Lua files in <ui folder>/resources/scripts (as MiniThemeStudio's registry implies)
  • Choosing a file or a folder through the system pickers (the importer is tested; the pickers are not automated)

The 613 Lua files under Lib/original are Nintendo's firmware scripts: they are not part of the open source
packages the company publishes, so they should not be in the repository or inside the executable.
The app now asks for them once per console, the way MiniThemeStudio does, and reads only the Lua files:

- from the console over SSH (hakchi): the untouched /var/squashfs/<ui folder> first, then the live one; only the
  Lua files travel (tar of find ... -name '*.lua')
- from a firmware file: a squashfs / .hsqs image (xz), a .tar or a .tar.gz
- from a folder: the console's UI folder, its resources folder, or anything above

Files are LuaJIT bytecode checked by their header (a decoded theme in text is refused), are read into a staging
folder first (a failed import keeps the originals already there) and are kept in %AppData%/SNESMiniLuaCompiler/Originals.
The dialog opens the first time a console is picked; cancelling deselects the console.

LTRData.DiscUtils.SquashFs and SharpCompress read the squashfs image; both work with Native AOT.
Lib/original is removed from the repository and the executable; the README explains the import.
…e console; fix GitVersion on feature branches

- A folder with the consoles side by side (a "base UI" folder: hvc, hvcj-shonen, nes, shvc, sneseur, snesusa) takes the
  one named like the console picked; with no match it asks for the console's own folder. A folder that is itself a
  console (or has its own resources folder) is used as is.
- Whatever the source, the files must be those of the console: a file only that family has (colors_nes.lua,
  scripts/env/colors_*.lua, constants.lua for the Shonen Jump edition) is required, and the Famicom refuses the
  Shonen Jump files, so a NES is not imported as a SNES by mistake.
- GitVersion.yml: the feature branch regex has the BranchName group its label uses; without it the version was
  "2.1.0-{BranchName}.1" and the Windows build of every feature/* branch failed to start.
… for them

A firmware image or a folder (a "base UI" folder with the consoles side by side) can hold the UI of several
consoles. The import now reads them all in one pass (a tar.gz is read once) and keeps every console whose files
are valid, so the app does not ask for the others later; the console the user asked for must be one of them.

- ConsoleTarget: the folder a console's files are collected in, what was found and why not
- A firmware: each console's UI folder is looked up (the NES and the Famicom share usr/share/clover-ui: their
  characteristic file tells them apart); a console the firmware lacks is skipped, unless it is the one asked for
- A folder with several consoles: each takes the folder named like it
- Staging folders as before: a failed import keeps every original already there; the window says how many
  consoles were kept
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant