From c63a7e45b11880b94234eb1e293f5e6f3db0fb33 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Sun, 18 Oct 2026 18:14:36 +0200 Subject: [PATCH] fix: detect ROCKNIX by the OS_NAME it writes --- install.ps1 | 2 +- install.py | 14 ++++++++++---- install.sh | 2 +- install/lakka.json | 4 +++- install/rocknix.json | 5 ++++- platforms/_registry.yml | 4 ++-- tests/test_install.py | 6 ++++-- wiki/installer.md | 2 +- 8 files changed, 26 insertions(+), 13 deletions(-) diff --git a/install.ps1 b/install.ps1 index f5b961f7..33c2b253 100644 --- a/install.ps1 +++ b/install.ps1 @@ -8,7 +8,7 @@ param( $ErrorActionPreference = "Stop" $defaultInstallUrl = "https://raw.githubusercontent.com/Abdess/retrobios/main/install.py" -$defaultInstallSha256 = "b6a3729bd7b1e954f691b915355b81b0f310de2eb21c5a34cbc5637b5cf06f07" +$defaultInstallSha256 = "7fb25b2ee8d7cdab5c852431732cf8ef92e6e9a81d24aeae7cb24b34dd413660" $maximumInstallerBytes = 2MB $installerExit = 0 $installer = if ($PSScriptRoot) { Join-Path $PSScriptRoot "install.py" } else { $null } diff --git a/install.py b/install.py index 826cffed..64c72d67 100644 --- a/install.py +++ b/install.py @@ -670,9 +670,11 @@ def _parse_ps1_var(path: Path, key: str) -> str | None: # markers. The registry publishes the same rules as each manifest's # `detect`; a test holds the two equal. MiSTer is a path rule below. _EMBEDDED_RULES: tuple[tuple[str, str, tuple[str, ...], str], ...] = ( - ("rocknix", "os_release", ("rocknix",), "/storage/roms/bios"), + # ROCKNIX writes OS_NAME and no ID since 2025 (scripts/image); older + # images wrote ID=rocknix. + ("rocknix", "os_release", ("OS_NAME=rocknix", "ID=rocknix"), "/storage/roms/bios"), ("batocera", "file_exists", ("/etc/knulli-release",), "/userdata/bios"), - ("lakka", "os_release", ("lakka",), "/storage/system"), + ("lakka", "os_release", ("ID=lakka",), "/storage/system"), ("batocera", "file_exists", ("/etc/batocera-version",), "/userdata/bios"), ("recalbox", "file_exists", ("/recalbox/recalbox.version",), "/recalbox/share/bios"), ("recalbox", "file_exists", ("/usr/bin/recalbox-settings",), "/recalbox/share/bios"), @@ -685,10 +687,14 @@ _EMBEDDED_RULES: tuple[tuple[str, str, tuple[str, ...], str], ...] = ( def _detect_embedded() -> list[tuple[str, Path]]: """Check for embedded Linux retrogaming OSes.""" - os_id = _parse_os_release().get("ID", "").lower() + release = {k: v.lower() for k, v in _parse_os_release().items()} for platform_name, method, values, bios in _EMBEDDED_RULES: if method == "os_release": - matched = os_id in values + # Any of the KEY=value pairs, the value compared without case. + matched = any( + release.get(key) == value.lower() + for key, _, value in (pair.partition("=") for pair in values) + ) else: matched = all(Path(value).exists() for value in values) if matched: diff --git a/install.sh b/install.sh index b722041a..27e7e78d 100755 --- a/install.sh +++ b/install.sh @@ -18,7 +18,7 @@ esac TEMP_INSTALLER="" TEMP_DIRECTORY="" DEFAULT_INSTALL_URL="https://raw.githubusercontent.com/Abdess/retrobios/main/install.py" -DEFAULT_INSTALL_SHA256="b6a3729bd7b1e954f691b915355b81b0f310de2eb21c5a34cbc5637b5cf06f07" +DEFAULT_INSTALL_SHA256="7fb25b2ee8d7cdab5c852431732cf8ef92e6e9a81d24aeae7cb24b34dd413660" MAX_INSTALLER_BYTES=2097152 cleanup() { diff --git a/install/lakka.json b/install/lakka.json index 975ec3b0..978f9e73 100644 --- a/install/lakka.json +++ b/install/lakka.json @@ -11,7 +11,9 @@ { "os": "linux", "method": "os_release", - "id": "lakka", + "match": [ + "ID=lakka" + ], "bios_path": "/storage/system" } ], diff --git a/install/rocknix.json b/install/rocknix.json index a3c35dfe..3dcee3c2 100644 --- a/install/rocknix.json +++ b/install/rocknix.json @@ -11,7 +11,10 @@ { "os": "linux", "method": "os_release", - "id": "rocknix", + "match": [ + "OS_NAME=rocknix", + "ID=rocknix" + ], "bios_path": "/storage/roms/bios" } ], diff --git a/platforms/_registry.yml b/platforms/_registry.yml index 46d7a2b7..00d97f2f 100644 --- a/platforms/_registry.yml +++ b/platforms/_registry.yml @@ -343,7 +343,7 @@ platforms: detect: - os: linux method: os_release - id: lakka + match: [ID=lakka] bios_path: /storage/system retrodeck: config: retrodeck.yml @@ -429,7 +429,7 @@ platforms: detect: - os: linux method: os_release - id: rocknix + match: [OS_NAME=rocknix, ID=rocknix] bios_path: /storage/roms/bios retropie: config: retropie.yml diff --git a/tests/test_install.py b/tests/test_install.py index 700e766c..19210a12 100644 --- a/tests/test_install.py +++ b/tests/test_install.py @@ -959,7 +959,7 @@ class DetectionFollowsTheRegistry(unittest.TestCase): for name, entry in registry["platforms"].items(): for rule in (entry.get("install") or {}).get("detect", []): if rule["method"] == "os_release": - rules.add((name, "os_release", (rule["id"],), rule["bios_path"])) + rules.add((name, "os_release", tuple(rule["match"]), rule["bios_path"])) elif rule["method"] == "file_exists": files = rule["file"] if isinstance(rule["file"], list) else [rule["file"]] rules.add((name, "file_exists", tuple(files), rule["bios_path"])) @@ -972,7 +972,9 @@ class DetectionFollowsTheRegistry(unittest.TestCase): lambda p: str(p) in ("/etc/knulli-release", "/etc/batocera-version"), ): self.assertEqual(install._detect_embedded(), [("batocera", Path("/userdata/bios"))]) - with unittest.mock.patch.object(install, "_parse_os_release", return_value={"ID": "ROCKNIX"}): + # What ROCKNIX writes since 2025: OS_NAME and HW_DEVICE, no ID. + with unittest.mock.patch.object(install, "_parse_os_release", + return_value={"OS_NAME": "ROCKNIX", "HW_DEVICE": "RK3566"}): self.assertEqual( install._detect_embedded(), [("rocknix", Path("/storage/roms/bios"))] ) diff --git a/wiki/installer.md b/wiki/installer.md index 844f2041..f2caf848 100644 --- a/wiki/installer.md +++ b/wiki/installer.md @@ -260,7 +260,7 @@ wins, since a machine is only one of them. | Evidence | Platform | BIOS directory | |----------|----------|----------------| -| `/etc/os-release` `ID=rocknix` | ROCKNIX | `/storage/roms/bios` | +| `/etc/os-release` `OS_NAME=ROCKNIX` (or `ID=rocknix` on images before 2025) | ROCKNIX | `/storage/roms/bios` | | `/etc/knulli-release` | Batocera | `/userdata/bios` | | `/etc/os-release` `ID=lakka` | Lakka | `/storage/system` | | `/etc/batocera-version` | Batocera | `/userdata/bios` |