MAME torrent history tracker (scraper + history viewer + systemd units)
  • TypeScript 95.2%
  • Shell 3.1%
  • Dockerfile 0.8%
  • JavaScript 0.5%
  • CSS 0.3%
  • Other 0.1%
Find a file
2026-08-30 16:42:04 +00:00
.gitea/workflows Show which build you are looking at, in the tab bar 2026-08-05 20:32:18 +00:00
demo Ship a sample manifest so the emulator checklist renders in a bare container 2026-08-05 20:22:18 +00:00
docs/superpowers Plan: CHD layering, honest installed state, selection and plan routes 2026-08-05 11:21:39 +00:00
web Say which system a machine belongs to, and filter by it 2026-08-08 11:48:55 -04:00
.containerignore Containerise: in-process copy jobs, filesystem destination, Containerfile 2026-08-05 13:41:09 +00:00
.gitignore Split: remove the build side, fetch catalogs instead 2026-08-05 13:34:36 +00:00
app-config.test.ts Let another service change the config, and say where the file is 2026-08-06 10:30:30 +00:00
app-config.ts Let another service change the config, and say where the file is 2026-08-06 10:30:30 +00:00
artwork-fetch.test.ts Leave bezels to the module that has a user interface 2026-08-07 17:11:36 -04:00
artwork-fetch.ts Actually fetch the wheels 2026-08-07 19:13:25 -04:00
ARTWORK.md Leave bezels to the module that has a user interface 2026-08-07 17:11:36 -04:00
bios-deps.test.ts Fetch the BIOS a game needs, not all 634 MB of them 2026-08-07 21:36:41 -04:00
bios-deps.ts Fetch the BIOS a game needs, not all 634 MB of them 2026-08-07 21:36:41 -04:00
bun.lock MAME tracker (Bun/TS): scraper, Deluge integration, ROM datfiles, web UI 2026-07-26 06:46:45 +00:00
cabinet-config.test.ts Say when the package list is sample data instead of a cabinet's own 2026-08-05 20:49:37 +00:00
cabinet-config.ts Say when the package list is sample data instead of a cabinet's own 2026-08-05 20:49:37 +00:00
catalog-fetch.ts Split: remove the build side, fetch catalogs instead 2026-08-05 13:34:36 +00:00
catalog.ts Split: remove the build side, fetch catalogs instead 2026-08-05 13:34:36 +00:00
Containerfile Put unzip in the image, or wheels can never work 2026-08-07 19:33:28 -04:00
deluge-web.ts Take torrent URLs, and per-system sources 2026-08-08 11:45:48 -04:00
DELUGE_USER_SETUP.md MAME tracker (Bun/TS): scraper, Deluge integration, ROM datfiles, web UI 2026-07-26 06:46:45 +00:00
download-progress.test.ts Finish the job, and stop leaving a 634 MB torrent behind 2026-08-08 08:11:35 -04:00
download-progress.ts Finish the job, and stop leaving a 634 MB torrent behind 2026-08-08 08:11:35 -04:00
emulator-config.test.ts Let the cabinet's emulators be configured from here 2026-08-06 07:37:50 -04:00
emulator-config.ts Let the cabinet's emulators be configured from here 2026-08-06 07:37:50 -04:00
fetch-artwork.sh Leave bezels to the module that has a user interface 2026-08-07 17:11:36 -04:00
install-services.sh MAME tracker (Bun/TS): scraper, Deluge integration, ROM datfiles, web UI 2026-07-26 06:46:45 +00:00
installed-live.test.ts Show a game as installed the moment it is 2026-08-07 19:43:15 -04:00
installed-live.ts Show a game as installed the moment it is 2026-08-07 19:43:15 -04:00
installed-manifest.test.ts Record installed games in the repository, and fetch them back 2026-08-07 15:54:07 -04:00
installed-manifest.ts Record installed games in the repository, and fetch them back 2026-08-07 15:54:07 -04:00
mame-datfile.test.ts ROM selector: stream the datfile without loading it 2026-08-05 10:26:43 +00:00
mame-datfile.ts ROM selector: stream the datfile without loading it 2026-08-05 10:26:43 +00:00
mame-monitor.service MAME tracker (Bun/TS): scraper, Deluge integration, ROM datfiles, web UI 2026-07-26 06:46:45 +00:00
mame-monitor.timer MAME tracker (Bun/TS): scraper, Deluge integration, ROM datfiles, web UI 2026-07-26 06:46:45 +00:00
mame-scraper.service MAME tracker (Bun/TS): scraper, Deluge integration, ROM datfiles, web UI 2026-07-26 06:46:45 +00:00
mame-scraper.timer MAME tracker (Bun/TS): scraper, Deluge integration, ROM datfiles, web UI 2026-07-26 06:46:45 +00:00
mame-web.service Point the bare-metal unit at the sample manifest 2026-08-05 16:42:27 -04:00
mnt-mame.mount MAME tracker (Bun/TS): scraper, Deluge integration, ROM datfiles, web UI 2026-07-26 06:46:45 +00:00
monitor-cli.ts MAME tracker (Bun/TS): scraper, Deluge integration, ROM datfiles, web UI 2026-07-26 06:46:45 +00:00
monitor-deluge.ts Remove a torrent this cabinet is done with, whatever "done" meant 2026-08-08 10:22:34 -04:00
package.json Show which build you are looking at, in the tab bar 2026-08-05 20:32:18 +00:00
post-scrape.ts A cabinet with no torrent history yet is not a failed refresh 2026-08-30 12:42:03 -04:00
postcss.config.js MAME tracker (Bun/TS): scraper, Deluge integration, ROM datfiles, web UI 2026-07-26 06:46:45 +00:00
README.md Let the destination be the ROM directory itself 2026-08-06 09:57:23 -04:00
refresh-cli.ts MAME tracker (Bun/TS): scraper, Deluge integration, ROM datfiles, web UI 2026-07-26 06:46:45 +00:00
rom-config.test.ts ROM selector: env-driven path config 2026-08-05 10:22:02 +00:00
rom-config.ts Let the destination be the ROM directory itself 2026-08-06 09:57:23 -04:00
rom-copy-progress.test.ts ROM selector: copy executor as a transient systemd unit 2026-08-05 12:12:45 +00:00
rom-copy.test.ts ROM selector: count disk images in selection size 2026-08-05 11:56:28 +00:00
rom-copy.ts Actually fetch the wheels 2026-08-07 19:13:25 -04:00
rom-datfile.ts MAME tracker (Bun/TS): scraper, Deluge integration, ROM datfiles, web UI 2026-07-26 06:46:45 +00:00
rom-deps.test.ts ROM selector: resolve a game's CHD through its parent 2026-08-05 11:11:48 +00:00
rom-deps.ts ROM selector: resolve a game's CHD through its parent 2026-08-05 11:11:48 +00:00
rom-dest-write.test.ts ROM selector: copy executor as a transient systemd unit 2026-08-05 12:12:45 +00:00
rom-dest.test.ts Let the destination be the ROM directory itself 2026-08-06 09:57:23 -04:00
rom-dest.ts Let the destination be the ROM directory itself 2026-08-06 09:57:23 -04:00
rom-download.test.ts Take torrent URLs, and per-system sources 2026-08-08 11:45:48 -04:00
rom-download.ts Take torrent URLs, and per-system sources 2026-08-08 11:45:48 -04:00
rom-index-job.test.ts ROM selector: background index build with status 2026-08-05 10:37:29 +00:00
rom-index-job.ts Keep the ROM sources in the repository, not the image 2026-08-08 11:52:27 -04:00
rom-index.test.ts ROM selector: merge datfile, catalog and ownership into one index 2026-08-05 10:33:51 +00:00
rom-index.ts Say which system a machine belongs to, and filter by it 2026-08-08 11:48:55 -04:00
rom-layers.test.ts ROM selector: CHD layering, and record whether the cabinet was checked 2026-08-05 11:24:52 +00:00
rom-layers.ts ROM selector: CHD layering, and record whether the cabinet was checked 2026-08-05 11:24:52 +00:00
rom-place.test.ts Remove a torrent this cabinet is done with, whatever "done" meant 2026-08-08 10:22:34 -04:00
rom-place.ts Remove a torrent this cabinet is done with, whatever "done" meant 2026-08-08 10:22:34 -04:00
rom-query.test.ts Say which system a machine belongs to, and filter by it 2026-08-08 11:48:55 -04:00
rom-query.ts Say which system a machine belongs to, and filter by it 2026-08-08 11:48:55 -04:00
rom-selection.test.ts ROM selector: named selections with .romsel interop 2026-08-05 11:11:23 +00:00
rom-selection.ts ROM selector: named selections with .romsel interop 2026-08-05 11:11:23 +00:00
rom-sources.test.ts Keep the ROM sources in the repository, not the image 2026-08-08 11:52:27 -04:00
rom-sources.ts Keep the ROM sources in the repository, not the image 2026-08-08 11:52:27 -04:00
romlist-refresh.test.ts Ask the host for a romlist rebuild instead of running it 2026-08-07 09:03:09 -04:00
romlist-refresh.ts Ask the host for a romlist rebuild instead of running it 2026-08-07 09:03:09 -04:00
scrape-cli.ts MAME tracker (Bun/TS): scraper, Deluge integration, ROM datfiles, web UI 2026-07-26 06:46:45 +00:00
scrape.ts MAME tracker (Bun/TS): scraper, Deluge integration, ROM datfiles, web UI 2026-07-26 06:46:45 +00:00
server.ts Keep the ROM sources in the repository, not the image 2026-08-08 11:52:27 -04:00
tailwind.config.cjs MAME tracker (Bun/TS): scraper, Deluge integration, ROM datfiles, web UI 2026-07-26 06:46:45 +00:00
torrent-index.test.ts Build the selectable list from the torrent itself 2026-08-07 09:49:25 -04:00
torrent-index.ts Build the index from the torrent when there is no datfile 2026-08-07 11:23:15 -04:00
tsconfig.json MAME tracker (Bun/TS): scraper, Deluge integration, ROM datfiles, web UI 2026-07-26 06:46:45 +00:00
tsconfig.node.json MAME tracker (Bun/TS): scraper, Deluge integration, ROM datfiles, web UI 2026-07-26 06:46:45 +00:00
uninstall-services.sh MAME tracker (Bun/TS): scraper, Deluge integration, ROM datfiles, web UI 2026-07-26 06:46:45 +00:00
vite.config.ts Show which build you are looking at, in the tab bar 2026-08-05 20:32:18 +00:00
wheel-fetch.ts Say why the catalogue is unavailable 2026-08-07 19:33:54 -04:00
wheel-index.test.ts Fetch wheels, which no source offers by ROM name 2026-08-07 15:55:56 -04:00
wheel-index.ts Fetch wheels, which no source offers by ROM name 2026-08-07 15:55:56 -04:00

MAME Torrent History Tracker

A system to scrape and track MAME torrent links from PleasureDome GitHub Pages, organized by category and version.

Installation Location

All files are installed in /opt/mame-tracker/:

/opt/mame-tracker/
├── server.ts               # Bun HTTP server: SPA + scrape + /api/refresh + JSON
├── scrape.ts               # PleasureDome HTML scraper (cheerio)
├── post-scrape.ts          # New version → Deluge Web UI + ROM datfile
├── deluge-web.ts           # Deluge JSON-RPC helpers
├── rom-datfile.ts          # dir2dat zip download + install
├── refresh-cli.ts          # Full pipeline CLI (for systemd timer)
├── scrape-cli.ts           # Scrape-only CLI
├── monitor-deluge.ts       # Completed-torrent cleanup (Deluge Web UI)
├── monitor-cli.ts          # CLI for monitor (systemd)
├── web/                    # React + Vite + Tailwind (shadcn-style UI)
│   ├── src/
│   └── dist/               # Production build output (from `bun run build`)
├── package.json
├── mame-scraper.service
├── mame-scraper.timer
├── mame-web.service
├── mnt-mame.mount
├── install-services.sh
└── uninstall-services.sh

Running as a container: what to mount, and where

The bare-metal install above is one way to run this. The other is the published image, which is how a cabinet runs it — git.forked.io/charles/mame-sync:latest, started by arcade-nix's services.rom-manager module.

Nothing below is discovered. Every path is an environment variable with a default, and a container that is missing one of these mounts does not fail loudly — it reports an empty collection, or an emulator checklist full of sample data, both of which look like the application working.

Mount at Env var Read/write What it is
the source path itself ROM_SOURCE_ROOT rw The collection: base set, update packs, CHDs, bios/, MAME-Set.xml. Read-write because the scraper installs a refreshed datfile back into it.
the destination path itself ROM_DEST_PATH rw The play set. Only with ROM_DEST_KIND=fs.
— ROM_DEST_LAYOUT — nested (default): sets in roms/, BIOS in bios/. flat: sets in the destination itself, BIOS still in bios/ — for a destination already named after the emulator, where …/roms/mame/roms reads like a mistake.
/data ROM_DATA_DIR rw Generated state: the ROM index, catalogs, saved selections, copy progress. A volume, or a restart costs a 44k-row index rebuild.
/etc/cabinet CABINET_MANIFEST (…/available-packages.json) ro Which packages the host can install. Read-only on purpose: this UI renders the list, it does not define it.
/etc/cabinet CABINET_EMULATORS (…/emulators.json) ro Which systems the host can configure as emulators, what each currently says, and which fields may be written back. Same mount, same reason.
/var/lib/cabinet CABINET_CONFIG_FILE (…/config.json) rw The configuration tab's only channel to the host. The UI writes the operator's choices here and the host picks them up and rebuilds.
/etc/samba/credentials ROM_SMB_CREDS ro Only when copying to a different machine over SMB (ROM_DEST_KIND=smb, the default). Not used on a Linux cabinet.

The two /…/cabinet mounts are a deliberate split. The container can write what it wants but cannot apply it: /etc/cabinet is read-only and the host rebuilds from /var/lib/cabinet/config.json on its own schedule. That is what makes "the web UI cannot reconfigure the machine out from under you" enforced rather than merely intended, and it is why the two are separate paths instead of one directory.

Mount the ROM paths at the same path inside the container as outside. The UI reports paths back to the operator, and a container that calls the collection /mnt/mame while the host calls it /srv/arcade/collection produces error messages naming a directory that does not exist on the machine reading them.

Wait for the share before starting. Where a path is a network mount, a container that starts first bind-mounts the empty directory underneath it and then reports an empty collection while the share is mounted perfectly. Under systemd that is RequiresMountsFor= on the container unit; arcade-nix sets it from the storage areas.

podman run -d --name rom-manager -p 8080:80 \
  -v /srv/arcade/collection:/srv/arcade/collection \
  -v /srv/arcade/roms/mame:/srv/arcade/roms/mame \
  -v rom-manager-data:/data \
  -v /etc/cabinet:/etc/cabinet:ro \
  -v /var/lib/cabinet:/var/lib/cabinet \
  -e ROM_SOURCE_ROOT=/srv/arcade/collection \
  -e ROM_DEST_KIND=fs \
  -e ROM_DEST_PATH=/srv/arcade/roms/mame \
  -e CABINET_MANIFEST=/etc/cabinet/available-packages.json \
  -e DELUGE_URL=http://host.containers.internal:8112 \
  -e DELUGE_TORRENT_LABEL=mame \
  --env-file /etc/rom-manager/deluge-password.env \
  git.forked.io/charles/mame-sync:latest

CABINET_MANIFEST is set explicitly even though the image has a default. The image ships a sample manifest so the checklist renders in a bare container, and without this line that fixture wins on a real cabinet too — showing sample data as though it were the built system. DELUGE_PASSWORD goes in the env file, never in -e: anything on the command line is visible in podman inspect and, under Nix, in the world-readable store.

NFS: MAME library on the NAS

The install script enables a systemd mount that connects your MAME folder on the NAS:

NAS export 10.2.0.10:/volume1/Main/Emulation/MAME
Local mount point /mnt/mame
Unit mnt-mame.mount

Requires nfs-common (Debian/Ubuntu) or nfs-utils (RHEL); install-services.sh tries to install it via apt-get or dnf/yum.

# Status and logs
systemctl status mnt-mame.mount
journalctl -u mnt-mame.mount -b

# Remount after NAS maintenance
sudo systemctl restart mnt-mame.mount

Synology: Enable NFS on the shared folder and grant this host access (read/write as needed). If the mount fails with “wrong version”, edit mnt-mame.mount and add e.g. nfsvers=3 or nfsvers=4 to the Options= line, then systemctl daemon-reload && systemctl restart mnt-mame.mount.

To install only the mount unit (no full app reinstall):

sudo mkdir -p /mnt/mame
sudo cp /opt/mame-tracker/mnt-mame.mount /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now mnt-mame.mount

Services Status

Check if services are running:

systemctl status mame-scraper.timer
systemctl status mame-web.service

Accessing the Web Interface

The Bun server listens on port 80 and serves the React app (shadcn-style components: Radix + Tailwind):

Resource URL
Tracker UI http://YOUR_SERVER_IP/
Same app (legacy paths) http://YOUR_SERVER_IP/mame-tracker/, http://YOUR_SERVER_IP/mame-sync/
History JSON http://YOUR_SERVER_IP/mame_torrent_history.json
Refresh (runs scraper) GET or POST http://YOUR_SERVER_IP/api/refresh
Latest ROM dat XML (download) GET (or HEAD) http://YOUR_SERVER_IP/api/mame-set.xml
Latest XML metadata (JSON) GET http://YOUR_SERVER_IP/api/mame-set/info
Game catalog — built versions GET http://YOUR_SERVER_IP/api/games/versions
Game catalog — one game GET http://YOUR_SERVER_IP/api/games/<version>/<zip>
Game catalog — group / list GET http://YOUR_SERVER_IP/api/games/<version>?zips=a,b or ?search=&status=&limit=&offset=
Settings — read GET http://YOUR_SERVER_IP/api/config
Settings — change PUT http://YOUR_SERVER_IP/api/config
Settings — reload from disk POST http://YOUR_SERVER_IP/api/config/reload
Settings — test Deluge POST http://YOUR_SERVER_IP/api/config/test
Cabinet packages — read / select GET / PUT http://YOUR_SERVER_IP/api/cabinet/packages
Cabinet emulators — read / configure GET / PUT http://YOUR_SERVER_IP/api/cabinet/emulators

The settings endpoints are covered in Configuration file (and where to mount it) below — including which file they read, where to mount it, and why an external writer has to call /api/config/reload.

The XML endpoints stream / describe the same MAME-Set.xml the post-scrape pipeline installs into the NFS MAME dir (MAME_DAT_DEST/MAME_DAT_XML_NAME); it is overwritten in place on every new version, so these always reflect the latest. /api/mame-set/info returns { available, filename, path, version, size, modified } (version is read from the Logiqx <header><version>); both return 404 with available: false if the file isn't present yet.

Configuration file (and where to mount it)

Runtime settings an operator can change live in a JSON file. Inside the container that file is:

/data/config.json

/data is ROM_DATA_DIR, declared as a VOLUME in the Containerfile. Mount a host directory there and the file is reachable from outside:

podman run -v /var/lib/rom-manager:/data ...   # -> /var/lib/rom-manager/config.json

A cabinet already does this: services.rom-manager in charles/arcade-nix mounts ${cfg.dataDir}:/data, and dataDir defaults to /var/lib/rom-manager, so the file is at /var/lib/rom-manager/config.json on the host with no extra work.

Note /data also holds generated state — ROM index, fetched catalogs, copy progress — so it is a directory the application writes to, not a config-only mount.

Shape

Absent means "all defaults"; the file is created on first save. Only keys present are treated as set:

{
  "deluge": {
    "url": "http://127.0.0.1:8112",
    "password": "deluge",
    "label": "mame"
  }
}

Three layers decide each value, most specific first: saved file → environment variable → built-in default. Clearing a key makes that value fall back a layer rather than become empty. GET /api/config reports which layer supplied each value in its sources object, which is the quickest way to confirm an edit landed.

Making an external edit take effect

Settings are cached in memory, so a service that writes the file directly must say when it is done:

curl -X POST http://YOUR_SERVER_IP/api/config/reload

The response echoes the values now in force plus their sources, so the caller can verify rather than assume — a value still reading env or default means the file did not carry it. Without this call the edit is ignored until the process restarts.

Game catalog API (per-version game metadata)

/api/games/... serves a per-game catalog — zip (set) name, game name, and emulation quality (plus year/manufacturer/clone) — for each MAME version this server has pulled & compiled (the no-nag builds). See catalog.ts.

  • <version> accepts a dotted version (0.288), the bare number (288), or the build tag (mame0288).
  • Zip lookups accept real non-merged filenames: a trailing .zip and any case are fine (pacman.zip, PUCKMAN.ZIP, or bare pacman). In a non-merged set every parent and clone has its own <setname>.zip, and each catalog entry's zip field is that set name — so they map 1:1.
  • One game: GET /api/games/0.288/pacman.zip → { zip, name, status, emulation, year, manufacturer, cloneof, sourcefile }.
  • A group: GET /api/games/0.288?zips=puckman.zip,dkong.zip,mario.
  • A filtered list: GET /api/games/0.288?search=street&status=good&limit=50&offset=0 (status ∈ good|imperfect|preliminary; default limit 200, max 50000).
  • Versions available: GET /api/games/versions. Unknown/unbuilt versions return 404 with the list of available ones.

How it's produced: the data is extracted statically from MAME source (the GAME/GAMEL/CONS/COMP/SYST macros), not by running a binary. status ("emulation quality") uses the exact good/imperfect/preliminary rule from MAME's own infoxml.cpp output_driver. It is generated automatically for every new version: the nightly scraper triggers a no-nag build (post-scrape.ts → triggerNoNagBuild), and build.sh writes builds/<tag>/catalog.json (~7.6 MB, ~38k games, ~1.6 s) as soon as the source is downloaded — before the multi-hour compile, so a new version is catalogued the moment it's pulled and even if the build later fails. The server loads it into memory on first request (sub-millisecond lookups thereafter). To (re)generate manually:

bun run catalog -- /path/to/mame-source/src/mame mame0288   # -> builds/mame0288/catalog.json

This static parse faithfully captures the declarative layer (name, zip, year, manufacturer, clone, driver flags) but not runtime-computed detail (dipswitches, device-provided ROMs, displays) — those would require a running binary's -listxml. Coverage note: every game and BIOS set is included (BIOS roots are GAME(...) macros), but standalone device-ROM zips (e.g. qsound) are not — devices are defined via DEVICE_*, not the GAME-family macros, so they don't appear as catalog entries.

Set MAME_WEB_PORT in the systemd unit if you need a port other than 80.

Development

  1. Install Bun if needed.
  2. Terminal A — API + JSON (port 8080): MAME_WEB_PORT=8080 bun run server.ts
  3. Terminal B — Vite dev server with proxy: bun run dev (opens port 5173; proxies /api and JSON to 8080).

ROM datfile (dir2dat) → MAME-Set.xml

When a new MAME version is processed (after each refresh that detects a new version), the Bun post-step also:

  1. Resolves the MAME ROMs dat zip URL (from scraped history, or standard GitHub paths under PleasureDome).
  2. Downloads it, extracts the zip, and picks the non-merged or merged .xml (or ClrMamePro .dat XML) per MAME_ROM_DAT_VARIANT.
  3. Copies it to the NFS MAME directory as a fixed name (default MAME-Set.xml).
Environment variable Default Meaning
MAME_DAT_DEST /mnt/mame Target directory (NFS mount)
MAME_DAT_XML_NAME MAME-Set.xml Output filename
MAME_ROM_DAT_VARIANT non-merged non-merged or merged — which PleasureDome ROM set zip/XML to install
ROM_DATFILE_GITHUB_BASE PleasureDome raw/gh-pages/mame/ Fallback URL prefix

mame-scraper.service starts after mnt-mame.mount so /mnt/mame is available.

No-nag MAME builds

When the scraper detects a new MAME version, the post-scrape pipeline also kicks off a Windows-x64 no-nag build of MAME from upstream source. Output is a single drop-in mame.exe, kept locally under /opt/mame-tracker/no-nag/builds/<tag>/.

What "no-nag" means here

A one-line patch in src/frontend/mame/ui/ui.cpp flips bool show_warnings = true; to false inside mame_ui_manager::display_startup_screens(...). Result: the orange/red emulation-warning popup never renders. Game-info, mandatory-image errors, and everything else are untouched. Using a binary built from this patched source means MAMEdev will not support bug reports — that's the point.

Layout

/opt/mame-tracker/no-nag/
├── apply-no-nag.sh          # idempotent patcher; fails loudly if MAME refactors
├── build.sh                 # download → patch → cross-compile → install
├── check-and-build.sh       # CLI: resolve mamedev/mame latest, build if new
├── builds/<tag>/mame.exe    # successful artifacts
├── logs/<tag>.log           # full build log, tail visible at /api/no-nag/log/<tag>
├── work/<tag>/              # transient build dir, removed on exit
├── .build.lock              # flock-based single-flight gate
└── .last-built              # last successful tag (e.g. mame0287)

Trigger model

  • Automatic: post-scrape.ts calls triggerNoNagBuild(latestVersion) after a new version is recorded; the build runs detached so the HTTP refresh returns immediately. See no-nag-trigger.ts.
  • Manual: /opt/mame-tracker/no-nag/build.sh mame0287 or check-and-build.sh (the latter resolves "latest" from the GitHub release).
  • Opt-out: set NO_NAG_BUILD=0 in the scraper service environment to disable the auto-trigger.

build.sh is idempotent: if builds/<tag>/mame.exe already exists, it returns 0 immediately. A flock-protected single-flight prevents overlap if a build is already in progress.

HTTP endpoints

Method Path Returns
GET /api/no-nag/builds JSON list of all builds + status (success / in-progress / failed)
GET /api/no-nag/download/<tag> mame-<tag>-no-nag.exe for completed builds
GET /api/no-nag/log/<tag> Last 64 KB of the build log (text/plain)

The tracker UI surfaces this via the No-nag MAME builds panel — a list of versions with download buttons and an in-progress badge while a build is running.

Toolchain

Cross-compile from this Linux host using MinGW-w64 (POSIX threads, GCC 14+):

sudo apt-get install -y --no-install-recommends \
  g++-mingw-w64-x86-64-posix gcc-mingw-w64-x86-64-posix \
  binutils-mingw-w64-x86-64 python3 make jq

Build invocation (set inside build.sh):

make TARGETOS=windows PTR64=1 MINGW64=/usr \
     OVERRIDE_CC=x86_64-w64-mingw32-gcc \
     OVERRIDE_CXX=x86_64-w64-mingw32-g++ \
     OVERRIDE_LD=x86_64-w64-mingw32-ld \
     PYTHON_EXECUTABLE=/usr/bin/python3 -j$(nproc)

Resource note

A full MAME build is heavy: ~3–4 GB of source extracted, ~25–30 GB of build artifacts at peak, ~6–12 GB RAM peak per gcc, multiple hours wall time even with -j6. Make sure the host has 16+ GB RAM and 100+ GB free under /opt. The work/<tag>/ tree is removed on a clean exit.

SMB publish

After a successful build, publish.sh pushes mame.exe to a Windows SMB share. Defaults match the user's arcade rig: //arcadepc/d/Arcade/MAME/emulator/mame.exe, overwriting the existing file.

The destination is typically locked while MAME is running on the arcade rig (NT_STATUS_SHARING_VIOLATION), so publish.sh is a retry daemon: it loops with a 5-min sleep until the lock clears, the destination becomes reachable, the daily cap hits, or a newer publish supersedes it. build.sh spawns it via setsid so the build slot isn't tied up by hours of polling.

Failure classification:

smbclient output Treated as Behavior
NT_STATUS_LOGON_FAILURE, NT_STATUS_ACCESS_DENIED, NT_STATUS_ACCOUNT_* auth failure exit 2 immediately, no retry
NT_STATUS_SHARING_VIOLATION destination locked (MAME running) retry every RETRY_INTERVAL_SEC
Connection ... failed, NT_STATUS_HOST_UNREACHABLE, NT_STATUS_IO_TIMEOUT, … network unavailable retry
anything else transient retry

If a newer publish is invoked (e.g. mame0288 finishes while mame0287 is still polling because MAME has been running for 6 hours), the newer one kills the older retry and takes over — we always ship the most recent build.

Configuration (env, defaults shown):

Env var Default Purpose
NO_NAG_SMB_TARGET //arcadepc/d UNC //host/share
NO_NAG_SMB_SUBPATH Arcade/MAME/emulator Path inside the share (forward slashes)
NO_NAG_SMB_CREDS /etc/samba/credentials.no-nag Samba creds file (mode 600)
NO_NAG_SMB_DEST_NAME mame.exe Remote filename
NO_NAG_PUBLISH_RETRY_SEC 300 Sleep between attempts
NO_NAG_PUBLISH_MAX_ATTEMPTS 288 Give-up cap (≈ 24 h × 5 min)

Credentials file format:

username=cdaoust
password=...
domain=WORKGROUP

publish-<tag>.log lives in /opt/mame-tracker/no-nag/logs/ for the detached retry runs. If NO_NAG_SMB_CREDS is missing, the publish step is skipped silently.

# Push an already-built version manually (retries until destination is unlocked):
sudo /opt/mame-tracker/no-nag/publish.sh mame0287

Service Management

View Logs

# Scraper logs
journalctl -u mame-scraper.service -f

# Web server logs
journalctl -u mame-web.service -f

Manual Operations

# Manually run the scraper
systemctl start mame-scraper.service

# Restart web server
systemctl restart mame-web.service

# Stop web server
systemctl stop mame-web.service

Check Timer Schedule

systemctl list-timers mame-scraper.timer
systemctl list-timers mame-monitor.timer
  • The scraper runs daily at 2 AM UTC
  • The Deluge monitor runs every 15 minutes to check for completed MAME torrents

Automatic Deluge Integration

The Bun post-step (after each successful scrape) can add MAME Update ROMs and MAME Update CHDs magnets to Deluge when a new version is detected. The tracker UI uses the same Deluge Web UI JSON-RPC (DELUGE_URL) to show what is already in the client.

Configuration

The URL, password and torrent label can be edited at runtime from the Configuration tab in the web UI — changes apply immediately, no restart needed. That's the preferred way to change them.

They resolve in three layers, most specific wins:

  1. Saved config — written by the Configuration tab to ${ROM_DATA_DIR}/config.json (inside this app's own data directory; never touches the NixOS cabinet config)
  2. Environment — set in mame-scraper.service, mame-web.service, or your shell (not the old daemon RPC host/port)
  3. Built-in defaults — Deluge's own defaults for a local install (http://127.0.0.1:8112, password deluge, label mame), so a cabinet running Deluge on the same machine needs no configuration at all
Variable Meaning
DELUGE_URL Web UI base, e.g. http://127.0.0.1:8112
DELUGE_PASSWORD Web UI password (empty string if none)
DELUGE_TORRENT_LABEL Label for new torrents (default mame)
DELUGE_WEB_URL Optional browser URL for “Open Deluge” in the UI (defaults to the resolved Deluge URL above). Environment-only — not editable from the Configuration tab.

Example:

Environment="DELUGE_URL=http://127.0.0.1:8112"
Environment="DELUGE_PASSWORD=your_web_ui_password"

Then: sudo systemctl daemon-reload && sudo systemctl restart mame-scraper.service mame-web.service

How It Works

  • When a new latest version appears vs .last_processed_version, the pipeline adds Update ROMs + Update CHDs magnets via core.add_torrent_magnet, then runs the ROM datfile install.
  • The Label plugin is optional but recommended for labels and for the completion monitor.

Manual Testing

curl -sS -X POST "http://127.0.0.1/api/refresh"
# or full pipeline without HTTP:
cd /opt/mame-tracker && bun run refresh

Data Storage

The JSON data file is stored at:

/opt/mame-tracker/mame_torrent_history.json

This file is automatically created and updated by the scraper (bun run scrape, bun run refresh, or /api/refresh).

Dependencies

  • Bun — runtime for the server, scraper, monitor, and CLIs (bun install installs cheerio, fflate, etc.).

Standalone binary (optional)

After bun install && bun run build:

bun run build:server
# produces ./mame-tracker — single executable with embedded Bun runtime

Automatic Torrent Removal

The system includes a monitor that automatically pauses completed torrents that have the mame label (or DELUGE_TORRENT_LABEL) only; other torrents are not touched.

How It Works

  1. Labeling: When torrents are added to Deluge, they are automatically labeled with mame
  2. Monitoring: A background service checks every 15 minutes for completed torrents with the mame label
  3. Removal: When a torrent finishes downloading (reaches 100% or enters "Seeding" state), it is removed from Deluge but files remain on disk

Monitor Service

  • Service: mame-monitor.service
  • Timer: mame-monitor.timer (runs every 15 minutes)
  • CLI: bun run monitor or /usr/bin/bun /opt/mame-tracker/monitor-cli.ts
  • Uses DELUGE_URL / DELUGE_PASSWORD (Web UI JSON-RPC), same as the tracker. Matches DELUGE_TORRENT_LABEL only (no owner filter).

Manual Operations

# Manually run the monitor
systemctl start mame-monitor.service

# Or from the repo
cd /opt/mame-tracker && bun run monitor

# Check monitor status
systemctl status mame-monitor.timer

# View monitor logs
journalctl -u mame-monitor.service -f

Requirements

  • Label Plugin: Must be enabled in Deluge for labeling to work
  • The monitor will skip torrents without the mame label
  • Files are preserved on disk when torrents are removed

Troubleshooting

Scraper not running

Check logs:

journalctl -u mame-scraper.service -n 50

Common issues:

  • Missing JS deps: cd /opt/mame-tracker && bun install && bun run build
  • Network issues: Check internet connectivity (scraper fetches PleasureDome + GitHub)
  • ROM dat: Ensure MAME_DAT_DEST exists and is writable (NFS mounted)

Web server not accessible

  1. Check if running: systemctl status mame-web.service
  2. Check logs: journalctl -u mame-web.service -f
  3. Check firewall: May need to allow port 80
  4. Verify port: Check if port 80 is already in use (requires root privileges)
  5. Note: Port 80 requires root privileges. The service runs as root by default.

Reinstall Services

If you need to reinstall the services:

cd /opt/mame-tracker
bash uninstall-services.sh
bash install-services.sh