mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-10 13:33:24 -05:00
feat: read retropie version from its setup script
This commit is contained in:
1 parent
86e6d3a6fd
commit
6453a96d47
3 files changed
+44
-5
No files matched your search
@@ -1,5 +1,6 @@
|
|||||||
inherits: retroarch
|
inherits: retroarch
|
||||||
platform: RetroPie
|
platform: RetroPie
|
||||||
|
version: 4.8.12
|
||||||
homepage: "https://retropie.org.uk"
|
homepage: "https://retropie.org.uk"
|
||||||
source: "https://codeload.github.com/RetroPie/RetroPie-Setup/tar.gz/refs/heads/master"
|
source: "https://codeload.github.com/RetroPie/RetroPie-Setup/tar.gz/refs/heads/master"
|
||||||
base_destination: BIOS
|
base_destination: BIOS
|
||||||
|
|||||||
@@ -39,6 +39,10 @@ GITHUB_REPO = "RetroPie/RetroPie-Setup"
|
|||||||
MAX_ARCHIVE = 64 * 1024 * 1024
|
MAX_ARCHIVE = 64 * 1024 * 1024
|
||||||
|
|
||||||
_MODULE_ID = re.compile(r'^rp_module_id="([^"]+)"', re.MULTILINE)
|
_MODULE_ID = re.compile(r'^rp_module_id="([^"]+)"', re.MULTILINE)
|
||||||
|
# RetroPie updates in place from master, so its release tags stop at the last
|
||||||
|
# SD image. The version a user runs is the one this script declares.
|
||||||
|
_VERSION_FILE = "retropie_packages.sh"
|
||||||
|
_VERSION = re.compile(r'^__version="([^"]+)"', re.MULTILINE)
|
||||||
# Sections RetroPie does not build as emulators: setup helpers, themes,
|
# Sections RetroPie does not build as emulators: setup helpers, themes,
|
||||||
# drivers and the like carry no core.
|
# drivers and the like carry no core.
|
||||||
_PACKAGE_DIRS = ("emulators", "libretrocores", "ports")
|
_PACKAGE_DIRS = ("emulators", "libretrocores", "ports")
|
||||||
@@ -50,6 +54,7 @@ class Scraper(BaseScraper):
|
|||||||
def __init__(self, url: str = SOURCE_URL):
|
def __init__(self, url: str = SOURCE_URL):
|
||||||
super().__init__(url=url)
|
super().__init__(url=url)
|
||||||
self._modules: list[str] | None = None
|
self._modules: list[str] | None = None
|
||||||
|
self._version = ""
|
||||||
|
|
||||||
def _fetch_archive(self) -> bytes:
|
def _fetch_archive(self) -> bytes:
|
||||||
request = urllib.request.Request(
|
request = urllib.request.Request(
|
||||||
@@ -77,16 +82,24 @@ class Scraper(BaseScraper):
|
|||||||
continue
|
continue
|
||||||
relative = member.name.split("/", 1)[-1]
|
relative = member.name.split("/", 1)[-1]
|
||||||
parts = relative.split("/")
|
parts = relative.split("/")
|
||||||
if len(parts) != 3 or parts[0] != "scriptmodules":
|
is_version_file = relative == _VERSION_FILE
|
||||||
continue
|
is_package = (
|
||||||
if parts[1] not in _PACKAGE_DIRS:
|
len(parts) == 3
|
||||||
|
and parts[0] == "scriptmodules"
|
||||||
|
and parts[1] in _PACKAGE_DIRS
|
||||||
|
)
|
||||||
|
if not (is_version_file or is_package):
|
||||||
continue
|
continue
|
||||||
handle = archive.extractfile(member)
|
handle = archive.extractfile(member)
|
||||||
if handle is None:
|
if handle is None:
|
||||||
continue
|
continue
|
||||||
text = handle.read().decode("utf-8", errors="replace")
|
text = handle.read().decode("utf-8", errors="replace")
|
||||||
match = _MODULE_ID.search(text)
|
match = (_VERSION if is_version_file else _MODULE_ID).search(text)
|
||||||
if match:
|
if not match:
|
||||||
|
continue
|
||||||
|
if is_version_file:
|
||||||
|
self._version = match.group(1)
|
||||||
|
else:
|
||||||
found.add(match.group(1))
|
found.add(match.group(1))
|
||||||
|
|
||||||
self._modules = sorted(found)
|
self._modules = sorted(found)
|
||||||
@@ -114,10 +127,13 @@ class Scraper(BaseScraper):
|
|||||||
# A libretro package is lr-<core>; a standalone package is named
|
# A libretro package is lr-<core>; a standalone package is named
|
||||||
# after the emulator itself.
|
# after the emulator itself.
|
||||||
cores = sorted({module.removeprefix("lr-") for module in self.module_ids()})
|
cores = sorted({module.removeprefix("lr-") for module in self.module_ids()})
|
||||||
|
if not self._version:
|
||||||
|
raise ValueError(f"{self.url}: no __version in {_VERSION_FILE}")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"inherits": "retroarch",
|
"inherits": "retroarch",
|
||||||
"platform": "RetroPie",
|
"platform": "RetroPie",
|
||||||
|
"version": self._version,
|
||||||
"homepage": "https://retropie.org.uk",
|
"homepage": "https://retropie.org.uk",
|
||||||
"source": SOURCE_URL,
|
"source": SOURCE_URL,
|
||||||
"base_destination": "BIOS",
|
"base_destination": "BIOS",
|
||||||
|
|||||||
@@ -165,6 +165,7 @@ class RetroPiePackageList(unittest.TestCase):
|
|||||||
def test_the_core_list_drops_the_libretro_prefix(self):
|
def test_the_core_list_drops_the_libretro_prefix(self):
|
||||||
scraper = self._scraper(
|
scraper = self._scraper(
|
||||||
{
|
{
|
||||||
|
"retropie_packages.sh": '__version="4.8.12"\n',
|
||||||
"scriptmodules/libretrocores/lr-mgba.sh": 'rp_module_id="lr-mgba"\n',
|
"scriptmodules/libretrocores/lr-mgba.sh": 'rp_module_id="lr-mgba"\n',
|
||||||
"scriptmodules/emulators/openmsx.sh": 'rp_module_id="openmsx"\n',
|
"scriptmodules/emulators/openmsx.sh": 'rp_module_id="openmsx"\n',
|
||||||
}
|
}
|
||||||
@@ -174,6 +175,27 @@ class RetroPiePackageList(unittest.TestCase):
|
|||||||
self.assertEqual(config["inherits"], "retroarch")
|
self.assertEqual(config["inherits"], "retroarch")
|
||||||
self.assertEqual(config["base_destination"], "BIOS")
|
self.assertEqual(config["base_destination"], "BIOS")
|
||||||
|
|
||||||
|
def test_the_version_is_the_one_the_setup_script_declares(self):
|
||||||
|
scraper = self._scraper(
|
||||||
|
{
|
||||||
|
"retropie_packages.sh": '#!/bin/bash\n__version="4.8.12"\n',
|
||||||
|
"scriptmodules/libretrocores/lr-mgba.sh": 'rp_module_id="lr-mgba"\n',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
self.assertEqual(scraper.generate_platform_yaml()["version"], "4.8.12")
|
||||||
|
|
||||||
|
def test_a_version_assigned_elsewhere_is_not_the_setup_version(self):
|
||||||
|
"""Only the top-level retropie_packages.sh speaks for the release."""
|
||||||
|
scraper = self._scraper(
|
||||||
|
{
|
||||||
|
"scriptmodules/emulators/openmsx.sh": (
|
||||||
|
'rp_module_id="openmsx"\n__version="1.0"\n'
|
||||||
|
),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
scraper.generate_platform_yaml()
|
||||||
|
|
||||||
def test_no_requirement_is_invented_from_prose(self):
|
def test_no_requirement_is_invented_from_prose(self):
|
||||||
"""RetroPie names BIOS in prose, without a hash to transcribe."""
|
"""RetroPie names BIOS in prose, without a hash to transcribe."""
|
||||||
scraper = self._scraper(
|
scraper = self._scraper(
|
||||||
|
|||||||
Reference in new issue
Block a user