From fe0d3d30af4104f4b3a998b81ac55abc9021a4d8 Mon Sep 17 00:00:00 2001 From: Yellowcooln <12516003+yellowcooln@users.noreply.github.com> Date: Wed, 29 Apr 2026 13:43:13 -0400 Subject: [PATCH] Fix Buildroot OTA upgrade path --- buildroot-manage.sh | 17 +++++++++++++++++ repeater/web/update_endpoints.py | 12 +++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/buildroot-manage.sh b/buildroot-manage.sh index 4acbbf0..26b4cea 100644 --- a/buildroot-manage.sh +++ b/buildroot-manage.sh @@ -622,6 +622,21 @@ PY info "Linked image-provided Python runtime into the venv" } +remove_shadowing_buildroot_native_packages() { + local removed=0 + + if "$VENV_PIP" show python-periphery >/dev/null 2>&1; then + stage "Restoring Buildroot GPIO runtime" + info "Removing venv-installed python-periphery so the image-provided package is used" + "$VENV_PIP" uninstall -y python-periphery >/dev/null 2>&1 || true + removed=1 + fi + + if [ "$removed" -eq 0 ]; then + info "No shadowing Buildroot native GPIO wheels found in the venv" + fi +} + install_core_into_venv() { local core_repo core_ref core_spec @@ -1361,6 +1376,7 @@ install_repeater() { install_buildroot_dependencies install_core_into_venv install_repeater_package + remove_shadowing_buildroot_native_packages link_system_site_packages stage "Validating installed runtime" @@ -1426,6 +1442,7 @@ upgrade_repeater() { ensure_yq >/dev/null 2>&1 || true install_repeater_package fi + remove_shadowing_buildroot_native_packages link_system_site_packages stage "Validating installed runtime" if check_venv_runtime; then diff --git a/repeater/web/update_endpoints.py b/repeater/web/update_endpoints.py index b45c977..7ff7ab1 100644 --- a/repeater/web/update_endpoints.py +++ b/repeater/web/update_endpoints.py @@ -29,6 +29,7 @@ from datetime import datetime from typing import List, Optional import cherrypy +from repeater.service_utils import is_buildroot logger = logging.getLogger("HTTPServer") @@ -808,9 +809,18 @@ def _do_install() -> None: _state.append_line(f"[pyMC updater] Installing from channel '{channel}'…") _UPGRADE_WRAPPER = "/usr/local/bin/pymc-do-upgrade" + _BUILDROOT_UPGRADE_HELPER = "/root/scripts/buildroot-manage.sh" is_root = (_os.geteuid() == 0) - if is_root: + if is_root and is_buildroot(): + env["PYMC_REPEATER_REF"] = channel + env["PYMC_CORE_REF"] = channel + _state.append_line(f"[pyMC updater] Buildroot image detected – using {_BUILDROOT_UPGRADE_HELPER}") + if not os.path.isfile(_BUILDROOT_UPGRADE_HELPER): + _state.finish_install(False, f"Buildroot upgrade helper not found at {_BUILDROOT_UPGRADE_HELPER}") + return + cmd = ["/bin/sh", _BUILDROOT_UPGRADE_HELPER, "upgrade"] + elif is_root: _migrate_service_unit() # Ensure venv exists (migration from system-pip era)