Commit Graph
159 Commits
Author SHA1 Message Date
Abdessamad Derraz 02969dda06 refactor: read declared hashes with one helper
core.hashing.declared_hash_lists gives an entry's declared values per
field in the order written, and declared_hashes builds its sets on it.
The gap page, the doubled-destination report and the file lookup used
their own copies of that reader. The wanted page keeps its filters on
top of it. sitegen.lookup.hash_pairs replaces sorted_hash_values for
the lookup, the data exports and the structured data. The one-field
aliases parse_md5_list and reconcile.hash_values are gone, and
model.profiles reads HASH_FIELDS instead of a fourth tuple.
2026-11-21 10:29:37 +01:00
Abdessamad Derraz 77ba6868a0 refactor: count nouns through core.text 2026-11-21 06:03:21 +01:00
Abdessamad Derraz 83fdc97edd fix: skip quoted hashes in batocera item notes 2026-11-21 06:01:53 +01:00
Abdessamad Derraz b81e89dbfb fix: judge declared sizes per entry with size_fits 2026-11-21 06:01:46 +01:00
Abdessamad Derraz e462b03848 fix: compare declared hashes in one place 2026-11-21 06:01:30 +01:00
Abdessamad Derraz 0332f6149a refactor: read RetroPie scripts from one tarball
script_members in retropie_scraper yields every shell script of a
RetroPie-Setup tarball. The platform scraper, the exporter and the target
scraper read the scripts through it. The target scraper fetched one
contents listing per section and about 200 raw files; it now reads the
tarball of the pinned revision in one request. On the cached tarball the
three produce the same module ids, scripts, BIOS-bearing scripts and
targets as before. The targets file keeps its source URL.
2026-11-20 20:03:09 +01:00
Abdessamad Derraz f7c08a6ca3 refactor: read md5 lists through parse_hash_list
The RetroDECK and Recalbox exporters compare md5 lists with
resolve.reconcile.hash_values, and the RetroDECK scraper reads an entry's
md5 with md5_field and parse_hash_list instead of its own copy.

Recalbox's comparison no longer keeps an empty item: md5="a,,b" states
a,b where it stated ,a,b. The RetroDECK scraper now splits a
comma-joined value and refuses an md5 that is neither a string nor a
list of strings, as the batocera-systems readers do. The ten cached
component manifests write neither form, so retrodeck.yml is unchanged.
2026-11-20 20:02:44 +01:00
Abdessamad Derraz e19025231e refactor: locate the systems dict once
systems_span in batocera_scraper finds the systems literal of a
batocera-systems script by reading strings of either quote and
comments, and accepts systems = OrderedDict({. The exporter cuts the
script at those braces and reads comments with the same comment_start,
in place of its line prefix rule, its ast fallback and a comment test
that only knew double quotes. Both give the same cut on the cached
Batocera, AmberELEC, EmuELEC, KNULLI and ROCKNIX scripts.

An unclosed dict is refused by name instead of failing in literal_eval.
2026-11-20 20:02:44 +01:00
Abdessamad Derraz f61c2cb7d4 refactor: one network layer for the scrapers
Each network job had several copies. One is kept per job and
every caller uses it.

- Source revision: model.sourcerevision (source_revision, required_revision,
  platform_revision) replaces BaseTargetScraper's pattern list, the
  exporter's _REVISION, the four launcher_revision copies and RetroBat's
  own YAML reader. It reads the union of the shapes: GitHub raw, blob and
  tree with or without a path after the revision, GitLab raw, blob, tree
  and archive, codeload tar.gz and zip. The target scrapers now answer
  for RetroDECK, NextUI, MinUI and MyMinUI, whose tree URLs end at the
  commit, and the exporter reads GitLab blob and tree and codeload zip.
  EmuDeck and RetroBat still require a 40-hex commit, and each launcher
  reader requires its own repository in the URL.
- Latest release: fetch_github_latest_version, type-checked, is the only
  lookup. mame_hash_scraper, romset_dat_importer and the Lakka target
  scraper call it. romset_dat_importer's NoReleaseError is gone: a
  release without a tag raises RuntimeError.
- Tree listing: github_tree and tree_entries refuse a truncated or
  unreadable listing. The libretro and core-info scrapers share
  core_info_files and fetch_info_file, with libretro's refusal of an empty
  listing. The core-info listing and the RetroDECK, ROCKNIX launcher and
  libretro listings were not checked for truncation before.
- GET: fetch_bytes is the one request path. fetch_text, fetch_present
  (None on 404 only), github_json and download are built on it, so every
  read retries 429 and 5xx, caps the body and raises FetchError, a
  ConnectionError carrying the HTTP status. The target scrapers' own
  fetch_text raised RuntimeError: they now raise FetchError, and an
  optional Batocera board include is skipped on 404 only, not on any
  failure. The exporter's originals, MiSTer, RetroPie, redump and the
  buildbot index go through it too.
- Headers: core.upstream.forge_headers is the one builder. The token goes
  to api.github.com and raw.githubusercontent.com, the host compared
  whole, as Bearer. A URL that only names api.github.com in its query
  got the scrapers' token before, and profile_sync sent its token to
  github.com, whose release downloads redirect to asset storage with the
  header. Scraper reads of raw files now carry the token.
- Submodule commit: submodule_commit checks that the path is a
  submodule. Batocera's target scraper accepted any contents answer with
  a sha, a directory's tree sha included.
- Download: download streams through a scratch file renamed into place,
  retries like fetch_bytes, can keep an existing file and returns the
  Content-Disposition. It replaces the _download of romset_dat_importer
  and game_dat_importer.
2026-11-20 20:02:15 +01:00
Abdessamad Derraz 348d5b51c3 refactor: read hashes and the registry one way
Hash fields go through core.hashing.parse_hash_list, which also splits comma-joined list items: the truth model compared a comma-joined sha256 list as one value. _registry.yml goes through load_platform_registry (required= where an absent file must stop the run), database.json through load_database, file and member digests through file_digest and stream_hashes. download.py and check_release read SHA256SUMS.txt with one parser: a sha256sum -b line matched nothing in download.py and the pack went unchecked.
2026-11-20 18:28:40 +01:00
Abdessamad Derraz 3853ca2f1c refactor: public names for cross-module reads 2026-11-18 22:59:51 +01:00
Abdessamad Derraz 0b532366d0 refactor: move pack library code into packs/ 2026-11-18 13:47:31 +01:00
Abdessamad Derraz a5834a4b8a refactor: move the export library into exporter 2026-11-18 13:38:44 +01:00
Abdessamad Derraz 83cfa6fd0f refactor: split common.py into three packages
core: cli (run_cli, input errors, name hints), github (token), paths.
model: sources, database, composition, registry, platforms,
declarations, targets, systems, profiles, cliargs. resolve: content,
ownership, datadirs, archives, localfile, directories, layout,
contentlayout, standalone, grouping, cores.

Definitions move verbatim; common.py and its re-exports are gone and
every importer, patch target and code-in-string names the new home. A
test that stubbed common.load_platform_config stubs each module that
reads the loader by its own name.
2026-11-18 11:09:13 +01:00
Abdessamad Derraz c784aef883 refactor: move leaf modules into packages
core: hashing, artifacts, ziptools, deterministic_zip, romdir, sect233r1,
crypto_verify, paths (REPO_ROOT). model: safeparse (needs yaml),
dumpcatalog, largefiles, alternatives. resolve: nativemode, validation,
launchers, slot, truth, gamedata, and exporter/baseline.py and
exporter/candidates.py as resolve/reconcile.py and resolve/categories.py,
which truth and gamedata read.

Every importer follows. Modules one level deeper read the repository
root from core.paths instead of __file__.
2026-11-18 10:50:45 +01:00
Abdessamad Derraz 81a94fc267 refactor: make writable an instance method 2026-11-17 09:48:13 +01:00
Abdessamad Derraz fd60b10de6 refactor: split export_native and the exporters 2026-11-17 07:54:04 +01:00
Abdessamad Derraz 4eacb6ff39 chore: lint scripts and tests with ruff
pyproject.toml now carries the ruff rule set: pyflakes, the B rules,
simplify, perf, pyupgrade, complexity and size limits. This commit
applies the fixes that change no behavior and the small defects the
first run named:

- tests/test_install.py used argparse without importing it
- three loops rebound the outer `profile` with each layout
  (packextras, slots, verify); the loop variable is now `layout`
- profile_sync loops shadowed dataclasses.field
- generate_readme and packextras computed values nothing read
- stale noqa markers for rules the project does not enforce

Complexity, size and the remaining findings are handled next.
2026-11-17 07:07:48 +01:00
Abdessamad Derraz 2c76cc7df9 feat: read a search list as one need
A core that loads the first of several names (yabause: saturn_bios.bin,
sega_101.bin, mpr-17933.bin) needs one of them. Profiles wrote this as
required on the first name and optional on the others, so verify and
the gap report called saturn_bios.bin a missing required file while
sega_101.bin was held, and a set held only through a name marked
optional read as a need met by an optional file.

Model: an explicit group on the file entry, mirroring the platform
field. priority was not reused: it is a rank, read by slot.py, region.py
and truth.py inside a (system, region) slot, and that slot is not the
set. px68k-sdl ranks its IPL list and its font list each from 1 in one
system, pom2 ranks one list per machine model, DuckStation ranks 105
images across every region and takes any of them. A rank cannot say
where one list ends. priority stays the order inside a group.

Readers, through alternatives.settle_sets:
- verify --emulator and the emulator pack: a held member fills the
  set, the others leave the report, a set nobody holds is one gap
  under its first member naming the others.
- find_undeclared_files (verify platform, core complement of packs and
  manifests): same rule, a platform declaration or launcher counts as
  answering the set.
- cross_reference: excused members are set aside as other versions.
- slot.py: ranks compare members of one set only.
- archive members: a required set inside an archive is met by one.
- truth: a member gives no requirement of its own, one_of and
  one_of_required carry the set, and the exporters and the diff leave
  such a line's required as the platform wrote it.
- validate_schemas: members of a group share required.
2026-11-09 17:39:46 +01:00
Abdessamad Derraz eb8f60aef7 fix: write retrobat group and optional back
The export dropped the two fields Program.cs reads besides md5 and file:
an empty truth no longer handed RetroBat's list back as written.
2026-11-09 12:45:56 +01:00
Abdessamad Derraz 70f530516d chore: merge pack and resolver fixes 2026-11-07 00:06:15 +01:00
Abdessamad Derraz ed6643022d fix: write the cut md5 rule once
Six places read an md5 shorter than 32 digits, each with its own bound.
digest_verdict accepted any prefix down to one digit, while Batocera
compares the whole string (batocera-systems:1088). A cut value now names
a dump only when one held md5 starts with it (cut_md5_owner, read by the
scraper, the resolver and --from-md5), and every verdict compares whole
digests.
2026-11-06 15:18:38 +01:00
Abdessamad Derraz 6a5b384e02 fix: say when a RetroPie help is updated in part 2026-11-06 14:56:11 +01:00
Abdessamad Derraz 144cd46df1 fix: count one export line per addition path 2026-11-06 14:55:23 +01:00
Abdessamad Derraz 63be8cc3bc fix: find tab-indented batocera-systems entries
The entry pattern required four spaces of indent. EmuELEC indents 23 systems with one tab, so render appended each again whole and the published export carried 21 duplicated keys, the md5 fills only in the second copy. Any indent opens an entry now, and an entry written again keeps its own. The EmuELEC export is regenerated: one copy of each system, the amiga entry also gaining the eight WHDLoad Kickstarts the profiles added since 2026-10-22.
2026-11-06 08:39:40 +01:00
Abdessamad Derraz 39e6afbeb2 fix: a size kept in bios_db.json is not removed
When the truth accepts the BiosDB hash but none of its sizes fits, the MiSTer render keeps the entry's size beside the hash, and the report still counted a size removed. A size the truth does not state is no longer reported as changed.
2026-11-06 04:00:47 +01:00
Abdessamad Derraz 290c0b73ff fix: a container md5 leaves a zippedFile md5 alone
Batocera and KNULLI check a zippedFile item's md5 against the member inside the archive. A profile's container md5 for the archive would have replaced it as a correction. The item's md5 is now read as Recalbox's composite md5 is: neither compared with the container's nor overwritten by it.
2026-11-06 04:00:15 +01:00
Abdessamad Derraz d5e61308e1 fix: additions join the native id their cores read
A platform system spanning several native ids with no native_id filed every addition under the id that sorts first: RetroDECK's arcade wrote MAME device archives as FBNeo BIOS, RetroBat's Amiga put A500 kickstarts under amiga1200. An addition now joins the id whose declared files its cores read, and one the cores do not settle is counted and not written.
2026-11-06 03:57:39 +01:00
Abdessamad Derraz 3d0ee19bcb refactor: index profile entries by name and hash
_matching walked the reader's whole profile for each platform entry, 2,135 scans of MAME in one verify --all. Each profile is now indexed once per kind by name and by accepted hash. Over every registered platform, 10,524 lookups give the same answers as the scan, in 0.13 s instead of 2.42 s.
2026-11-05 19:37:27 +01:00
Abdessamad Derraz 4af0d70e4e fix: report md5 lists Recalbox and RetroDECK grow
Both formats write every accepted md5 when the truth extends the platform's list without contradicting it, but only Batocera answered written_list, so landed_changes reported nothing for a diff the maintainer would find. Both now name the list they write when it holds several values.
2026-11-05 19:36:02 +01:00
Abdessamad Derraz b90f8bb0b9 chore: merge tooling batch 2026-11-05 15:57:19 +01:00
Abdessamad Derraz 5ef7a9fabf refactor: hash each profile entry once 2026-11-05 11:57:08 +01:00
Abdessamad Derraz d7d6f3e412 fix: one hash mismatch rule for diff and export
diff_truth read sha1, md5 and crc32 and let one shared value settle the
entry, while export_native corrected each of the four fields on its own.
contradicted_hashes is now the single decision both read.
2026-11-05 11:50:09 +01:00
Abdessamad Derraz a434c1a8a0 fix: add a retropie file to its own system's list
Only the first BIOS clause of a help string was read, so naomi2.zip and
segasp.zip went into flycast's Dreamcast sentence. A file now joins the
clause whose names the platform files under its system, or is not added.
2026-11-05 11:43:54 +01:00
Abdessamad Derraz 4e5b48ddbe fix: keep the md5 a mister entry already holds
A BiosDB entry is one record: md5, size and url describe one dump. The
first md5 the truth accepts replaced an accepted one with no change
reported. The exporter now writes record_hash, as RomM and System.dat do.
2026-11-05 11:41:18 +01:00
Abdessamad Derraz 2ee777824a feat: name doubled destinations in exports
A platform list that declares one path for two files fails one of the
two checks on every install. The export report lists each declaration
with its hash and the emulators whose profile reads that file.
2026-10-24 02:42:04 +02:00
Abdessamad Derraz 5b083c45b5 feat: export md5 lists the pinned checker reads
The script exporters (Batocera, ROCKNIX, KNULLI, AmberELEC, EmuELEC)
read the checker of the pinned original: when checkBios hands an
item's md5 to a function that tests it with isinstance(..., list),
as md5Matches does since batocera.linux 6b08b873, an entry whose
emulator code accepts several dumps is written with all of them, and
an addition that needed several becomes writable. Items with altmd5
keep a string, since checkBios wraps them in a list of its own.

No cached original reads lists today, so every export is unchanged.
The report records a list as a list, counts the lists written, and
records a list the truth extends without contradicting it.
2026-10-23 08:06:58 +02:00
Abdessamad Derraz 0b4504992b feat: read batocera md5 written as a list
batocera.linux 6b08b873 lets a biosFiles item declare its md5 as a
list of strings, and checkBios accepts a file matching any of them.
The scrapers join the values with commas, as for Recalbox, and record
md5_list so the export writes the list back as a list, byte for byte.
2026-10-23 07:39:25 +02:00
Abdessamad Derraz 14a6518d49 fix: cite the reader that accepts the hash
A platform entry that declares a hash is now answered by the profile entries accepting it. Batocera's scph1001.bin (md5 dc2b9bf8, v2.0) cited DuckStation's bios.cpp:36, the v2.2 line. A same-named entry is kept, marked by name, only when none accepts the hash and its own hashes do not contradict it. Categories are unchanged: verify --all prints the same report.
2026-10-23 02:58:43 +02:00
Abdessamad Derraz 33041b6bd1 feat: find a file by any hash, out of the search
Hashes, link lists, install commands, member tables and long reference
tables leave the site search: the index drops from 21.0 MB (4.88 MB
gzip) to 6.8 MB (1.33 MB gzip). Names and prose stay searchable.

files/?hash= takes a SHA1, MD5, CRC32 or SHA256 and reads one shard of
api/v1/lookup/ (about 22 KB gzip, was 675 KB) listing the collection
card, the platforms that declare the value and the profiles that check
it. files/?sha1= still opens the card, and a sha1- anchor missing from
a page is looked up there, so a card can move between pages.

Excluded blocks are section elements: the search plugin compares
elements by tag, so a div ended at the first nested div.
2026-10-22 12:46:40 +02:00
Abdessamad Derraz baf38ffbee refactor: compute coverage once, index proofs
EntryCategories asked every core in turn: 3.8 million proofs for 7,430
entries. ProofIndex looks each key up once, and verify --all --json is
byte-identical (24 s to 17 s). generate_site and generate_readme now share
one coverage, cached in tmp/coverage-cache keyed by its inputs, so the
README step drops from 25 s to 3 s.
2026-10-22 12:23:26 +02:00
Abdessamad Derraz cd7d993cac feat: settle entries by their system's cores
A system that lists the cores it runs is settled by those cores alone, so an unprofiled core of another system no longer leaves its entries open. Readers whose core runs the entry's system are named first, and cores that only share the file name are listed as such.
2026-10-22 06:30:56 +02:00
Abdessamad Derraz a75ea05b86 feat: document what settles each category
Each missing platform entry now carries its evidence: the profile entries that read it with their source reference, the cores of its system examined without finding a reader, or why the question stays open. verify --verbose prints it, --json carries it and the platform pages show it.
2026-10-22 05:43:06 +02:00
Abdessamad Derraz f66adfdcbc feat: categorize missing platform entries
A platform list can name a game's data files or a file no core it runs opens. Verify gives each missing entry a category read from the profiles of the platform's cores: firmware, game data or unread. Only firmware gaps carry a severity and fail --strict; the others are counted on their own line, and the pack check no longer counts them as pack errors. Missing firmware stays a conformance error.
2026-10-22 05:38:57 +02:00
Abdessamad Derraz 2bdac466a9 feat: add knulli, amberelec and emuelec platforms
Each OS publishes Batocera's systems dict (knulli-systems, and
batocera-systems at AmberELEC's newest prerelease commit and EmuELEC v4.8),
read with the shared parser. Cores come from each OS's own ES list.
AmberELEC and EmuELEC declare neogeo/ and ports/ beside bios/ from
/storage/roms, so their packs extract there and core_destination puts
core files under bios/.
2026-10-22 03:42:20 +02:00
Abdessamad Derraz fd1d1b7b96 chore: merge round 2 fixes (pins)
# Conflicts:
#	install.ps1
#	install.sh
2026-10-21 10:31:09 +02:00
Abdessamad Derraz ccf61b96d7 fix: report names a RetroPie sentence gains
flycast now reads naomi2.zip, which the RetroArch list RetroPie inherits
already declares. The render added it to the flycast help sentences but
landed_changes counted additions only for entries the platform layer
lacks, so the report missed a name the diff carries. names_anew lets an
exporter whose unit is not the entry say so.
2026-10-21 10:26:04 +02:00
Abdessamad Derraz 83a4b21d30 fix: keep platform hashes cores disagree on
When two cores declare different values for one file, the truth keeps the first and marks the entry hash_conflict. Its hashes pair an entry and never replace the platform's: armsx2's GameIndex.yaml no longer overwrites System.dat's line for LRPS2.
2026-10-21 09:57:20 +02:00
Abdessamad Derraz f7b758a41d fix: patch batocera entries past commented items
_patched_entry read '#{ ... }' lines as live items, found no match in the model and gave up, so atarist was written again whole (52 lines changed for 3 additions). A commented item is now left as written.
2026-10-21 09:52:34 +02:00
Abdessamad Derraz 5ec1208a83 fix: write romm keys with a bare file name
RomM lists the platform firmware folder without recursing and looks each file up as slug:file_name (models/firmware.py, base_handler.list_files at 5.4.0). An addition named with a directory (fuse/48.rom) is not written.
2026-10-21 09:51:32 +02:00