Skip to content

Commit a10b601

Browse files
committed
feat: add delete_all_now strategy and update backup strategy documentation
- Add D/d option for immediate delete without backup (delete_all_now) - Update delete_all description: backup then delete, no restore - Add manual operation prompts when backup/delete fails - Add GPL copyright header to install.sh - Update all documentation: README, README_ZH, install.ps1, install.sh, touch_env.py
1 parent e4abc4c commit a10b601

5 files changed

Lines changed: 108 additions & 25 deletions

File tree

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,16 @@ The following are the parameter descriptions common to all installation scripts:
181181
| `-P`, `--packages <repo>[#<branch>]` | Specify packages repository address and branch, format: url[#branch] |
182182
| `-E`, `--env <repo>[#<branch>]` | Specify env repository address and branch, format: url[#branch] |
183183
| `-S`, `--sdk <repo>[#<branch>]` | Specify sdk repository address and branch, format: url[#branch] |
184-
| `-b`, `--backup <strategy>` | Backup strategy: preserve (keep configs and toolchains), delete_all (delete all), backup_all (full backup) |
184+
| `-b`, `--backup <strategy>` | Backup strategy: preserve (keep configs and toolchains), delete_all (backup then delete), delete_all_now (delete immediately, no backup), backup_all (full backup) |
185185
| `-t`, `--touch-env-url <url>` | Specify touch_env.py download URL |
186186
| `-h`, `--help` | Display help information |
187187
| `-p`, `--python [path]` | Install portable Python, installation directory is path (Windows only, default: D:\Tools\Python) |
188188

189189
**Backup Strategy Description:**
190190

191191
- **preserve** (default): Keep configuration files (.config) and toolchains (local_pkgs), delete other content and reinstall
192-
- **delete_all**: Completely delete existing ENV directory, keep nothing
192+
- **delete_all**: Backup then delete existing ENV directory, keep nothing
193+
- **delete_all_now**: Immediately delete existing ENV directory, no backup
193194
- **backup_all**: Create full backup, keep all content including configurations and toolchains
194195

195196
**Usage Examples:**

README_ZH.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,15 +182,16 @@ echo 'source ~/.rt-env/env.sh' >> ~/.zshrc
182182
| `-P`, `--packages <repo>[#<branch>]` | 指定 packages 仓库地址和分支,格式: url[#branch] |
183183
| `-E`, `--env <repo>[#<branch>]` | 指定 env 仓库地址和分支,格式: url[#branch] |
184184
| `-S`, `--sdk <repo>[#<branch>]` | 指定 sdk 仓库地址和分支,格式: url[#branch] |
185-
| `-b`, `--backup <strategy>` | 备份策略:preserve(保留配置和工具链)、delete_all(删除所有内容)、backup_all(完整备份) |
185+
| `-b`, `--backup <strategy>` | 备份策略:preserve(保留配置和工具链)、delete_all(备份后删除)、delete_all_now(立即删除,不备份)、backup_all(完整备份) |
186186
| `-t`, `--touch-env-url <url>` | 指定 touch_env.py 下载 URL |
187187
| `-h`, `--help` | 显示帮助信息 |
188188
| `-p`, `--python [path]` | 安装便携式 Python,安装目录为 path(仅 Windows,默认:D:\Tools\Python) |
189189

190190
**备份策略说明:**
191191

192192
- **preserve** (默认):保留配置文件(.config)和工具链(local_pkgs),删除其他内容后重新安装
193-
- **delete_all**:完全删除现有 ENV 目录,不保留任何内容
193+
- **delete_all**:备份后删除现有 ENV 目录,不保留任何内容
194+
- **delete_all_now**:立即删除现有 ENV 目录,不备份
194195
- **backup_all**:创建完整备份,保留所有内容,包括配置和工具链
195196

196197
**使用示例:**

tools/install.ps1

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,10 @@
6969
# 当 ENV 已存在时的备份策略:
7070
# preserve: Keep .config and local_pkgs, restore and delete backup
7171
# 保留 .config 和 local_pkgs,恢复后删除备份
72-
# delete_all: Delete everything, no restore
73-
# 删除所有内容,不恢复
72+
# delete_all: Backup then delete everything, no restore
73+
# 备份后删除所有内容,不恢复
74+
# delete_all_now: Delete everything immediately, no backup
75+
# 立即删除所有内容,不备份
7476
# backup_all: Keep backup with hardlink restore
7577
# 保留备份,用硬链接恢复本地包
7678
# -t, --touch-env-url <url> Specify touch_env.py download URL
@@ -250,7 +252,11 @@ function Print-Help {
250252
Write-Host " 格式: url[#branch]"
251253
Write-Host " -S, --sdk [repo] 指定 sdk 仓库地址和分支"
252254
Write-Host " 格式: url[#branch]"
253-
Write-Host " -b, --backup [strategy] 备份策略 (preserve/delete_all/backup_all)"
255+
Write-Host " -b, --backup [strategy] 备份策略 (preserve/delete_all/delete_all_now/backup_all)"
256+
Write-Host " preserve: 保留 .config 和 local_pkgs,恢复后删除备份"
257+
Write-Host " delete_all: 备份后删除所有内容,不恢复"
258+
Write-Host " delete_all_now: 立即删除所有内容,不备份"
259+
Write-Host " backup_all: 保留备份,用硬链接恢复本地包"
254260
Write-Host " -t, --touch-env-url [url] 指定 touch_env.py 下载 URL"
255261
Write-Host " -h, --help 显示此帮助信息"
256262
Write-Host ""
@@ -275,7 +281,11 @@ function Print-Help {
275281
Write-Host " Format: url[#branch]"
276282
Write-Host " -S, --sdk [repo] Specify custom sdk repository and branch"
277283
Write-Host " Format: url[#branch]"
278-
Write-Host " -b, --backup [strategy] Backup strategy (preserve/delete_all/backup_all)"
284+
Write-Host " -b, --backup [strategy] Backup strategy (preserve/delete_all/delete_all_now/backup_all)"
285+
Write-Host " preserve: Keep .config and local_pkgs, restore and delete backup"
286+
Write-Host " delete_all: Backup then delete everything, no restore"
287+
Write-Host " delete_all_now: Delete everything immediately, no backup"
288+
Write-Host " backup_all: Keep backup with hardlink restore"
279289
Write-Host " -t, --touch-env-url [url] Specify touch_env.py download URL"
280290
Write-Host " -h, --help Show this help message"
281291
Write-Host ""
@@ -1065,9 +1075,10 @@ function Install-PortablePython {
10651075
$result = New-PythonConfig
10661076

10671077
try {
1078+
# Download and extract portable Python
10681079
Download-PortablePython -UseCNMirror $UseCNMirror
10691080
Extract-PortablePython
1070-
1081+
# Configure python3xx._pth file
10711082
Configure-PythonPth
10721083
# Save portable Python path to global variable
10731084
$portablePython = $script:Config.PythonConfig.PythonPath
@@ -1087,7 +1098,9 @@ function Install-PortablePython {
10871098
}
10881099
}
10891100
catch {
1090-
$result.Result = 1
1101+
$result.Result = 2
1102+
Write-LogError "python_install_failed" $_.Exception.Message
1103+
Write-Host "请手动删除 Python 安装目录后重试" -ForegroundColor Yellow
10911104
}
10921105

10931106
return $result

tools/install.sh

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
#!/usr/bin/env bash
22
#
3+
# File : install.sh
4+
# This file is part of RT-Thread RTOS
5+
# COPYRIGHT (C) 2006 - 2026, RT-Thread Development Team
6+
#
7+
# This program is free software; you can redistribute it and/or modify
8+
# it under the terms of the GNU General Public License as published by
9+
# the Free Software Foundation; either version 2 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License along
18+
# with this program; if not, write to the Free Software Foundation, Inc.,
19+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20+
#
21+
# Change Logs:
22+
# Date Author Notes
23+
# 2026-01-31 dongly Refactored
24+
325
# RT-Thread ENV Installation Script (Unix)
426
# Unified installation script for Linux and macOS
527
# Supports: English / 中文
@@ -18,7 +40,15 @@
1840
# -P, --packages <repo>[#<branch>] Specify custom packages repository and branch
1941
# -E, --env <repo>[#<branch>] Specify custom env repository and branch
2042
# -S, --sdk <repo>[#<branch>] Specify custom sdk repository and branch
21-
# -b, --backup <strategy> Backup strategy (preserve/delete_all/backup_all)
43+
# -b, --backup <strategy> Backup strategy when ENV exists:
44+
# preserve: Keep .config and local_pkgs, restore and delete backup
45+
# 保留 .config 和 local_pkgs,恢复后删除备份
46+
# delete_all: Backup then delete everything, no restore
47+
# 备份后删除所有内容,不恢复
48+
# delete_all_now: Delete everything immediately, no backup
49+
# 立即删除所有内容,不备份
50+
# backup_all: Keep backup with hardlink restore
51+
# 保留备份,用硬链接恢复工具链
2252
# -t, --touch-env-url <url> Specify touch_env.py download URL
2353
# -h, --help Show this help message
2454
#
@@ -401,7 +431,15 @@ print_help() {
401431
echo " -P, --packages <repo>[#<branch>] Specify custom packages repository and branch"
402432
echo " -E, --env <repo>[#<branch>] Specify custom env repository and branch"
403433
echo " -S, --sdk <repo>[#<branch>] Specify custom sdk repository and branch"
404-
echo " -b, --backup <strategy> Backup strategy (preserve/delete_all/backup_all)"
434+
echo " -b, --backup <strategy> Backup strategy (preserve/delete_all/delete_all_now/backup_all)"
435+
echo " preserve: Keep .config and local_pkgs, restore and delete backup"
436+
echo " 保留 .config 和 local_pkgs,恢复后删除备份"
437+
echo " delete_all: Backup then delete everything, no restore"
438+
echo " 备份后删除所有内容,不恢复"
439+
echo " delete_all_now: Delete everything immediately, no backup"
440+
echo " 立即删除所有内容,不备份"
441+
echo " backup_all: Keep backup with hardlink restore"
442+
echo " 保留备份,用硬链接恢复工具链"
405443
echo " -t, --touch-env-url <url> Specify touch_env.py download URL"
406444
echo " -h, --help Show this help message"
407445
echo ""

0 commit comments

Comments
 (0)