Files
homelabstack/scripts/igir-dryrun.sh
T
ginnoir 797fe425b1 feat(roms): add igir per-platform dry-run + rename sweep helpers
igir-dryrun.sh: read-only igir report for one platform vs given DAT(s),
prints an identified%% summary + sample of unmatched files (the scoring
step of the platform sweep).

igir-dorename.sh: igir move to canonical names in place for one platform,
with before/after manifests for reversibility and --dir-game-subdir never
to keep folders flat. Cart-safe; not for disc systems with .m3u.
2026-06-05 22:37:35 -05:00

43 lines
1.8 KiB
Bash

#!/usr/bin/env bash
# scripts/igir-dryrun.sh (runs ON valhalla)
#
# Read-only igir REPORT for one platform folder against the given DAT(s), then a
# checksum-status summary + a sample of unmatched files. Used to score a platform
# ("identified%") before deciding whether to canonicalize it with igir-dorename.sh.
#
# DAT paths are relative to libretro-database/metadat (so "no-intro/..." or
# "redump/...") — the cache populated by scripts/igir-report.ps1.
#
# ssh ginnoir@valhalla 'bash -s -- gb "no-intro/Nintendo - Game Boy.dat"' < scripts/igir-dryrun.sh
# # or, already deployed on the host:
# ssh ginnoir@valhalla 'bash /storage1/igir/dryrun.sh nes "no-intro/Nintendo - Nintendo Entertainment System.dat"'
set -uo pipefail
plat="$1"; shift
dargs=(); for d in "$@"; do dargs+=(-d "/dats/$d"); done
out="_dry_${plat}.csv"
docker run --rm \
-v /storage1/Emulation/roms:/input:ro \
-v /storage1/igir/dats/libretro-database/metadat:/dats:ro \
-v /storage1/igir/reports:/output \
node:lts npx -y igir@latest report "${dargs[@]}" \
-i "/input/$plat" --report-output "/output/$out" 2>&1 \
| grep -E "files found|games," || true
python3 - "/storage1/igir/reports/$out" <<'PY'
import csv,sys
name=sys.argv[1].split('/')[-1]
found=unused=dup=missing=0; samp=[]
with open(sys.argv[1],newline='',encoding='utf-8',errors='replace') as fh:
for r in csv.DictReader(fh):
s=r.get('Status','')
if s=='FOUND': found+=1
elif s=='UNUSED':
unused+=1
if len(samp)<10: samp.append(r.get('ROM Files') or r.get('Game Name',''))
elif s=='DUPLICATE': dup+=1
elif s=='MISSING': missing+=1
den=found+dup+unused
pct=100.0*(found+dup)/den if den else 0
print(f"SUMMARY {name}: identified={pct:.1f}% matched={found+dup}/{den} FOUND={found} DUP={dup} UNUSED={unused} MISSING={missing}")
for x in samp: print(" UNUSED:",x)
PY