From df93e5f901307b611f2e44e2e4a6c68122d9c64b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=B8=D0=BA=D1=82=D0=BE=D1=80?= <78488229+viktor138irk@users.noreply.github.com> Date: Thu, 7 May 2026 06:47:57 +0900 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B0=D1=82=D1=87=D0=B5=D1=80=20Update?= =?UTF-8?q?=20Center=20=D0=B1=D1=8B=D0=BB=20=D0=B7=D0=B0=D1=89=D0=B8=D1=89?= =?UTF-8?q?=D1=91=D0=BD=20=D0=BE=D1=82=20=D1=80=D0=B0=D0=BD=D0=BD=D0=B5?= =?UTF-8?q?=D0=B3=D0=BE=20=D0=B2=D1=8B=D1=85=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/patch_update_center.py | 35 ++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/scripts/patch_update_center.py b/scripts/patch_update_center.py index 72d99e1..78bcd4c 100644 --- a/scripts/patch_update_center.py +++ b/scripts/patch_update_center.py @@ -9,22 +9,14 @@ if not app_path.exists(): script_dir = Path(__file__).resolve().parent -# New installs run this patch from install_web_panel.sh. Keep feature patches here too. -for optional_patch in ('patch_disk_images.py', 'patch_disk_convert_progress.py', 'patch_vm_architecture.py', 'patch_arm64_emulation_xml.py', 'patch_vm_disk_replace.py', 'patch_update_badge.py'): - patch_path = script_dir / optional_patch - if patch_path.exists(): - old_argv = sys.argv[:] - try: - sys.argv = [str(patch_path), str(app_path)] - runpy.run_path(str(patch_path), run_name='__main__') - finally: - sys.argv = old_argv - text = app_path.read_text() changed = [] if 'import update_core' not in text: - text = text.replace('import network_core\n', 'import network_core\nimport update_core\n', 1) + if 'import network_core\n' in text: + text = text.replace('import network_core\n', 'import network_core\nimport update_core\n', 1) + else: + text = text.replace('from network_core import NetworkError\n', 'from network_core import NetworkError\nimport update_core\n', 1) changed.append('import update_core added') else: changed.append('import update_core already present') @@ -133,3 +125,22 @@ app_path.write_text(text) print('update center patch applied:') for item in changed: print(f'- {item}') + +# Extra feature patches are intentionally executed after Update Center routes are written. +# Some legacy patches can exit early; they must not block /update from being installed. +for optional_patch in ('patch_disk_images.py', 'patch_disk_convert_progress.py', 'patch_vm_architecture.py', 'patch_arm64_emulation_xml.py', 'patch_vm_disk_replace.py', 'patch_update_badge.py'): + patch_path = script_dir / optional_patch + if not patch_path.exists(): + continue + old_argv = sys.argv[:] + try: + sys.argv = [str(patch_path), str(app_path)] + try: + runpy.run_path(str(patch_path), run_name='__main__') + except SystemExit as exc: + code = exc.code + if code not in (None, 0): + raise + print(f'optional patch exited after successful run: {optional_patch}') + finally: + sys.argv = old_argv