mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-20 18:59:07 -05:00
fix: detect ROCKNIX by the OS_NAME it writes
This commit is contained in:
1 parent
d430d361d9
commit
c63a7e45b1
8 files changed
+26
-13
No files matched your search
+1
-1
@@ -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 }
|
||||
|
||||
+10
-4
@@ -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:
|
||||
|
||||
+1
-1
@@ -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() {
|
||||
|
||||
+3
-1
@@ -11,7 +11,9 @@
|
||||
{
|
||||
"os": "linux",
|
||||
"method": "os_release",
|
||||
"id": "lakka",
|
||||
"match": [
|
||||
"ID=lakka"
|
||||
],
|
||||
"bios_path": "/storage/system"
|
||||
}
|
||||
],
|
||||
|
||||
@@ -11,7 +11,10 @@
|
||||
{
|
||||
"os": "linux",
|
||||
"method": "os_release",
|
||||
"id": "rocknix",
|
||||
"match": [
|
||||
"OS_NAME=rocknix",
|
||||
"ID=rocknix"
|
||||
],
|
||||
"bios_path": "/storage/roms/bios"
|
||||
}
|
||||
],
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"))]
|
||||
)
|
||||
|
||||
+1
-1
@@ -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` |
|
||||
|
||||
Reference in new issue
Block a user