From c06674c93b3c9bee456cfb6566ee878c3b78a597 Mon Sep 17 00:00:00 2001 From: Yinan Qin <39023210+ganyuanzhen@users.noreply.github.com> Date: Wed, 24 Jan 2024 11:02:58 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=20=E6=B7=BB=E5=8A=A0=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E8=87=AA=E5=B8=A6ROS=E7=9A=84=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=20(#43)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Create tool_install_ros1_systemdefault.py 添加工具,使得用户可以在高版本中使用系统源安装ROS * Update install.py * Update install.py * Fix error * Update tool_install_ros1_systemdefault.py * Update tool_install_ros1_systemdefault.py * Update install.py * 修改警示标语 * 添加警告信息 --- install.py | 3 +- tools/tool_install_ros1_systemdefault.py | 78 ++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 tools/tool_install_ros1_systemdefault.py diff --git a/install.py b/install.py index 4ef0e36..1fb64d6 100644 --- a/install.py +++ b/install.py @@ -33,6 +33,7 @@ 13: {'tip':'一键配置:python国内源','type':CONFIG_TOOL,'tool':url_prefix+'tools/tool_config_python_source.py' ,'dep':[] }, 14: {'tip':'一键安装:科学上网代理工具','type':INSTALL_SOFTWARE,'tool':url_prefix+'tools/tool_install_proxy_tool.py' ,'dep':[8] }, 15: {'tip':'一键安装:QQ for Linux', 'type':INSTALL_SOFTWARE, 'tool': url_prefix+'tools/tool_install_qq.py', 'dep':[]}, + 16: {'tip':'一键安装:系统自带ROS (!!警告!!仅供特殊情况下使用)', 'type':INSTALL_ROS, 'tool': url_prefix+'tools/tool_install_ros1_systemdefault.py', 'dep':[5]}, # 77: {'tip':'测试模式:运行自定义工具测试'}, } # @@ -119,4 +120,4 @@ def main(): PrintUtils.print_success("如在使用过程中遇到问题,请打开:https://fishros.org.cn/forum 进行反馈",0.001) if __name__=='__main__': - main() \ No newline at end of file + main() diff --git a/tools/tool_install_ros1_systemdefault.py b/tools/tool_install_ros1_systemdefault.py new file mode 100644 index 0000000..850ce03 --- /dev/null +++ b/tools/tool_install_ros1_systemdefault.py @@ -0,0 +1,78 @@ +# -*- coding: utf-8 -*- +from .base import BaseTool +from .base import PrintUtils,CmdTask,FileUtils,AptUtils,ChooseTask +from .base import osversion +from .base import run_tool_file + +class Tool(BaseTool): + def __init__(self): + self.type = BaseTool.TYPE_INSTALL + self.name = "一键安装系统自带ROS,仅在Ubuntu 22.04 及以上版本系统中使用。" + self.autor = 'Elysia' + PrintUtils.print_warn("警告!!此工具安装的ROS与从ROS官方软件源安装的ROS冲突!") + + def run(self): + #正式的运行 + self.check_sys_source() + self.install_system_ros() + return True + + def check_sys_source(self): + # 更换系统源 + dic = {1:"更换系统源再继续安装",2:"不更换继续安装"} + PrintUtils.print_warn("=========接下来这一步很很很很重要,如果不知道怎么选请选择1========") + code,result = ChooseTask(dic, "新手或首次安装一定要一定要一定要换源并清理三方源,换源!!!系统默认国外源容易失败!!").run() + if code==1: + tool = run_tool_file('tools.tool_config_system_source',autorun=False) + tool.change_sys_source() + + def install_system_ros(self): + version_dic = {1:"完整版",2:"基础版(小)"} + code,name = ChooseTask(version_dic,"请选择安装的具体版本(如果不知道怎么选,请选1桌面版):",False).run() + + if code==0: + print("你选择退出。。。。") + return + + install_tool = 'aptitude' + install_tool_apt = 'apt' + if osversion.get_version() == "16.04": + install_tool = 'apt' + + if install_tool=='aptitude': + AptUtils.install_pkg('aptitude') + AptUtils.install_pkg('aptitude') + + # 先尝试使用apt 安装,之后再使用aptitude。 + if code==2: + # 第一次尝试 + cmd_result = CmdTask("sudo {} install {} -y".format(install_tool_apt,"ros-base-dev"),300,os_command=True).run() + cmd_result = CmdTask("sudo {} install {} -y".format(install_tool_apt,"ros-base-dev"),300,os_command=False).run() + if FileUtils.check_result(cmd_result,['未满足的依赖关系','unmet dependencies','but it is not installable']): + # 尝试使用aptitude解决依赖问题 + PrintUtils.print_warn("============================================================") + PrintUtils.print_delay("请注意,检测你在安装过程中出现依赖问题,请在稍后输入n,再选择y,即可解决") + import time + input("确认了解情况,请输入回车继续安装") + cmd_result = CmdTask("sudo {} install {} ".format(install_tool,"ros-base-dev"),300,os_command=True).run() + cmd_result = CmdTask("sudo {} install {} -y".format(install_tool,"ros-base-dev"),300,os_command=False).run() + + elif code==1: + cmd_result = CmdTask("sudo {} install {} -y".format(install_tool_apt,"ros-desktop-full-dev"),300,os_command=True).run() + cmd_result = CmdTask("sudo {} install {} -y".format(install_tool_apt,"ros-desktop-full-dev"),300,os_command=False).run() + if FileUtils.check_result(cmd_result,['未满足的依赖关系','unmet dependencies','but it is not installable']): + # 尝试使用aptitude解决依赖问题 + PrintUtils.print_warn("============================================================") + PrintUtils.print_delay("请注意,检测你在安装过程中出现依赖问题,请在稍后输入n,再选择y,即可解决(若无法解决,清在稍后手动运行命令: sudo aptitude install {})".format(RosVersions.get_desktop_version(install_version))) + import time + input("确认了解情况,请输入回车继续安装") + cmd_result = CmdTask("sudo {} install {}".format(install_tool,"ros-desktop-full-dev"),300,os_command=True).run() + cmd_result = CmdTask("sudo {} install {} -y".format(install_tool,"ros-desktop-full-dev"),300,os_command=False).run() + + # apt broken error + if cmd_result[0]!=0: + if FileUtils.check_result(cmd_result[1]+cmd_result[2],['sudo apt --fix-broken install -y']): + if code==2: cmd_result = CmdTask("sudo {} install {} -y".format(install_tool,"ros-base-dev"),300,os_command=False).run() + elif code==1: cmd_result = CmdTask("sudo {} install {} -y".format(install_tool,"ros-desktop-full-dev"),300,os_command=False).run() + + return True