mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-06 01:53:56 -06:00
feat: narrow a retropie install to its pi
This commit is contained in:
1 parent
fbc530123e
commit
d78af1b00d
6 files changed
+94
-13
No files matched your search
+1
-1
@@ -16,7 +16,7 @@
|
||||
# and Invoke-WebRequest throws on a cut transfer before the hash is read:
|
||||
# the site's build rewrites this line there (scripts/sitebootstrap.py).
|
||||
$mismatchAdvice = "The download was most likely cut short: try again. Within minutes of an update of this project the two files can come from caches of different ages. Waiting five minutes settles that."
|
||||
$defaultInstallSha256 = "389da8c666aecb14f32e064a53f05a9cc26481317ad5a877688c3e485b6c6e44"
|
||||
$defaultInstallSha256 = "65f7d49de83de9d99734293009762adaff6f844c2c3627f507d4dc3b029f57be"
|
||||
$maximumInstallerBytes = 2MB
|
||||
$installerExit = 0
|
||||
$installer = if ($PSScriptRoot) { Join-Path $PSScriptRoot "install.py" } else { $null }
|
||||
|
||||
+45
-1
@@ -1468,6 +1468,7 @@ _BOARD_SOURCES: dict[str, tuple[str, str]] = {
|
||||
"rocknix": ("os_release", "HW_DEVICE"),
|
||||
"lakka": ("os_release", "LIBREELEC_DEVICE|LIBREELEC_PROJECT"),
|
||||
"knulli": ("file", "/usr/share/knulli/knulli.arch"),
|
||||
"retropie": ("retropie", ""),
|
||||
}
|
||||
|
||||
# The board a system's own name stands for, where the two differ: the
|
||||
@@ -1520,6 +1521,8 @@ def detect_board(platform: str) -> str | None:
|
||||
elif kind == "os_release":
|
||||
release = _parse_os_release()
|
||||
value = next((release[key] for key in where.split("|") if release.get(key)), "")
|
||||
elif kind == "retropie":
|
||||
value = _retropie_board() or ""
|
||||
else:
|
||||
return None
|
||||
board = value.strip().lower()
|
||||
@@ -1529,6 +1532,46 @@ def detect_board(platform: str) -> str | None:
|
||||
return _BOARD_NAMES.get(platform, {}).get(board, board) or None
|
||||
|
||||
|
||||
# RetroPie names its board as get_platform does (RetroPie-Setup f5ebfba6,
|
||||
# scriptmodules/system.sh:396-424 and 425-513): a Pi by the BCM Hardware
|
||||
# line of /proc/cpuinfo or raspberrypi in its device tree, its model by the
|
||||
# CPU field (bits 12-15) of a revision code with bit 23 set, rpi1 without
|
||||
# it. With neither a Hardware line nor a device tree, the machine: x86_64.
|
||||
# Read only where RetroPie is installed (rootdir /opt/retropie,
|
||||
# retropie_packages.sh:17): a computer preparing a Pi's card is no Pi.
|
||||
_RPI_MODELS = {0: "rpi1", 1: "rpi2", 2: "rpi3", 3: "rpi4", 4: "rpi5"}
|
||||
|
||||
|
||||
def _retropie_board() -> str | None:
|
||||
"""The target RetroPie's own reading of this machine names, or None."""
|
||||
if not _is_dir(_on_device("/opt/retropie")):
|
||||
return None
|
||||
try:
|
||||
cpuinfo = _on_device("/proc/cpuinfo").read_text(encoding="utf-8", errors="replace")
|
||||
except OSError:
|
||||
cpuinfo = ""
|
||||
fields = {key.strip(): value.strip() for key, sep, value in
|
||||
(line.partition(":") for line in cpuinfo.splitlines()) if sep}
|
||||
tree = _on_device("/proc/device-tree/compatible")
|
||||
try:
|
||||
compatible = tree.read_bytes().decode("ascii", errors="replace")
|
||||
except OSError:
|
||||
compatible = None
|
||||
hardware = fields.get("Hardware", "")
|
||||
if hardware.startswith("BCM") or (not hardware and compatible is not None
|
||||
and "raspberrypi" in compatible):
|
||||
try:
|
||||
revision = int(fields.get("Revision", ""), 16)
|
||||
except ValueError:
|
||||
return None
|
||||
if not (revision >> 23) & 1:
|
||||
return "rpi1"
|
||||
return _RPI_MODELS.get((revision >> 12) & 15)
|
||||
if hardware or compatible is not None:
|
||||
return None
|
||||
return "x86_64" if platform.machine() == "x86_64" else None
|
||||
|
||||
|
||||
def _parse_json_path(path: Path, *keys: str) -> str | None:
|
||||
"""Extract a nested string value from a JSON file."""
|
||||
if not _exists(path):
|
||||
@@ -12997,7 +13040,8 @@ def build_parser() -> argparse.ArgumentParser:
|
||||
"--target",
|
||||
metavar="NAME",
|
||||
help="hardware target for core filtering (switch, rpi4, ...). "
|
||||
"On Batocera, Recalbox, ROCKNIX, Lakka and KNULLI the board is read from the system",
|
||||
"On Batocera, Recalbox, ROCKNIX, Lakka, KNULLI and RetroPie the board is read "
|
||||
"from the system",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--every-board",
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ DEFAULT_INSTALL_URL="https://raw.githubusercontent.com/Abdess/retrobios/main/ins
|
||||
# curl or wget stop on a cut transfer before the hash is read: the site's
|
||||
# build rewrites this line there (scripts/sitebootstrap.py).
|
||||
MISMATCH_ADVICE="The download was most likely cut short: try again. Within minutes of an update of this project the two files can come from caches of different ages. Waiting five minutes settles that."
|
||||
DEFAULT_INSTALL_SHA256="389da8c666aecb14f32e064a53f05a9cc26481317ad5a877688c3e485b6c6e44"
|
||||
DEFAULT_INSTALL_SHA256="65f7d49de83de9d99734293009762adaff6f844c2c3627f507d4dc3b029f57be"
|
||||
MAX_INSTALLER_BYTES=2097152
|
||||
|
||||
cleanup() {
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
{
|
||||
"dest": "roms/ports/retrobios/install.py",
|
||||
"repo_path": "install.py",
|
||||
"size": 1093006,
|
||||
"sha256": "389da8c666aecb14f32e064a53f05a9cc26481317ad5a877688c3e485b6c6e44",
|
||||
"size": 1094917,
|
||||
"sha256": "65f7d49de83de9d99734293009762adaff6f844c2c3627f507d4dc3b029f57be",
|
||||
"executable": false
|
||||
},
|
||||
{
|
||||
@@ -71,8 +71,8 @@
|
||||
"muos": {
|
||||
"archive": {
|
||||
"dest": "ARCHIVE/RetroBIOS.muxapp",
|
||||
"size": 1146633,
|
||||
"sha256": "c221a6529cb99a510a28eb739a69237cd1b77fb0d9b9a97b3a7e14acc275b54a"
|
||||
"size": 1148544,
|
||||
"sha256": "ba22f19af63c4003f7195636f6c7a5ebe3900ce6a300fe089058ff78eff52eb2"
|
||||
},
|
||||
"members": [
|
||||
{
|
||||
@@ -92,8 +92,8 @@
|
||||
{
|
||||
"name": "RetroBIOS/install.py",
|
||||
"repo_path": "install.py",
|
||||
"size": 1093006,
|
||||
"sha256": "389da8c666aecb14f32e064a53f05a9cc26481317ad5a877688c3e485b6c6e44",
|
||||
"size": 1094917,
|
||||
"sha256": "65f7d49de83de9d99734293009762adaff6f844c2c3627f507d4dc3b029f57be",
|
||||
"executable": false
|
||||
},
|
||||
{
|
||||
@@ -166,8 +166,8 @@
|
||||
{
|
||||
"dest": ".config/modules/retrobios/install.py",
|
||||
"repo_path": "install.py",
|
||||
"size": 1093006,
|
||||
"sha256": "389da8c666aecb14f32e064a53f05a9cc26481317ad5a877688c3e485b6c6e44",
|
||||
"size": 1094917,
|
||||
"sha256": "65f7d49de83de9d99734293009762adaff6f844c2c3627f507d4dc3b029f57be",
|
||||
"executable": false
|
||||
},
|
||||
{
|
||||
|
||||
@@ -3400,6 +3400,42 @@ class TheBoardTheSystemNamesIsTheTarget(unittest.TestCase):
|
||||
self.assertEqual(install.detect_board("rocknix"), "rk3326")
|
||||
self.assertIsNone(install.detect_board("retroarch"))
|
||||
|
||||
def test_retropie_names_its_pi_as_get_platform_does(self):
|
||||
"""A RetroPie Pi 4 installed every target's files, 8.4 GiB where
|
||||
rpi4 needs 4.0: nothing read the Pi model."""
|
||||
root = Path(_tempdir(self))
|
||||
(root / "proc" / "device-tree").mkdir(parents=True)
|
||||
cpuinfo = root / "proc" / "cpuinfo"
|
||||
tree = root / "proc" / "device-tree" / "compatible"
|
||||
cases = (
|
||||
("Hardware\t: BCM2835\nRevision\t: c03114\n", None, "rpi4"),
|
||||
("Revision\t: d04170\n", b"raspberrypi,5-model-b\0brcm,bcm2712\0", "rpi5"),
|
||||
("Hardware\t: BCM2835\nRevision\t: a02082\n", None, "rpi3"),
|
||||
("Hardware\t: BCM2835\nRevision\t: 000e\n", None, "rpi1"),
|
||||
("Hardware\t: ODROIDC\n", None, None),
|
||||
)
|
||||
with unittest.mock.patch.object(install, "_SYSTEM_ROOT", root):
|
||||
# Not installed here: a computer preparing a Pi's card.
|
||||
cpuinfo.write_text(cases[0][0])
|
||||
self.assertIsNone(install.detect_board("retropie"))
|
||||
(root / "opt" / "retropie").mkdir(parents=True)
|
||||
for text, compatible, board in cases:
|
||||
with self.subTest(board=board, text=text):
|
||||
cpuinfo.write_text(text)
|
||||
if compatible is None:
|
||||
tree.unlink(missing_ok=True)
|
||||
else:
|
||||
tree.write_bytes(compatible)
|
||||
self.assertEqual(install.detect_board("retropie"), board)
|
||||
tree.unlink(missing_ok=True)
|
||||
cpuinfo.write_text("processor\t: 0\n")
|
||||
with unittest.mock.patch.object(install.platform, "machine",
|
||||
return_value="x86_64"):
|
||||
self.assertEqual(install.detect_board("retropie"), "x86_64")
|
||||
targets = json.loads((REPO_ROOT / "install" / "targets" / "retropie.json")
|
||||
.read_text(encoding="utf-8"))
|
||||
self.assertLessEqual({*install._RPI_MODELS.values(), "x86_64"}, set(targets))
|
||||
|
||||
def test_lakka_names_its_device_or_its_project(self):
|
||||
# An RPi4 Lakka installed 5.7 GB of every board's files: its board
|
||||
# was in os-release and never read.
|
||||
|
||||
+3
-2
@@ -958,7 +958,7 @@ what the options name, everything by default.
|
||||
|--------|--------|
|
||||
| <span id="option-platform"></span>`--platform NAME` | Install for this platform instead of the detected one. A system `--list-platforms` names under its own files (`muos`, `arkos`) stands for the file list it gets, and the run says which. ES-DE, LaunchBox and Android, which keep no BIOS folder, are answered with the run that fills each emulator's folder. Unknown names are refused with the closest ones |
|
||||
| <span id="option-dest"></span>`--dest PATH` | Destination directory, overriding detection. Without `--platform`, the file list is the platform detected here: at a terminal the installer asks, Enter taking the one found, and otherwise it uses the one found, RetroArch's when nothing is found, and refuses when several are. The run prints whose list it is. A folder that does not exist is named with the nearest one that does, then created, except for a system that runs from its SD card, which refuses it. When more than its last level is missing (a mistyped path), a run at a terminal asks first, and the answer defaults to no |
|
||||
| <span id="option-target"></span>`--target NAME` | Keep only the files the cores of that hardware target need, and the systems they emulate. An unknown target is refused rather than ignored, since carrying on would install everything. On Batocera, Recalbox, ROCKNIX, Lakka and KNULLI the board is read from the system (`batocera.arch`, `recalbox.arch`, `HW_DEVICE`, `LIBREELEC_DEVICE` or `LIBREELEC_PROJECT`, `knulli.arch`) and applied when no `--target` is given, from a pack alone too when it carries the core list per board. On a computer, the board a Batocera card names on its BATOCERA partition (`boot/batocera.board`) is applied the same way, in line mode and on the full screen |
|
||||
| <span id="option-target"></span>`--target NAME` | Keep only the files the cores of that hardware target need, and the systems they emulate. An unknown target is refused rather than ignored, since carrying on would install everything. On Batocera, Recalbox, ROCKNIX, Lakka, KNULLI and RetroPie the board is read from the system (`batocera.arch`, `recalbox.arch`, `HW_DEVICE`, `LIBREELEC_DEVICE` or `LIBREELEC_PROJECT`, `knulli.arch`, the Pi model in `/proc/cpuinfo` where `/opt/retropie` exists) and applied when no `--target` is given, from a pack alone too when it carries the core list per board. On a computer, the board a Batocera card names on its BATOCERA partition (`boot/batocera.board`) is applied the same way, in line mode and on the full screen |
|
||||
| <span id="option-every-board"></span>`--every-board` | Install the files of every board instead of the one the system names, for a card that moves between devices |
|
||||
| <span id="option-installed-cores"></span>`--installed-cores` | Keep only what the cores already installed read (RetroArch, Lakka, RetroPie). See [Installed cores](#installed-cores) |
|
||||
| <span id="option-cores-dir"></span>`--cores-dir PATH` | The folder RetroArch loads its cores from, for `--installed-cores` when it is not found. Implies `--installed-cores`. A folder that does not exist or cannot be opened is refused with the reason (code 1) |
|
||||
@@ -1059,7 +1059,8 @@ image or source of its Odroid Go builds is published, so neither its marker
|
||||
files nor its folder could be read.
|
||||
|
||||
Batocera, Recalbox, ROCKNIX, Lakka and KNULLI also name the board they were built
|
||||
for, and that board narrows the install unless `--target` or `--every-board` says
|
||||
for, RetroPie reads the Pi model as its setup script does (`x86_64` on a PC),
|
||||
and that board narrows the install unless `--target` or `--every-board` says
|
||||
otherwise (see the options above). A board with no core list of its own is
|
||||
named and gets the files of every board. KNULLI writes its board to
|
||||
`/usr/share/knulli/knulli.arch` under the name of the chip its board file
|
||||
|
||||
Reference in new issue
Block a user