mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-15 22:43:48 -06:00
fix: pick a Python that can do HTTPS
This commit is contained in:
1 parent
4d46587693
commit
bcedd22a9e
7 files changed
+118
-13
No files matched your search
@@ -1080,6 +1080,44 @@ class ThePortMasterPort(unittest.TestCase):
|
||||
self.assertIn("--dest", screen)
|
||||
self.assertEqual(device.calls(), [])
|
||||
|
||||
def _python_without_ssl(self, device) -> None:
|
||||
"""A python3 3.8 or newer whose ssl import fails, as on a CFW image
|
||||
built without OpenSSL."""
|
||||
real = shutil.which("python3.8") or sys.executable
|
||||
shadow = device.root / "no-ssl"
|
||||
shadow.mkdir()
|
||||
(shadow / "ssl.py").write_text('raise ImportError("built without ssl")\n')
|
||||
device.tool("python3", f'#!/bin/sh\nPYTHONPATH="{shadow}" exec {real} "$@"\n')
|
||||
|
||||
def test_a_python_without_ssl_is_told_on_the_console(self):
|
||||
"""Only the version was probed: a python3 without ssl was chosen and
|
||||
every download failed as if the network were down."""
|
||||
device = self.device()
|
||||
self._python_without_ssl(device)
|
||||
device.tool("uname", "#!/bin/sh\necho armv7l\n")
|
||||
proc = device.run(["bash", self.script])
|
||||
self.assertEqual(proc.returncode, 1)
|
||||
screen = " ".join(device.screen.split())
|
||||
self.assertIn("built without a module install.py needs", screen)
|
||||
self.assertEqual(device.calls(), [])
|
||||
|
||||
def test_a_python_without_ssl_gives_way_to_the_runtime(self):
|
||||
device = self.device()
|
||||
self._python_without_ssl(device)
|
||||
real = shutil.which("python3.8") or sys.executable
|
||||
device.tool("uname", "#!/bin/sh\necho aarch64\n")
|
||||
device.tool("mount", '#!/bin/sh\nprintf "mount %s\\n" "$*" >> "$FAKE_STATE/tools.log"\n'
|
||||
'mkdir -p "$2/bin"\n'
|
||||
f'printf \'#!/bin/sh\\nunset PYTHONHOME\\nexec {real} "$@"\\n\' > "$2/bin/python3"\n'
|
||||
'chmod +x "$2/bin/python3"\n')
|
||||
device.tool("umount", FAKE_RECORDER)
|
||||
(self.control / "libs").mkdir()
|
||||
(self.control / "libs" / "python_3.11.squashfs").write_bytes(b"")
|
||||
proc = device.run(["bash", self.script])
|
||||
self.assertEqual(proc.returncode, 0, proc.stderr.decode())
|
||||
[call] = device.tui_calls()
|
||||
self.assertTrue(any(t.startswith("mount") for t in device.tools()))
|
||||
|
||||
def test_the_runtime_is_mounted_then_unmounted(self):
|
||||
"""ArkOS's Python 3.7: PortMaster's python_3.11 runtime, mounted for
|
||||
the run and unmounted after it."""
|
||||
|
||||
@@ -2575,6 +2575,51 @@ class NoPythonNamesThisSystemsCommand(unittest.TestCase):
|
||||
self.assertNotIn("apt", proc.stderr)
|
||||
|
||||
|
||||
class ABootstrapPythonCanDoHttps(unittest.TestCase):
|
||||
"""find_python checked the version only: a python3 built without ssl
|
||||
was chosen over a full python, and every download then failed."""
|
||||
|
||||
def _bin(self) -> tuple[Path, Path]:
|
||||
root = Path(_tempdir(self))
|
||||
fake_bin = root / "bin"
|
||||
fake_bin.mkdir()
|
||||
for tool in ("sed", "tr", "dirname", "cat", "awk", "uname"):
|
||||
found = shutil.which(tool)
|
||||
if found:
|
||||
(fake_bin / tool).symlink_to(found)
|
||||
shadow = root / "no-ssl"
|
||||
shadow.mkdir()
|
||||
(shadow / "ssl.py").write_text('raise ImportError("built without ssl")\n')
|
||||
(fake_bin / "python3").write_text(
|
||||
f'#!/bin/sh\nPYTHONPATH="{shadow}" exec {shlex.quote(sys.executable)} "$@"\n')
|
||||
(fake_bin / "python3").chmod(0o755)
|
||||
(root / "install.py").write_text("import ssl; print('installer ran')\n")
|
||||
shutil.copy(REPO_ROOT / "install.sh", root / "install.sh")
|
||||
return root, fake_bin
|
||||
|
||||
def _run(self, root: Path, fake_bin: Path) -> subprocess.CompletedProcess:
|
||||
return subprocess.run(
|
||||
["/bin/sh", str(root / "install.sh")], cwd=root,
|
||||
env={"PATH": str(fake_bin), "HOME": str(root)},
|
||||
capture_output=True, text=True, timeout=30, check=False,
|
||||
stdin=subprocess.DEVNULL, start_new_session=True,
|
||||
)
|
||||
|
||||
def test_a_full_python_is_preferred(self):
|
||||
root, fake_bin = self._bin()
|
||||
(fake_bin / "python").symlink_to(sys.executable)
|
||||
proc = self._run(root, fake_bin)
|
||||
self.assertEqual(proc.returncode, 0, proc.stderr)
|
||||
self.assertIn("installer ran", proc.stdout)
|
||||
|
||||
def test_the_missing_module_is_named(self):
|
||||
root, fake_bin = self._bin()
|
||||
proc = self._run(root, fake_bin)
|
||||
self.assertEqual(proc.returncode, 1)
|
||||
self.assertNotIn("installer ran", proc.stdout)
|
||||
self.assertIn("python3 is built without a module the installer needs", proc.stderr)
|
||||
|
||||
|
||||
@unittest.skipUnless(shutil.which("pwsh") and shutil.which("script"), "needs PowerShell and a terminal")
|
||||
class WindowsWithoutPythonIsOfferedWinget(unittest.TestCase):
|
||||
"""A Windows machine without Python was told to install it, open a new
|
||||
|
||||
Reference in new issue
Block a user