diff --git a/install.ps1 b/install.ps1 index eadcf2fbe..083a4ea7c 100644 --- a/install.ps1 +++ b/install.ps1 @@ -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 = "4e30340981c2e28c197256042d005361196eda47f3490fae52f823b7da1f4a20" + $defaultInstallSha256 = "d22f3e21b4552873934cb50f09d44fca59d567c561d3654f8408e434c8060aaa" # The pin above refuses any changed byte: this cap only stops a body that # cannot be the installer (a sign-in portal's page) before it is hashed. $maximumInstallerBytes = 8MB diff --git a/install.py b/install.py index 6af2d0866..6afa94b7b 100644 --- a/install.py +++ b/install.py @@ -24590,7 +24590,8 @@ def _tui_app_ready(state: TuiState) -> bool: """Whether the RetroBIOS app can go on this card: its system has one, and the run may use the network to fetch it.""" card = _tui_card(state) - return card is not None and card.place is not None and not LOCAL.offline + return card is not None and card.place is not None and not ( + state.offline or LOCAL.pack is not None) def _tui_installed(state: TuiState) -> bool: @@ -30224,8 +30225,8 @@ def _option_offline(state: TuiState, step: int) -> list[tuple]: state.status = _styled("Open Device once first: without the internet the " "board list has to be read already.", "refusal") return [] - # Set in this process by the effect, as --offline sets it: the - # runs started next inherit it, and their command names it. + # The screens read state.offline. The effect carries the choice to + # this process's own fetches and to the runs started next. state.offline = on return [("offline", on)] @@ -30338,15 +30339,6 @@ def use_tui_pack(pack: PackSource) -> None: LOCAL.pack = pack -def set_offline(on: bool) -> None: - """Without the internet on or off for this process and the runs it - starts, as --offline sets it.""" - if on: - os.environ[OFFLINE_VARIABLE] = OFFLINE_FLAG_VALUE - else: - os.environ.pop(OFFLINE_VARIABLE, None) - - def _open_from_browser(state: TuiState) -> list[tuple]: """The browser, to name an old card, a backup or a ZIP to copy from.""" state.browse_for = "from" @@ -31843,6 +31835,15 @@ def tui_suspend(runs: list[_EngineRun], whole: bool) -> None: run.pause(False) +def set_offline(on: bool) -> None: + """Without the internet on or off for this process and the runs it + starts, as --offline sets it.""" + if on: + os.environ[OFFLINE_VARIABLE] = OFFLINE_FLAG_VALUE + else: + os.environ.pop(OFFLINE_VARIABLE, None) + + class _TuiSignals: """What the signal handlers saw, read by the screen between frames.""" diff --git a/install.sh b/install.sh index c371a8cfc..7fc589129 100755 --- a/install.sh +++ b/install.sh @@ -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="4e30340981c2e28c197256042d005361196eda47f3490fae52f823b7da1f4a20" +DEFAULT_INSTALL_SHA256="d22f3e21b4552873934cb50f09d44fca59d567c561d3654f8408e434c8060aaa" # The pin above refuses any changed byte: this cap only stops a body that # cannot be the installer (a sign-in portal's page) before it is hashed. MAX_INSTALLER_BYTES=8388608 diff --git a/install/launchers/index.json b/install/launchers/index.json index da9a9c1b4..31925bcce 100644 --- a/install/launchers/index.json +++ b/install/launchers/index.json @@ -27,8 +27,8 @@ { "dest": "roms/ports/retrobios/install.py", "repo_path": "install.py", - "size": 1487677, - "sha256": "4e30340981c2e28c197256042d005361196eda47f3490fae52f823b7da1f4a20", + "size": 1487717, + "sha256": "d22f3e21b4552873934cb50f09d44fca59d567c561d3654f8408e434c8060aaa", "executable": false }, { @@ -71,8 +71,8 @@ "muos": { "archive": { "dest": "ARCHIVE/RetroBIOS.muxapp", - "size": 1541302, - "sha256": "e4ad81376894def15823a914b5173b8f6b67ee10be663836ca33c05044134937" + "size": 1541342, + "sha256": "621a0d612b8763db6cb42d281bcf0c4c9d97475c8e8d7400d2f34c4affe4c02d" }, "members": [ { @@ -92,8 +92,8 @@ { "name": "RetroBIOS/install.py", "repo_path": "install.py", - "size": 1487677, - "sha256": "4e30340981c2e28c197256042d005361196eda47f3490fae52f823b7da1f4a20", + "size": 1487717, + "sha256": "d22f3e21b4552873934cb50f09d44fca59d567c561d3654f8408e434c8060aaa", "executable": false }, { @@ -166,8 +166,8 @@ { "dest": ".config/modules/retrobios/install.py", "repo_path": "install.py", - "size": 1487677, - "sha256": "4e30340981c2e28c197256042d005361196eda47f3490fae52f823b7da1f4a20", + "size": 1487717, + "sha256": "d22f3e21b4552873934cb50f09d44fca59d567c561d3654f8408e434c8060aaa", "executable": false }, { diff --git a/installer/tui_actions.py b/installer/tui_actions.py index fd40c795a..944cb08ff 100644 --- a/installer/tui_actions.py +++ b/installer/tui_actions.py @@ -42,9 +42,8 @@ from installer.install_record import ( setup_record, take_recorded_choice, ) -from installer.invocation import OFFLINE_VARIABLE from installer.lists import local_targets -from installer.offline import LOCAL, OFFLINE_FLAG_VALUE +from installer.offline import LOCAL from installer.pack import _listed from installer.pack_source import PackSource from installer.paths import shown_path @@ -1211,8 +1210,8 @@ def _option_offline(state: TuiState, step: int) -> list[tuple]: state.status = _styled("Open Device once first: without the internet the " "board list has to be read already.", "refusal") return [] - # Set in this process by the effect, as --offline sets it: the - # runs started next inherit it, and their command names it. + # The screens read state.offline. The effect carries the choice to + # this process's own fetches and to the runs started next. state.offline = on return [("offline", on)] @@ -1325,15 +1324,6 @@ def use_tui_pack(pack: PackSource) -> None: LOCAL.pack = pack -def set_offline(on: bool) -> None: - """Without the internet on or off for this process and the runs it - starts, as --offline sets it.""" - if on: - os.environ[OFFLINE_VARIABLE] = OFFLINE_FLAG_VALUE - else: - os.environ.pop(OFFLINE_VARIABLE, None) - - def _open_from_browser(state: TuiState) -> list[tuple]: """The browser, to name an old card, a backup or a ZIP to copy from.""" state.browse_for = "from" diff --git a/installer/tui_commands.py b/installer/tui_commands.py index 47285ed89..67b9a8409 100644 --- a/installer/tui_commands.py +++ b/installer/tui_commands.py @@ -150,7 +150,8 @@ def _tui_app_ready(state: TuiState) -> bool: """Whether the RetroBIOS app can go on this card: its system has one, and the run may use the network to fetch it.""" card = _tui_card(state) - return card is not None and card.place is not None and not LOCAL.offline + return card is not None and card.place is not None and not ( + state.offline or LOCAL.pack is not None) def _tui_installed(state: TuiState) -> bool: diff --git a/installer/tui_session.py b/installer/tui_session.py index 2bdbde024..6f4094cb5 100644 --- a/installer/tui_session.py +++ b/installer/tui_session.py @@ -35,8 +35,8 @@ from installer.detect_os import _enter_wsl, _wsl_dest, detect_os, detected_os from installer.from_folders import from_folder_refusal, open_list_and_pack, reset_local_sources from installer.host_fs import _DETECTION_REFUSED, refused_words from installer.install_record import choice_given -from installer.invocation import _INVOCATION -from installer.offline import LOCAL +from installer.invocation import _INVOCATION, OFFLINE_VARIABLE +from installer.offline import LOCAL, OFFLINE_FLAG_VALUE from installer.outcome import LINE_SAVE_REMEDY from installer.platforms import normalize_platform from installer.regions import resolve_regions @@ -50,7 +50,6 @@ from installer.tui_actions import ( _platform_focus, _take_card, open_tui_pack, - set_offline, tui_interrupt, use_tui_pack, ) @@ -544,6 +543,15 @@ def tui_suspend(runs: list[_EngineRun], whole: bool) -> None: run.pause(False) +def set_offline(on: bool) -> None: + """Without the internet on or off for this process and the runs it + starts, as --offline sets it.""" + if on: + os.environ[OFFLINE_VARIABLE] = OFFLINE_FLAG_VALUE + else: + os.environ.pop(OFFLINE_VARIABLE, None) + + class _TuiSignals: """What the signal handlers saw, read by the screen between frames.""" diff --git a/tests/test_install_tui.py b/tests/test_install_tui.py index cb6d25e8e..7f3247028 100644 --- a/tests/test_install_tui.py +++ b/tests/test_install_tui.py @@ -4380,7 +4380,6 @@ class OfflineToggleStalesTheCheck(unittest.TestCase): state.checked_flags = install.tui_flags(state) self.assertIn(("--offline", None), state.checked_flags) self.assertEqual(install._option_offline(state, 0), [("offline", False)]) - install.set_offline(False) self.assertNotIn(("--offline", None), install.tui_flags(state)) self.assertEqual(install._begin_install(state), [("run", "confirm")]) @@ -5436,9 +5435,8 @@ class AppOnTheCard(unittest.TestCase): for name, state in cases.items(): with self.subTest(case=name): self.assertEqual(install.tui_rows(state), []) - os.environ[install.OFFLINE_VARIABLE] = "1" + offline.offline = True self.assertEqual(install.tui_rows(offline), []) - os.environ.pop(install.OFFLINE_VARIABLE) _title, lines = install.tui_outcome(cases["no launcher"]) self.assertIn(install.no_python_words("Onion"), lines) @@ -5469,6 +5467,17 @@ class AppOnTheCard(unittest.TestCase): plain.stack = ["plan", "options"] self.assertFalse(any(row.action == "addapp" for row in install.tui_rows(plain))) + def test_offline_on_the_screen_drops_the_flag_before_its_effect(self): + _root, bios = _app_card(self, "muOS") + state = _installed_state(bios) + state.add_app = True + with mock.patch.dict(os.environ): + os.environ.pop(install.OFFLINE_VARIABLE, None) + state.offline = True + argv = install.tui_argv(state, "install", "py", "install.py") + self.assertIn("--offline", argv) + self.assertNotIn("--add-app", argv) + def test_the_command_line_flag_ticks_the_row(self): _root, bios = _app_card(self, "ROCKNIX") state, _effects = install.tui_start(_args(add_app=True, platform="rocknix",