diff --git a/cobot/commands/run.py b/cobot/commands/run.py index 887127f..a0381d0 100644 --- a/cobot/commands/run.py +++ b/cobot/commands/run.py @@ -90,24 +90,29 @@ def _ask(step: str, question: str, options: List[str], default: str) -> Optional def _detect_webots_home() -> str: - """Return the WEBOTS_HOME path for the locally installed Webots. + """Return the WEBOTS_HOME path for the locally installed Linux Webots. - Checks the environment variable first, then the default deb install path, - then resolves the 'webots' symlink to find the real installation directory. - Returns an empty string if Webots cannot be located. + Validates that the candidate directory contains the Linux 'webots' binary - Возвращает путь WEBOTS_HOME для локально установленного Webots. - Сначала проверяет переменную окружения, затем стандартный путь deb-установки, - затем разворачивает симлинк 'webots' до реальной директории установки. - Возвращает пустую строку если Webots не найден. + Возвращает путь WEBOTS_HOME для локально установленного Linux Webots. """ + def _is_linux_webots(home: str) -> bool: + # Accept only directories that have the Linux 'webots' binary directly inside. + # Принимаем только директории с Linux-бинарником 'webots' напрямую внутри. + return (Path(home) / "webots").is_file() + if "WEBOTS_HOME" in os.environ: - return os.environ["WEBOTS_HOME"] - if _WEBOTS_DEFAULT_HOME.is_dir(): + home = os.environ["WEBOTS_HOME"] + if _is_linux_webots(home): + return home + return "" + if _WEBOTS_DEFAULT_HOME.is_dir() and _is_linux_webots(str(_WEBOTS_DEFAULT_HOME)): return str(_WEBOTS_DEFAULT_HOME) webots_bin = shutil.which("webots") if webots_bin: - return str(Path(webots_bin).resolve().parent) + home = str(Path(webots_bin).resolve().parent) + if _is_linux_webots(home): + return home return "" diff --git a/scripts/setup_ros2_desktop.sh b/scripts/setup_ros2_desktop.sh index 7743aa5..4e79c41 100755 --- a/scripts/setup_ros2_desktop.sh +++ b/scripts/setup_ros2_desktop.sh @@ -8,6 +8,15 @@ export DEBIAN_FRONTEND=noninteractive PROGRESS() { echo "PROGRESS:$1:$2"; } +# Keep sudo credentials alive throughout the installation so the build step that +# follows (rosdep/colcon) does not trigger a password prompt inside the TUI. +# Обновляем sudo-токен в фоне чтобы он не истёк за время установки и не запросил +# пароль повторно во время rosdep/colcon внутри TUI. +sudo -v +( while true; do sudo -v; sleep 240; done ) & +_SUDO_KEEPALIVE_PID=$! +trap 'kill "$_SUDO_KEEPALIVE_PID" 2>/dev/null || true' EXIT + PROGRESS 0 "Checking dpkg state..." echo "Checking dpkg state..." sudo dpkg --configure -a diff --git a/scripts/setup_ros2_ros_base.sh b/scripts/setup_ros2_ros_base.sh index a12efbc..fd07b31 100755 --- a/scripts/setup_ros2_ros_base.sh +++ b/scripts/setup_ros2_ros_base.sh @@ -8,6 +8,15 @@ export DEBIAN_FRONTEND=noninteractive PROGRESS() { echo "PROGRESS:$1:$2"; } +# Keep sudo credentials alive throughout the installation so the build step that +# follows (rosdep/colcon) does not trigger a password prompt inside the TUI. +# Обновляем sudo-токен в фоне чтобы он не истёк за время установки и не запросил +# пароль повторно во время rosdep/colcon внутри TUI. +sudo -v +( while true; do sudo -v; sleep 240; done ) & +_SUDO_KEEPALIVE_PID=$! +trap 'kill "$_SUDO_KEEPALIVE_PID" 2>/dev/null || true' EXIT + PROGRESS 0 "Checking dpkg state..." echo "Checking dpkg state..." sudo dpkg --configure -a