From 002c68656f50ffaa84baf4daca92b24cf2eefbcb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 14 Jul 2026 00:58:03 +0000 Subject: [PATCH 01/11] Initial plan From de8216cca8c4f00921cc982cde3542a8ec4f977a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 14 Jul 2026 01:00:57 +0000 Subject: [PATCH 02/11] Automate Env mirror setup and venv activation --- README.md | 33 ++++----------------------------- env.sh | 14 +++++++++++++- install_arch.sh | 9 ++------- install_macos.sh | 8 ++------ install_suse.sh | 11 +++-------- install_ubuntu.sh | 11 +++-------- install_windows.ps1 | 15 ++++++++++----- touch_env.ps1 | 12 ++++++++++-- touch_env.sh | 8 +++++--- 9 files changed, 52 insertions(+), 69 deletions(-) diff --git a/README.md b/README.md index 20cd129..cfbe14a 100644 --- a/README.md +++ b/README.md @@ -25,20 +25,11 @@ chmod 777 install_ubuntu.sh rm install_ubuntu.sh ``` -对于中国大陆用户,请使用以下命令 - -``` -wget https://gitee.com/RT-Thread-Mirror/env/raw/master/install_ubuntu.sh -chmod 777 install_ubuntu.sh -./install_ubuntu.sh --gitee -rm install_ubuntu.sh -``` +安装脚本会自动识别网络区域,使用相应镜像下载仓库,完成后将仓库远程地址统一设为 GitHub。 ### Prepare Env -PLAN A: Whenever start the ubuntu system, you need to type command `source ~/.env/env.sh` to activate the environment variables. - -or PLAN B: open `~/.bashrc` file, and attach the command `source ~/.env/env.sh` at the end of the file. It will be automatically executed when you log in the ubuntu, and you don't need to execute that command any more. +Run `source ~/.env/env.sh` to activate Env. The script creates and activates its Python virtual environment on first use. To activate Env automatically, add this command to `~/.bashrc`. ### Use Env @@ -63,13 +54,7 @@ set-executionpolicy remotesigned .\install_windows.ps1 ``` -对于中国大陆用户,请使用以下命令: - -```powershell -wget https://gitee.com/RT-Thread-Mirror/env/raw/master/install_windows.ps1 -O install_windows.ps1 -set-executionpolicy remotesigned -.\install_windows.ps1 --gitee -``` +安装脚本会自动识别网络区域,使用相应镜像下载仓库,完成后将仓库远程地址统一设为 GitHub。 注意: @@ -79,14 +64,4 @@ set-executionpolicy remotesigned ### Prepare Env -方案 A:每次重启 PowerShell 时,都需要输入命令 `~/.env/env.ps1`,以激活环境变量。(PLAN A: Each time you restart PowerShell, you need to enter the command `~/.env/env.ps1` to activate the environment variable.) - -方案 B (推荐):打开 `C:\Users\user\Documents\WindowsPowerShell`,如果没有`WindowsPowerShell`则新建该文件夹。新建文件 `Microsoft.PowerShell_profile.ps1`,然后写入 `~/.env/env.ps1` 内容即可,它将在你重启 PowerShell 时自动执行,无需再执行方案 A 中的命令。(or PLAN B (recommended): Open `C:\Users\user\Documents\WindowsPowerShell` and create a new file `Microsoft.PowerShell_profile.ps1`. Then write `~/.env/env.ps1` to the file. It will be executed automatically when you restart PowerShell, without having to execute the command in scenario A.) - -### 常见问题 - -对于中国大陆用户,请注意首次激活 Env 时可能出现错误,这可能是当前网络下使用的镜像(默认清华源)连接失败,修复方法: - -1. 再次进入安装 Env 的目录,运行`.\install_windows.ps1 --gitee`重新安装,并在**安装完成后不要激活 Env**。 -2. 打开 `~/.env/env.ps1` 文件,修改 `python -m pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple` 和 `pip install -i https://pypi.tuna.tsinghua.edu.cn/simple "$PSScriptRoot\tools\scriptse` 中的镜像地址 `https://pypi.tuna.tsinghua.edu.cn/simple` 为其他可用的镜像。 -3. 激活 Env。 \ No newline at end of file +Run `~/.env/env.ps1` to activate Env. The script creates and activates its Python virtual environment on first use. To activate Env automatically, add `~/.env/env.ps1` to your PowerShell profile. \ No newline at end of file diff --git a/env.sh b/env.sh index 5c5280f..2e70e06 100644 --- a/env.sh +++ b/env.sh @@ -1 +1,13 @@ -export PATH=~/.env/tools/scripts:$PATH +# shellcheck shell=sh +VENV_ROOT="$HOME/.env/.venv" + +if [ ! -d "$VENV_ROOT" ]; then + echo "Create Python venv for RT-Thread..." + python3 -m venv "$VENV_ROOT" || return + "$VENV_ROOT/bin/python" -m pip install --upgrade pip + "$VENV_ROOT/bin/pip" install "$HOME/.env/tools/scripts" +fi + +. "$VENV_ROOT/bin/activate" +export PATH="$HOME/.env/tools/scripts:$PATH" +export RTT_EXEC_PATH=/usr/bin diff --git a/install_arch.sh b/install_arch.sh index cc6fe9f..7d4698b 100755 --- a/install_arch.sh +++ b/install_arch.sh @@ -59,12 +59,7 @@ esac echo "安装完成。" -url=https://raw.githubusercontent.com/RT-Thread/env/master/touch_env.sh -if [ $1 ] && [ $1 = --gitee ]; then - url=https://gitee.com/RT-Thread-Mirror/env/raw/master/touch_env.sh -fi - -wget $url -O touch_env.sh +wget https://raw.githubusercontent.com/RT-Thread/env/master/touch_env.sh -O touch_env.sh chmod 777 touch_env.sh -./touch_env.sh $@ +./touch_env.sh rm touch_env.sh diff --git a/install_macos.sh b/install_macos.sh index 6098479..a9ab0c4 100755 --- a/install_macos.sh +++ b/install_macos.sh @@ -66,11 +66,7 @@ if ! [ -x "$(command -v arm-none-eabi-gcc)" ]; then brew install gnu-arm-embedded fi -url=https://raw.githubusercontent.com/RT-Thread/env/master/touch_env.sh -if [ $1 ] && [ $1 = --gitee ]; then - url=https://gitee.com/RT-Thread-Mirror/env/raw/master/touch_env.sh -fi -curl $url -o touch_env.sh +curl https://raw.githubusercontent.com/RT-Thread/env/master/touch_env.sh -o touch_env.sh chmod 777 touch_env.sh -./touch_env.sh $@ +./touch_env.sh rm touch_env.sh diff --git a/install_suse.sh b/install_suse.sh index a127718..793614b 100755 --- a/install_suse.sh +++ b/install_suse.sh @@ -2,16 +2,11 @@ sudo zypper update -y -sudo zypper install python3 python3-pip gcc git ncurses-devel cross-arm-none-gcc11-bootstrap cross-arm-binutils qemu qemu-arm qemu-extra -y +sudo zypper install python3 python3-pip python3-venv gcc git ncurses-devel cross-arm-none-gcc11-bootstrap cross-arm-binutils qemu qemu-arm qemu-extra -y python3 -m pip install scons requests tqdm kconfiglib python3 -m pip install -U pyocd -url=https://raw.githubusercontent.com/RT-Thread/env/master/touch_env.sh -if [ $1 ] && [ $1 = --gitee ]; then - url=https://gitee.com/RT-Thread-Mirror/env/raw/master/touch_env.sh -fi - -wget $url -O touch_env.sh +wget https://raw.githubusercontent.com/RT-Thread/env/master/touch_env.sh -O touch_env.sh chmod 777 touch_env.sh -./touch_env.sh $@ +./touch_env.sh rm touch_env.sh diff --git a/install_ubuntu.sh b/install_ubuntu.sh index 2d27e97..e5236a5 100755 --- a/install_ubuntu.sh +++ b/install_ubuntu.sh @@ -1,15 +1,10 @@ #!/usr/bin/env bash sudo apt-get update -sudo apt-get -qq install python3 python3-pip gcc git libncurses5-dev -y +sudo apt-get -qq install python3 python3-pip python3-venv gcc git libncurses5-dev -y pip install scons requests tqdm kconfiglib pyyaml -url=https://raw.githubusercontent.com/RT-Thread/env/master/touch_env.sh -if [ $1 ] && [ $1 = --gitee ]; then - url=https://gitee.com/RT-Thread-Mirror/env/raw/master/touch_env.sh -fi - -wget $url -O touch_env.sh +wget https://raw.githubusercontent.com/RT-Thread/env/master/touch_env.sh -O touch_env.sh chmod 777 touch_env.sh -./touch_env.sh $@ +./touch_env.sh rm touch_env.sh diff --git a/install_windows.ps1 b/install_windows.ps1 index 8ed3b77..23131bb 100644 --- a/install_windows.ps1 +++ b/install_windows.ps1 @@ -29,9 +29,14 @@ if (!$?) { echo "Python environment has installed. Jump this step." } +try { + $useGitee = (Invoke-RestMethod -Uri "https://ipinfo.io/json" -UseBasicParsing -TimeoutSec 3).country -eq "CN" +} catch { + $useGitee = $false +} + $git_url = "https://github.com/git-for-windows/git/releases/download/v2.39.2.windows.1/Git-2.39.2-64-bit.exe" -if ($args[0] -eq "--gitee") { - echo "Use gitee mirror server!" +if ($useGitee) { $git_url = "https://registry.npmmirror.com/-/binary/git-for-windows/v2.39.2.windows.1/Git-2.39.2-64-bit.exe" } @@ -53,7 +58,7 @@ if (!(Test-Command git)) { $PIP_SOURCE = "https://pypi.org/simple" $PIP_HOST = "pypi.org" -if ($args[0] -eq "--gitee") { +if ($useGitee) { $PIP_SOURCE = "http://mirrors.aliyun.com/pypi/simple" $PIP_HOST = "mirrors.aliyun.com" } @@ -116,13 +121,13 @@ if (!$?) { } $url = "https://raw.githubusercontent.com/RT-Thread/env/master/touch_env.ps1" -if ($args[0] -eq "--gitee") { +if ($useGitee) { $url = "https://gitee.com/RT-Thread-Mirror/env/raw/master/touch_env.ps1" } wget $url -O touch_env.ps1 echo "run touch_env.ps1" -./touch_env.ps1 $args[0] +./touch_env.ps1 if ($args.Count -ge 2 -and $args[1] -eq "-y") { echo "Windows Env environment installment has finished. (auto mode, no pause)" diff --git a/touch_env.ps1 b/touch_env.ps1 index c2d3ce9..dc31cbf 100644 --- a/touch_env.ps1 +++ b/touch_env.ps1 @@ -2,8 +2,13 @@ $DEFAULT_RTT_PACKAGE_URL = "https://github.com/RT-Thread/packages.git" $ENV_URL = "https://github.com/RT-Thread/env.git" $SDK_URL = "https://github.com/RT-Thread/sdk.git" -if ($args[0] -eq "--gitee") { - echo "Using gitee service." +try { + $useGitee = (Invoke-RestMethod -Uri "https://ipinfo.io/json" -UseBasicParsing -TimeoutSec 3).country -eq "CN" +} catch { + $useGitee = $false +} + +if ($useGitee) { $DEFAULT_RTT_PACKAGE_URL = "https://gitee.com/RT-Thread-Mirror/packages.git" $ENV_URL = "https://gitee.com/RT-Thread-Mirror/env.git" $SDK_URL = "https://gitee.com/RT-Thread-Mirror/sdk.git" @@ -29,6 +34,9 @@ if (!(Test-Path -Path $env_dir)) { echo 'source "$PKGS_DIR/packages/Kconfig"' | Out-File -FilePath $env_dir/packages/Kconfig -Encoding ASCII git clone $SDK_URL $env_dir/packages/sdk --depth=1 git clone $ENV_URL $env_dir/tools/scripts --depth=1 + git -C $env_dir/packages/packages remote set-url origin https://github.com/RT-Thread/packages.git + git -C $env_dir/packages/sdk remote set-url origin https://github.com/RT-Thread/sdk.git + git -C $env_dir/tools/scripts remote set-url origin https://github.com/RT-Thread/env.git copy $env_dir/tools/scripts/env.ps1 $env_dir/env.ps1 } else { echo ".env folder has exsited. Jump this step." diff --git a/touch_env.sh b/touch_env.sh index c35dc4d..812df9c 100755 --- a/touch_env.sh +++ b/touch_env.sh @@ -4,8 +4,7 @@ DEFAULT_RTT_PACKAGE_URL=https://github.com/RT-Thread/packages.git ENV_URL=https://github.com/RT-Thread/env.git SDK_URL="https://github.com/RT-Thread/sdk.git" -if [ $1 ] && [ $1 = --gitee ]; then - gitee=1 +if [ "$(wget -qO- --timeout=3 https://ipinfo.io/country 2>/dev/null)" = "CN" ]; then DEFAULT_RTT_PACKAGE_URL=https://gitee.com/RT-Thread-Mirror/packages.git ENV_URL=https://gitee.com/RT-Thread-Mirror/env.git SDK_URL="https://gitee.com/RT-Thread-Mirror/sdk.git" @@ -29,5 +28,8 @@ if ! [ -d $env_dir ]; then echo 'source "$PKGS_DIR/packages/Kconfig"' >$env_dir/packages/Kconfig git clone $SDK_URL $env_dir/packages/sdk --depth=1 git clone $ENV_URL $env_dir/tools/scripts --depth=1 - echo -e 'export PATH=`python3 -m site --user-base`/bin:$HOME/.env/tools/scripts:$PATH\nexport RTT_EXEC_PATH=/usr/bin' >$env_dir/env.sh + git -C $env_dir/packages/packages remote set-url origin https://github.com/RT-Thread/packages.git + git -C $env_dir/packages/sdk remote set-url origin https://github.com/RT-Thread/sdk.git + git -C $env_dir/tools/scripts remote set-url origin https://github.com/RT-Thread/env.git + cp $env_dir/tools/scripts/env.sh $env_dir/env.sh fi From dbd1d713ad7291e8ba8ac0058ebee9e3d2b4d65c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 14 Jul 2026 01:01:39 +0000 Subject: [PATCH 03/11] Handle Env venv setup failures --- env.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/env.sh b/env.sh index 2e70e06..52d86c8 100644 --- a/env.sh +++ b/env.sh @@ -4,8 +4,11 @@ VENV_ROOT="$HOME/.env/.venv" if [ ! -d "$VENV_ROOT" ]; then echo "Create Python venv for RT-Thread..." python3 -m venv "$VENV_ROOT" || return - "$VENV_ROOT/bin/python" -m pip install --upgrade pip - "$VENV_ROOT/bin/pip" install "$HOME/.env/tools/scripts" + if ! "$VENV_ROOT/bin/python" -m pip install --upgrade pip || + ! "$VENV_ROOT/bin/pip" install "$HOME/.env/tools/scripts"; then + rm -rf "$VENV_ROOT" + return 1 + fi fi . "$VENV_ROOT/bin/activate" From 72c129276675dcf8e63f99ac376f1d29dae79a27 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 14 Jul 2026 01:02:19 +0000 Subject: [PATCH 04/11] Report Env venv setup errors --- env.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/env.sh b/env.sh index 52d86c8..c06b50a 100644 --- a/env.sh +++ b/env.sh @@ -3,9 +3,13 @@ VENV_ROOT="$HOME/.env/.venv" if [ ! -d "$VENV_ROOT" ]; then echo "Create Python venv for RT-Thread..." - python3 -m venv "$VENV_ROOT" || return + if ! python3 -m venv "$VENV_ROOT"; then + echo "Failed to create Python venv for RT-Thread." + return 1 + fi if ! "$VENV_ROOT/bin/python" -m pip install --upgrade pip || ! "$VENV_ROOT/bin/pip" install "$HOME/.env/tools/scripts"; then + echo "Failed to install RT-Thread dependencies." rm -rf "$VENV_ROOT" return 1 fi From b409bb59fe9432c1030cb3b17fc1747726376251 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 14 Jul 2026 01:02:59 +0000 Subject: [PATCH 05/11] Fix Env setup prompts and errors --- env.sh | 8 ++++++-- touch_env.ps1 | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/env.sh b/env.sh index c06b50a..428bae4 100644 --- a/env.sh +++ b/env.sh @@ -7,8 +7,12 @@ if [ ! -d "$VENV_ROOT" ]; then echo "Failed to create Python venv for RT-Thread." return 1 fi - if ! "$VENV_ROOT/bin/python" -m pip install --upgrade pip || - ! "$VENV_ROOT/bin/pip" install "$HOME/.env/tools/scripts"; then + if ! "$VENV_ROOT/bin/python" -m pip install --upgrade pip; then + echo "Failed to upgrade pip for RT-Thread." + rm -rf "$VENV_ROOT" + return 1 + fi + if ! "$VENV_ROOT/bin/pip" install "$HOME/.env/tools/scripts"; then echo "Failed to install RT-Thread dependencies." rm -rf "$VENV_ROOT" return 1 diff --git a/touch_env.ps1 b/touch_env.ps1 index dc31cbf..bf94baa 100644 --- a/touch_env.ps1 +++ b/touch_env.ps1 @@ -17,7 +17,7 @@ if ($useGitee) { $env_dir = "$HOME\.env" if (Test-Path -Path $env_dir) { - $option = Read-Host ".env directory already exists. Would you like to remove and recreate .env directory? (Y/N) " option + $option = Read-Host ".env directory already exists. Would you like to remove and recreate .env directory? (Y/N) " } if (( $option -eq 'Y' ) -or ($option -eq 'y')) { Get-ChildItem $env_dir -Recurse | Remove-Item -Force -Recurse rm -r $env_dir From 9733e9de8fd8c2b0ee8c0a6977baa21fffa2c49a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 14 Jul 2026 01:03:47 +0000 Subject: [PATCH 06/11] Harden Env setup scripts --- touch_env.ps1 | 3 ++- touch_env.sh | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/touch_env.ps1 b/touch_env.ps1 index bf94baa..8189361 100644 --- a/touch_env.ps1 +++ b/touch_env.ps1 @@ -18,7 +18,8 @@ $env_dir = "$HOME\.env" if (Test-Path -Path $env_dir) { $option = Read-Host ".env directory already exists. Would you like to remove and recreate .env directory? (Y/N) " -} if (( $option -eq 'Y' ) -or ($option -eq 'y')) { +} +if (( $option -eq 'Y' ) -or ($option -eq 'y')) { Get-ChildItem $env_dir -Recurse | Remove-Item -Force -Recurse rm -r $env_dir } diff --git a/touch_env.sh b/touch_env.sh index 812df9c..d87121a 100755 --- a/touch_env.sh +++ b/touch_env.sh @@ -31,5 +31,9 @@ if ! [ -d $env_dir ]; then git -C $env_dir/packages/packages remote set-url origin https://github.com/RT-Thread/packages.git git -C $env_dir/packages/sdk remote set-url origin https://github.com/RT-Thread/sdk.git git -C $env_dir/tools/scripts remote set-url origin https://github.com/RT-Thread/env.git - cp $env_dir/tools/scripts/env.sh $env_dir/env.sh + if ! cp $env_dir/tools/scripts/env.sh $env_dir/env.sh; then + echo "Failed to set up Env activation script." + rm -rf $env_dir + exit 1 + fi fi From 39d9edb76aeea05b50d127655e04f4850f621ab0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 15 Jul 2026 16:29:56 +0000 Subject: [PATCH 07/11] Select Linux bootstrap mirror by region --- README.md | 7 ++++++- install_arch.sh | 7 ++++++- install_suse.sh | 7 ++++++- install_ubuntu.sh | 7 ++++++- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index cfbe14a..dfe9485 100644 --- a/README.md +++ b/README.md @@ -19,13 +19,18 @@ ### Install Env ``` +# 中国大陆网络: +wget https://gitee.com/RT-Thread-Mirror/env/raw/master/install_ubuntu.sh + +# 其他地区网络: wget https://raw.githubusercontent.com/RT-Thread/env/master/install_ubuntu.sh + chmod 777 install_ubuntu.sh ./install_ubuntu.sh rm install_ubuntu.sh ``` -安装脚本会自动识别网络区域,使用相应镜像下载仓库,完成后将仓库远程地址统一设为 GitHub。 +请根据自身网络地区选择对应的下载地址。安装脚本会自动识别网络区域,使用相应镜像下载仓库,完成后将仓库远程地址统一设为 GitHub。 ### Prepare Env diff --git a/install_arch.sh b/install_arch.sh index 7d4698b..abf2130 100755 --- a/install_arch.sh +++ b/install_arch.sh @@ -1,5 +1,10 @@ #!/usr/bin/env bash +TOUCH_ENV_URL=https://raw.githubusercontent.com/RT-Thread/env/master/touch_env.sh +if [ "$(wget -qO- --timeout=3 https://ipinfo.io/country 2>/dev/null)" = "CN" ]; then + TOUCH_ENV_URL=https://gitee.com/RT-Thread-Mirror/env/raw/master/touch_env.sh +fi + # 函数:从 AUR 安装 rt-thread-env-meta 包 install_from_aur() { echo "正在从 AUR 安装 rt-thread-env-meta 包..." @@ -59,7 +64,7 @@ esac echo "安装完成。" -wget https://raw.githubusercontent.com/RT-Thread/env/master/touch_env.sh -O touch_env.sh +wget "$TOUCH_ENV_URL" -O touch_env.sh chmod 777 touch_env.sh ./touch_env.sh rm touch_env.sh diff --git a/install_suse.sh b/install_suse.sh index 793614b..8da436c 100755 --- a/install_suse.sh +++ b/install_suse.sh @@ -1,12 +1,17 @@ #!/usr/bin/env bash +TOUCH_ENV_URL=https://raw.githubusercontent.com/RT-Thread/env/master/touch_env.sh +if [ "$(wget -qO- --timeout=3 https://ipinfo.io/country 2>/dev/null)" = "CN" ]; then + TOUCH_ENV_URL=https://gitee.com/RT-Thread-Mirror/env/raw/master/touch_env.sh +fi + sudo zypper update -y sudo zypper install python3 python3-pip python3-venv gcc git ncurses-devel cross-arm-none-gcc11-bootstrap cross-arm-binutils qemu qemu-arm qemu-extra -y python3 -m pip install scons requests tqdm kconfiglib python3 -m pip install -U pyocd -wget https://raw.githubusercontent.com/RT-Thread/env/master/touch_env.sh -O touch_env.sh +wget "$TOUCH_ENV_URL" -O touch_env.sh chmod 777 touch_env.sh ./touch_env.sh rm touch_env.sh diff --git a/install_ubuntu.sh b/install_ubuntu.sh index e5236a5..5bded29 100755 --- a/install_ubuntu.sh +++ b/install_ubuntu.sh @@ -1,10 +1,15 @@ #!/usr/bin/env bash +TOUCH_ENV_URL=https://raw.githubusercontent.com/RT-Thread/env/master/touch_env.sh +if [ "$(wget -qO- --timeout=3 https://ipinfo.io/country 2>/dev/null)" = "CN" ]; then + TOUCH_ENV_URL=https://gitee.com/RT-Thread-Mirror/env/raw/master/touch_env.sh +fi + sudo apt-get update sudo apt-get -qq install python3 python3-pip python3-venv gcc git libncurses5-dev -y pip install scons requests tqdm kconfiglib pyyaml -wget https://raw.githubusercontent.com/RT-Thread/env/master/touch_env.sh -O touch_env.sh +wget "$TOUCH_ENV_URL" -O touch_env.sh chmod 777 touch_env.sh ./touch_env.sh rm touch_env.sh From dfaa78f182a5175899416ec42ee8a9de787c9a5c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 15 Jul 2026 16:30:42 +0000 Subject: [PATCH 08/11] Handle unavailable installer region lookup --- install_arch.sh | 8 +++++++- install_suse.sh | 8 +++++++- install_ubuntu.sh | 8 +++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/install_arch.sh b/install_arch.sh index abf2130..bbfe91b 100755 --- a/install_arch.sh +++ b/install_arch.sh @@ -1,8 +1,14 @@ #!/usr/bin/env bash TOUCH_ENV_URL=https://raw.githubusercontent.com/RT-Thread/env/master/touch_env.sh -if [ "$(wget -qO- --timeout=3 https://ipinfo.io/country 2>/dev/null)" = "CN" ]; then +COUNTRY=$(wget -qO- --timeout=3 https://ipinfo.io/country 2>/dev/null) +if [ "$COUNTRY" = "CN" ]; then TOUCH_ENV_URL=https://gitee.com/RT-Thread-Mirror/env/raw/master/touch_env.sh +elif [ -z "$COUNTRY" ]; then + read -r -p "Unable to detect network region. Use the Gitee mirror? (y/N) " use_gitee + if [[ "$use_gitee" =~ ^[Yy]$ ]]; then + TOUCH_ENV_URL=https://gitee.com/RT-Thread-Mirror/env/raw/master/touch_env.sh + fi fi # 函数:从 AUR 安装 rt-thread-env-meta 包 diff --git a/install_suse.sh b/install_suse.sh index 8da436c..3002fed 100755 --- a/install_suse.sh +++ b/install_suse.sh @@ -1,8 +1,14 @@ #!/usr/bin/env bash TOUCH_ENV_URL=https://raw.githubusercontent.com/RT-Thread/env/master/touch_env.sh -if [ "$(wget -qO- --timeout=3 https://ipinfo.io/country 2>/dev/null)" = "CN" ]; then +COUNTRY=$(wget -qO- --timeout=3 https://ipinfo.io/country 2>/dev/null) +if [ "$COUNTRY" = "CN" ]; then TOUCH_ENV_URL=https://gitee.com/RT-Thread-Mirror/env/raw/master/touch_env.sh +elif [ -z "$COUNTRY" ]; then + read -r -p "Unable to detect network region. Use the Gitee mirror? (y/N) " use_gitee + if [[ "$use_gitee" =~ ^[Yy]$ ]]; then + TOUCH_ENV_URL=https://gitee.com/RT-Thread-Mirror/env/raw/master/touch_env.sh + fi fi sudo zypper update -y diff --git a/install_ubuntu.sh b/install_ubuntu.sh index 5bded29..37492bd 100755 --- a/install_ubuntu.sh +++ b/install_ubuntu.sh @@ -1,8 +1,14 @@ #!/usr/bin/env bash TOUCH_ENV_URL=https://raw.githubusercontent.com/RT-Thread/env/master/touch_env.sh -if [ "$(wget -qO- --timeout=3 https://ipinfo.io/country 2>/dev/null)" = "CN" ]; then +COUNTRY=$(wget -qO- --timeout=3 https://ipinfo.io/country 2>/dev/null) +if [ "$COUNTRY" = "CN" ]; then TOUCH_ENV_URL=https://gitee.com/RT-Thread-Mirror/env/raw/master/touch_env.sh +elif [ -z "$COUNTRY" ]; then + read -r -p "Unable to detect network region. Use the Gitee mirror? (y/N) " use_gitee + if [[ "$use_gitee" =~ ^[Yy]$ ]]; then + TOUCH_ENV_URL=https://gitee.com/RT-Thread-Mirror/env/raw/master/touch_env.sh + fi fi sudo apt-get update From 0a609930613e0568e5b2c81213dc76d7ab6a2393 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 15 Jul 2026 16:31:23 +0000 Subject: [PATCH 09/11] Avoid prompts in unattended installers --- README.md | 2 +- install_arch.sh | 2 +- install_suse.sh | 2 +- install_ubuntu.sh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index dfe9485..a54a891 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ chmod 777 install_ubuntu.sh rm install_ubuntu.sh ``` -请根据自身网络地区选择对应的下载地址。安装脚本会自动识别网络区域,使用相应镜像下载仓库,完成后将仓库远程地址统一设为 GitHub。 +请根据自身网络地区选择对应的下载地址来下载安装脚本。安装脚本会自动识别网络区域,使用相应镜像下载后续仓库,完成后将仓库远程地址统一设为 GitHub。 ### Prepare Env diff --git a/install_arch.sh b/install_arch.sh index bbfe91b..f2de907 100755 --- a/install_arch.sh +++ b/install_arch.sh @@ -4,7 +4,7 @@ TOUCH_ENV_URL=https://raw.githubusercontent.com/RT-Thread/env/master/touch_env.s COUNTRY=$(wget -qO- --timeout=3 https://ipinfo.io/country 2>/dev/null) if [ "$COUNTRY" = "CN" ]; then TOUCH_ENV_URL=https://gitee.com/RT-Thread-Mirror/env/raw/master/touch_env.sh -elif [ -z "$COUNTRY" ]; then +elif [ -z "$COUNTRY" ] && [ -t 0 ]; then read -r -p "Unable to detect network region. Use the Gitee mirror? (y/N) " use_gitee if [[ "$use_gitee" =~ ^[Yy]$ ]]; then TOUCH_ENV_URL=https://gitee.com/RT-Thread-Mirror/env/raw/master/touch_env.sh diff --git a/install_suse.sh b/install_suse.sh index 3002fed..db3ae45 100755 --- a/install_suse.sh +++ b/install_suse.sh @@ -4,7 +4,7 @@ TOUCH_ENV_URL=https://raw.githubusercontent.com/RT-Thread/env/master/touch_env.s COUNTRY=$(wget -qO- --timeout=3 https://ipinfo.io/country 2>/dev/null) if [ "$COUNTRY" = "CN" ]; then TOUCH_ENV_URL=https://gitee.com/RT-Thread-Mirror/env/raw/master/touch_env.sh -elif [ -z "$COUNTRY" ]; then +elif [ -z "$COUNTRY" ] && [ -t 0 ]; then read -r -p "Unable to detect network region. Use the Gitee mirror? (y/N) " use_gitee if [[ "$use_gitee" =~ ^[Yy]$ ]]; then TOUCH_ENV_URL=https://gitee.com/RT-Thread-Mirror/env/raw/master/touch_env.sh diff --git a/install_ubuntu.sh b/install_ubuntu.sh index 37492bd..9b33eba 100755 --- a/install_ubuntu.sh +++ b/install_ubuntu.sh @@ -4,7 +4,7 @@ TOUCH_ENV_URL=https://raw.githubusercontent.com/RT-Thread/env/master/touch_env.s COUNTRY=$(wget -qO- --timeout=3 https://ipinfo.io/country 2>/dev/null) if [ "$COUNTRY" = "CN" ]; then TOUCH_ENV_URL=https://gitee.com/RT-Thread-Mirror/env/raw/master/touch_env.sh -elif [ -z "$COUNTRY" ]; then +elif [ -z "$COUNTRY" ] && [ -t 0 ]; then read -r -p "Unable to detect network region. Use the Gitee mirror? (y/N) " use_gitee if [[ "$use_gitee" =~ ^[Yy]$ ]]; then TOUCH_ENV_URL=https://gitee.com/RT-Thread-Mirror/env/raw/master/touch_env.sh From 65212885453da527104441ec1d5875e5fb3114db Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 15 Jul 2026 16:32:05 +0000 Subject: [PATCH 10/11] Clarify installer mirror fallback --- install_arch.sh | 2 +- install_suse.sh | 2 +- install_ubuntu.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/install_arch.sh b/install_arch.sh index f2de907..2275f87 100755 --- a/install_arch.sh +++ b/install_arch.sh @@ -5,7 +5,7 @@ COUNTRY=$(wget -qO- --timeout=3 https://ipinfo.io/country 2>/dev/null) if [ "$COUNTRY" = "CN" ]; then TOUCH_ENV_URL=https://gitee.com/RT-Thread-Mirror/env/raw/master/touch_env.sh elif [ -z "$COUNTRY" ] && [ -t 0 ]; then - read -r -p "Unable to detect network region. Use the Gitee mirror? (y/N) " use_gitee + read -r -p "Unable to detect network region; defaulting to GitHub. Use Gitee instead? (y/N) " use_gitee if [[ "$use_gitee" =~ ^[Yy]$ ]]; then TOUCH_ENV_URL=https://gitee.com/RT-Thread-Mirror/env/raw/master/touch_env.sh fi diff --git a/install_suse.sh b/install_suse.sh index db3ae45..4762804 100755 --- a/install_suse.sh +++ b/install_suse.sh @@ -5,7 +5,7 @@ COUNTRY=$(wget -qO- --timeout=3 https://ipinfo.io/country 2>/dev/null) if [ "$COUNTRY" = "CN" ]; then TOUCH_ENV_URL=https://gitee.com/RT-Thread-Mirror/env/raw/master/touch_env.sh elif [ -z "$COUNTRY" ] && [ -t 0 ]; then - read -r -p "Unable to detect network region. Use the Gitee mirror? (y/N) " use_gitee + read -r -p "Unable to detect network region; defaulting to GitHub. Use Gitee instead? (y/N) " use_gitee if [[ "$use_gitee" =~ ^[Yy]$ ]]; then TOUCH_ENV_URL=https://gitee.com/RT-Thread-Mirror/env/raw/master/touch_env.sh fi diff --git a/install_ubuntu.sh b/install_ubuntu.sh index 9b33eba..6e9efe3 100755 --- a/install_ubuntu.sh +++ b/install_ubuntu.sh @@ -5,7 +5,7 @@ COUNTRY=$(wget -qO- --timeout=3 https://ipinfo.io/country 2>/dev/null) if [ "$COUNTRY" = "CN" ]; then TOUCH_ENV_URL=https://gitee.com/RT-Thread-Mirror/env/raw/master/touch_env.sh elif [ -z "$COUNTRY" ] && [ -t 0 ]; then - read -r -p "Unable to detect network region. Use the Gitee mirror? (y/N) " use_gitee + read -r -p "Unable to detect network region; defaulting to GitHub. Use Gitee instead? (y/N) " use_gitee if [[ "$use_gitee" =~ ^[Yy]$ ]]; then TOUCH_ENV_URL=https://gitee.com/RT-Thread-Mirror/env/raw/master/touch_env.sh fi From 672cf01a22aed8ccff49c156cfdb2c715169a8a8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 15 Jul 2026 16:32:39 +0000 Subject: [PATCH 11/11] Clarify default installer mirror --- install_arch.sh | 2 +- install_suse.sh | 2 +- install_ubuntu.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/install_arch.sh b/install_arch.sh index 2275f87..cde77d7 100755 --- a/install_arch.sh +++ b/install_arch.sh @@ -5,7 +5,7 @@ COUNTRY=$(wget -qO- --timeout=3 https://ipinfo.io/country 2>/dev/null) if [ "$COUNTRY" = "CN" ]; then TOUCH_ENV_URL=https://gitee.com/RT-Thread-Mirror/env/raw/master/touch_env.sh elif [ -z "$COUNTRY" ] && [ -t 0 ]; then - read -r -p "Unable to detect network region; defaulting to GitHub. Use Gitee instead? (y/N) " use_gitee + read -r -p "Unable to detect network region. Use Gitee mirror? (y/N, default: GitHub) " use_gitee if [[ "$use_gitee" =~ ^[Yy]$ ]]; then TOUCH_ENV_URL=https://gitee.com/RT-Thread-Mirror/env/raw/master/touch_env.sh fi diff --git a/install_suse.sh b/install_suse.sh index 4762804..63a5204 100755 --- a/install_suse.sh +++ b/install_suse.sh @@ -5,7 +5,7 @@ COUNTRY=$(wget -qO- --timeout=3 https://ipinfo.io/country 2>/dev/null) if [ "$COUNTRY" = "CN" ]; then TOUCH_ENV_URL=https://gitee.com/RT-Thread-Mirror/env/raw/master/touch_env.sh elif [ -z "$COUNTRY" ] && [ -t 0 ]; then - read -r -p "Unable to detect network region; defaulting to GitHub. Use Gitee instead? (y/N) " use_gitee + read -r -p "Unable to detect network region. Use Gitee mirror? (y/N, default: GitHub) " use_gitee if [[ "$use_gitee" =~ ^[Yy]$ ]]; then TOUCH_ENV_URL=https://gitee.com/RT-Thread-Mirror/env/raw/master/touch_env.sh fi diff --git a/install_ubuntu.sh b/install_ubuntu.sh index 6e9efe3..8174bcf 100755 --- a/install_ubuntu.sh +++ b/install_ubuntu.sh @@ -5,7 +5,7 @@ COUNTRY=$(wget -qO- --timeout=3 https://ipinfo.io/country 2>/dev/null) if [ "$COUNTRY" = "CN" ]; then TOUCH_ENV_URL=https://gitee.com/RT-Thread-Mirror/env/raw/master/touch_env.sh elif [ -z "$COUNTRY" ] && [ -t 0 ]; then - read -r -p "Unable to detect network region; defaulting to GitHub. Use Gitee instead? (y/N) " use_gitee + read -r -p "Unable to detect network region. Use Gitee mirror? (y/N, default: GitHub) " use_gitee if [[ "$use_gitee" =~ ^[Yy]$ ]]; then TOUCH_ENV_URL=https://gitee.com/RT-Thread-Mirror/env/raw/master/touch_env.sh fi