mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-27 20:08:51 -06:00
refactor: one reader of the installer pin
The launcher builders read install.py's SHA-256 through pins.installer_sha256 and the value install.sh pins through pins.PIN, which now sits beside the pattern pin_installer writes with. build_port kept a third copy of that pattern.
This commit is contained in:
1 parent
b9c91a897d
commit
27bff61560
4 files changed
+12
-13
No files matched your search
@@ -8,6 +8,7 @@ import json
|
||||
from pathlib import Path
|
||||
|
||||
from core.paths import REPO_ROOT
|
||||
from installer_build.pins import installer_sha256
|
||||
from installer_build.port import (
|
||||
BATOCERA_ZIP,
|
||||
MUOS_APP,
|
||||
@@ -53,7 +54,7 @@ def _member_bytes(entry: dict, root: Path) -> bytes:
|
||||
|
||||
def build_index(root: Path = REPO_ROOT) -> dict:
|
||||
"""Every launcher a card can carry, from the archives' members."""
|
||||
actual = hashlib.sha256((root / "install.py").read_bytes()).hexdigest()
|
||||
actual = installer_sha256(root)
|
||||
if actual != pinned_installer_sha256(root):
|
||||
raise ValueError("install.py is not the installer install.sh pins: re-pin the "
|
||||
"bootstraps before writing the launcher list")
|
||||
|
||||
@@ -17,6 +17,11 @@ PINS: dict[str, re.Pattern[str]] = {
|
||||
"install.sh": re.compile(r'^(DEFAULT_INSTALL_SHA256=")[0-9a-f]{64}(")', re.M),
|
||||
"install.ps1": re.compile(r'^(\s*\$defaultInstallSha256 = ")[0-9a-f]{64}(")', re.M),
|
||||
}
|
||||
# The value of that pin line, by the name the site serves each bootstrap under.
|
||||
PIN: dict[str, re.Pattern[str]] = {
|
||||
SH_NAME: re.compile(r'^DEFAULT_INSTALL_SHA256="([0-9a-f]{64})"', re.M),
|
||||
PS1_NAME: re.compile(r'^\s*\$defaultInstallSha256 = "([0-9a-f]{64})"', re.M),
|
||||
}
|
||||
COMMAND = "python scripts/pin_installer.py"
|
||||
|
||||
|
||||
@@ -50,9 +55,3 @@ def write_pins(root: Path = ROOT) -> list[str]:
|
||||
path.write_bytes(new.encode("utf-8"))
|
||||
written.append(name)
|
||||
return written
|
||||
|
||||
|
||||
PIN: dict[str, re.Pattern[str]] = {
|
||||
SH_NAME: re.compile(r'^DEFAULT_INSTALL_SHA256="([0-9a-f]{64})"', re.M),
|
||||
PS1_NAME: re.compile(r'^\s*\$defaultInstallSha256 = "([0-9a-f]{64})"', re.M),
|
||||
}
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import re
|
||||
import zipfile
|
||||
from pathlib import Path
|
||||
|
||||
from core.paths import REPO_ROOT
|
||||
from installer_build.pins import PIN, installer_sha256
|
||||
from model.guides import SH_NAME
|
||||
|
||||
|
||||
PORT_DIR = "retrobios"
|
||||
@@ -20,12 +20,11 @@ TOOLS_ZIP = "RetroBIOS-tools.zip"
|
||||
ARCHIVES = (PORT_ZIP, BATOCERA_ZIP, MUOS_APP, TOOLS_ZIP)
|
||||
# Which release pack serves each platform, read by tui.txt offline.
|
||||
PACKS_TABLE = "packs.txt"
|
||||
_PIN = re.compile(r'^DEFAULT_INSTALL_SHA256="([0-9a-f]{64})"$', re.MULTILINE)
|
||||
|
||||
|
||||
def pinned_installer_sha256(root: Path = REPO_ROOT) -> str:
|
||||
"""The SHA-256 install.sh accepts for install.py."""
|
||||
found = _PIN.search((root / "install.sh").read_text(encoding="utf-8"))
|
||||
found = PIN[SH_NAME].search((root / "install.sh").read_text(encoding="utf-8"))
|
||||
if found is None:
|
||||
raise ValueError("install.sh pins no installer SHA-256")
|
||||
return found.group(1)
|
||||
@@ -137,7 +136,7 @@ def _packs_table(root: Path) -> bytes:
|
||||
def build_archive(name: str, output: Path, root: Path = REPO_ROOT) -> Path:
|
||||
"""Write the launcher archive *name* to *output* and return it."""
|
||||
pinned = pinned_installer_sha256(root)
|
||||
actual = hashlib.sha256((root / "install.py").read_bytes()).hexdigest()
|
||||
actual = installer_sha256(root)
|
||||
if actual != pinned:
|
||||
raise ValueError(
|
||||
f"install.py is {actual[:12]}, install.sh pins {pinned[:12]}: "
|
||||
|
||||
@@ -33,7 +33,7 @@ SOURCES: dict[str, tuple[str, re.Pattern[str]]] = {
|
||||
SH_NAME: ("install.sh", re.compile(r'^(DEFAULT_INSTALL_URL=")[^"]*(")', re.M)),
|
||||
PS1_NAME: ("install.ps1", re.compile(r'^(\s*\$defaultInstallUrl = ")[^"]*(")', re.M)),
|
||||
}
|
||||
# The line each bootstrap says a refused installer with, and the pin.
|
||||
# The line each bootstrap says a refused installer with.
|
||||
ADVICE: dict[str, re.Pattern[str]] = {
|
||||
SH_NAME: re.compile(r'^(MISMATCH_ADVICE=")[^"]*(")', re.M),
|
||||
PS1_NAME: re.compile(r'^(\s*\$mismatchAdvice = ")[^"]*(")', re.M),
|
||||
|
||||
Reference in new issue
Block a user