fix: map a card's image name to its board

Batocera and KNULLI write the image name, not the board, to the card's board file (post-image-script.sh). The target scraper now records each board's images from Config.in, the target lists carry them, and the installer maps a card's image to its board. KNULLI's boot/knulli.board is read too.
This commit is contained in:
Abdessamad Derraz committed 2026-11-06 03:40:34 +01:00
1 parent 349914fda2
commit a2e8809945
14 files changed
+5236 -4691

No files matched your search

+40
View File
@@ -1584,6 +1584,8 @@ class TargetFlagIsAppliedOrRefused(unittest.TestCase):
with self.subTest(platform=platform):
self.assertEqual(sorted(targets), sorted(known))
for target, cores in targets.items():
# A target that names its card images carries them beside.
cores = cores["cores"] if isinstance(cores, dict) else cores
with self.subTest(platform=platform, target=target):
resolved = load_target_config(platform, target, platforms)
self.assertEqual(cores, None if resolved is None else sorted(resolved))
@@ -3347,6 +3349,44 @@ class ACardPreparedOnAComputerGetsItsBoard(unittest.TestCase):
files = {event["dest"] for event in events if event["event"] == "file"}
self.assertEqual(files, {"pi.bin"})
def test_a_card_naming_its_image_gets_the_board_of_that_image(self):
"""A Batocera RG35XX Plus card names anbernic-rg35xx-plus, a zen3 one
x86-64-v3: neither is a target name, and the card took every
board's files (9.0 GB where h700 reads 6.1)."""
(self.boot / "boot" / "batocera.board").write_text("anbernic-rg35xx-plus\n")
(self.list.parent / "targets" / "batocera.json").write_text(json.dumps({
"h700": {"cores": ["picore"], "images": ["anbernic-rg28xx",
"anbernic-rg35xx-plus"]},
"x86_64": ["pccore"]}))
out, events = self.run_main()
[board] = [event for event in events if event["event"] == "board"]
self.assertEqual((board["board"], board["applied"]), ("h700", True))
self.assertIn("Board h700 (anbernic-rg35xx-plus) found on the card", out)
files = {event["dest"] for event in events if event["event"] == "file"}
self.assertEqual(files, {"pi.bin"})
def test_an_image_two_boards_build_names_neither(self):
targets = install._validate_targets({
"zen3": {"cores": ["a"], "images": ["x86-64-v3"]},
"rk3326": {"cores": ["b"], "images": ["r36s"]},
"rk3566": {"cores": ["c"], "images": ["r36s"]}})
self.assertEqual(install.board_target("x86-64-v3", targets), "zen3")
self.assertEqual(install.board_target("zen3", targets), "zen3")
self.assertIsNone(install.board_target("r36s", targets))
def test_a_knulli_card_names_its_image_too(self):
(self.boot / "boot" / "knulli.board").write_text("rg35xx-plus\n")
with unittest.mock.patch.object(install, "_mounted_cards", return_value=[self.boot]):
self.assertEqual(install.card_board("knulli"), "rg35xx-plus")
published = json.loads((REPO_ROOT / "install" / "targets" / "knulli.json").read_text())
self.assertEqual(install.board_target(
"rg35xx-plus", install._validate_targets(published)), "h700")
batocera = install._validate_targets(json.loads(
(REPO_ROOT / "install" / "targets" / "batocera.json").read_text()))
for image, board in (("anbernic-rg35xx-plus", "h700"), ("x86-64-v3", "zen3"),
("odroidn2", "s922x"), ("bcm2711", "bcm2711")):
self.assertEqual(install.board_target(image, batocera), board)
def test_every_board_keeps_them_all(self):
_out, events = self.run_main("--every-board")
self.assertFalse([event for event in events if event["event"] == "board"])
+15 -4
View File
@@ -96,7 +96,9 @@ class FailedRequestsStopTheScrape(unittest.TestCase):
b"BR2_PACKAGE_BATOCERA_SYSTEM=y\n")
if url.endswith("Config.in"):
return _Body(b"config BR2_PACKAGE_BATOCERA_SYSTEM\n"
b"\tselect BR2_PACKAGE_MGBA\n")
b"\tselect BR2_PACKAGE_MGBA\n\n"
b"config BR2_TARGET_BATOCERA_IMAGES\n\tstring \"x\"\n"
b"\tdefault \"x86_64\" if BR2_PACKAGE_BATOCERA_TARGET_X86_64\n")
return _Body(
b"gba:\n emulators:\n libretro:\n"
b" mgba: {requireAnyOf: [BR2_PACKAGE_MGBA]}\n"
@@ -263,7 +265,14 @@ class KnulliPerBoard(unittest.TestCase):
"\tconfig BR2_PACKAGE_BATOCERA_GLES3\n\tdefault y\nendif\n\n"
"config BR2_PACKAGE_KNULLI_SYSTEM\n"
"\tselect BR2_PACKAGE_LIBRETRO_MGBA\n"
"\tselect BR2_PACKAGE_PPSSPP\tif BR2_PACKAGE_BATOCERA_GLES3\n"
"\tselect BR2_PACKAGE_PPSSPP\tif BR2_PACKAGE_BATOCERA_GLES3\n\n"
"config BR2_TARGET_KNULLI_IMAGES_DEFINITIONS\n"
"\tbool \"target images definitions\"\n"
"\tconfig BR2_TARGET_KNULLI_IMAGES\n\tstring \"target images\"\n"
"\tdefault \"allwinner/h700/rg35xx-sp allwinner/h700/rg35xx-plus\" \\\n"
"\t\tif BR2_PACKAGE_BATOCERA_TARGET_H700\n"
"\tdefault \"allwinner/r16/miyoo-a30\"\tif BR2_PACKAGE_BATOCERA_TARGET_SUNXI_R16\n\n"
"\tchoice\n\tprompt \"knulli target\"\n"
),
"package/emulationstation/knulli-es-system/es_systems.yml": (
"gba:\n emulators:\n libretro:\n"
@@ -316,10 +325,12 @@ class KnulliPerBoard(unittest.TestCase):
self.assertEqual(data["source"],
f"https://github.com/knulli-cfw/knulli-linux/tree/{pin}")
self.assertEqual(sorted(data["targets"]), ["h700", "r16"])
# The images name what a card's boot/knulli.board holds.
self.assertEqual(data["targets"]["h700"],
{"architecture": "aarch64", "cores": ["mgba", "ppsspp"]})
{"architecture": "aarch64", "cores": ["mgba", "ppsspp"],
"images": ["rg35xx-plus", "rg35xx-sp"]})
self.assertEqual(data["targets"]["r16"],
{"architecture": "arm", "cores": ["mgba"]})
{"architecture": "arm", "cores": ["mgba"], "images": ["miyoo-a30"]})
self.assertTrue(all(pin in url or "buildroot/c2d7985b" in url for url in seen), seen)