Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 132 additions & 0 deletions README-en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# OpenWrt Kernel Patch Management Tool v6.0.0

A modern CVE patch creation tool designed specifically for OpenWrt developers, featuring a **workflow-driven** design philosophy for one-click automated patch creation.

## 🚀 v6.0.0 Major Updates

- **🎯 Workflow-Driven**: Transformed from toolbox mode to automated workflow mode
- **⚡ Ultra-Simple Operation**: One `auto-patch` command completes the entire patch creation process
- **📦 Code Streamlined**: Reduced from 3500+ lines to 600+ lines, improving code quality by 83%
- **🤖 Automatic Metadata**: Automatically injects complete CVE metadata during patch generation
- **📚 Documentation Reorganization**: Reorganized documentation structure by category for improved readability

## 📁 Project Structure

```
openwrt-tools/
├── tools/ # 🔧 Core Tools
│ └── quilt_patch_manager_final.sh # v6.0.0 Main Tool
├── doc/ # 📚 Categorized Documentation
│ ├── 01_tool_guides/ # Tool Usage Guides
│ ├── 02_workflow_guides/ # Workflow Process Guides
│ ├── 03_reference_manuals/ # Reference Manuals
│ ├── 04_summaries/ # Summary Archives
│ └── DOCUMENTATION_INDEX.md # Documentation Index
├── suggest/ # 💡 Improvement Suggestions
└── README.md # This File
```

## 🎯 Core Features

### 🥇 One-Click Patch Creation
```bash
# Most recommended usage - one command completes all operations
./tools/quilt_patch_manager_final.sh auto-patch <commit_id> <patch_name>
```

### 🥈 Intelligent Compatibility Detection
```bash
# Test compatibility before creating patches
./tools/quilt_patch_manager_final.sh test-patch <commit_id>
```

### 🥉 Environment Management
```bash
# View current patch status
./tools/quilt_patch_manager_final.sh status

# Clean working environment
./tools/quilt_patch_manager_final.sh clean

# Reset entire environment
./tools/quilt_patch_manager_final.sh reset-env
```

## 🔧 Installation & Dependencies

### System Requirements
- ✅ **macOS** (All versions)
- ✅ **Ubuntu 20.04+**
- ✅ **Other Linux Distributions**

### Dependency Installation
```bash
# Ubuntu/Debian
sudo apt install -y curl quilt git

# macOS
brew install quilt curl git

# CentOS/RHEL
sudo yum install -y curl quilt git
```

## 📖 Documentation Navigation

| Document Category | Recommended Reading Order | Document Path |
|-------------------|-------------------------|---------------|
| **🔰 Beginner Guide** | 1️⃣ | [`doc/01_tool_guides/QUILT_PATCH_MANAGER_GUIDE.md`](doc/01_tool_guides/QUILT_PATCH_MANAGER_GUIDE.md) |
| **⚡ Quick Start** | 2️⃣ | [`doc/02_workflow_guides/QUILT_CVE_PATCH_CREATION_GUIDE.md`](doc/02_workflow_guides/QUILT_CVE_PATCH_CREATION_GUIDE.md) |
| **📋 Standard Process** | 3️⃣ | [`doc/02_workflow_guides/CVE_PATCH_WORKFLOW.md`](doc/02_workflow_guides/CVE_PATCH_WORKFLOW.md) |
| **🔍 Version Comparison** | 4️⃣ | [`doc/01_tool_guides/VERSION_COMPARISON_v5.7_vs_v6.0.md`](doc/01_tool_guides/VERSION_COMPARISON_v5.7_vs_v6.0.md) |
| **📚 Complete Index** | 🔗 | [`doc/DOCUMENTATION_INDEX.md`](doc/DOCUMENTATION_INDEX.md) |

## 💡 Use Cases

### Scenario 1: CVE Patch Creation (Most Common)
```bash
# One-click CVE patch creation
./tools/quilt_patch_manager_final.sh auto-patch 1234567890abcdef CVE-2024-12345
```

### Scenario 2: Enterprise SVN Environment
- ✅ No Git history dependency required
- ✅ Supports multi-source patches (Linux mainline, Android, GitHub)
- ✅ Intelligent conflict warnings

### Scenario 3: High-to-Low Version Porting
- ✅ Intelligent compatibility detection
- ✅ Symbol change warnings
- ✅ Fuzzy matching support

## 🆚 Version Comparison

| Feature | v5.7.0 (Legacy) | v6.0.0 (Current) |
|---------|-----------------|------------------|
| **Operation Complexity** | Multi-step manual operations | One-click automation |
| **Lines of Code** | 3,535 lines | 607 lines |
| **Learning Curve** | Need to understand multiple commands | Only need to master `auto-patch` |
| **Error Probability** | High (multi-step) | Extremely low (automated) |
| **Maintenance Difficulty** | Complex | Simple |

## 🌟 Core Advantages

1. **🎯 Focus**: Specifically designed for OpenWrt CVE patch creation
2. **⚡ Efficiency**: One-click completion from download to generation
3. **🛡️ Security**: Intelligent compatibility detection to avoid code damage
4. **🔧 Adaptability**: Supports SVN environments and multi-source patch scenarios
5. **📚 Completeness**: Comprehensive documentation system and practical examples

## 🤝 Contributing & Support

- **📋 Issue Reports**: [GitHub Issues](https://github.com/TbusOS/openwrt-tools/issues)
- **💡 Feature Suggestions**: Check the [`suggest/`](suggest/) directory
- **📖 Documentation Improvements**: Welcome to submit PRs for documentation improvements

## 📄 License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

---

**🎉 Get Started Now**: Read [`doc/01_tool_guides/QUILT_PATCH_MANAGER_GUIDE.md`](doc/01_tool_guides/QUILT_PATCH_MANAGER_GUIDE.md) to begin your CVE patch creation journey!
153 changes: 106 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,73 +1,132 @@
# OpenWrt 内核补丁管理工具集
# OpenWrt 内核补丁管理工具 v6.0.0

## �� 目录结构
一个专为 OpenWrt 开发者设计的现代化 CVE 补丁制作工具,采用**工作流驱动**的设计理念,实现一键式自动化补丁制作。

## 🚀 v6.0.0 重大更新

- **🎯 工作流驱动**: 从工具箱模式转变为自动化工作流模式
- **⚡ 极简操作**: 一个 `auto-patch` 命令完成整个补丁制作流程
- **📦 代码精简**: 从 3500+ 行精简至 600+ 行,提升 83% 的代码质量
- **🤖 自动元数据**: 补丁生成时自动注入完整的 CVE 元数据
- **📚 文档重组**: 按类别重新组织文档结构,提升可读性

## 📁 项目结构

```
/Users/sky/linux-kernel/openwrt/
├── tools/ # 🔧 工具脚本目录
│ ├── quilt_patch_manager_final.sh # 主要工具 (v5.7) - 智能元数据集成
│ ├── patch_helper_universal.sh # 通用补丁助手
│ └── patch_helper.sh # 基础补丁助手
├── doc/ # 📚 完整文档
│ ├── QUILT_PATCH_MANAGER_GUIDE.md
│ ├── DOCUMENTATION_INDEX.md
│ ├── UBUNTU_COMPATIBILITY_GUIDE.md
│ └── ... (更多文档)
├── openwrt-source/ # OpenWrt 源码目录
└── README.md # 本文件
openwrt-tools/
├── tools/ # 🔧 核心工具
│ └── quilt_patch_manager_final.sh # v6.0.0 主工具
├── doc/ # 📚 分类文档
│ ├── 01_tool_guides/ # 工具使用指南
│ ├── 02_workflow_guides/ # 工作流程指南
│ ├── 03_reference_manuals/ # 参考手册
│ ├── 04_summaries/ # 总结归档
│ └── DOCUMENTATION_INDEX.md # 文档索引
├── suggest/ # 💡 改进建议文档
└── README.md # 本文件
```

## 🚀 快速开始
## 🎯 核心功能

### 主要工具 (推荐 v5.7)
### 🥇 一键式补丁制作
```bash
# 演示所有功能
./tools/quilt_patch_manager_final.sh demo
# 最推荐的使用方式 - 一键完成所有操作
./tools/quilt_patch_manager_final.sh auto-patch <commit_id> <patch_name>
```

# 🆕 智能补丁兼容性检测 (推荐先执行)
### 🥈 智能兼容性检测
```bash
# 在制作补丁前检测兼容性
./tools/quilt_patch_manager_final.sh test-patch <commit_id>
```

# 查看补丁状态
### 🥉 环境管理
```bash
# 查看当前补丁状态
./tools/quilt_patch_manager_final.sh status

# 🆕 网络连接检测和优化
./tools/quilt_patch_manager_final.sh test-network

# 自动制作 CVE 补丁 (已集成兼容性检测)
./tools/quilt_patch_manager_final.sh auto-patch <commit_id> <patch_name>
# 清理工作环境
./tools/quilt_patch_manager_final.sh clean

# 🆕 生成补丁并自动集成元数据 (推荐)
./tools/quilt_patch_manager_final.sh auto-refresh
# 重置整个环境
./tools/quilt_patch_manager_final.sh reset-env
```

### 补丁管理
## 🔧 安装与依赖

### 系统要求
- ✅ **macOS** (所有版本)
- ✅ **Ubuntu 20.04+**
- ✅ **其他 Linux 发行版**

### 依赖安装
```bash
# 应用补丁
./tools/quilt_patch_manager_final.sh push
# Ubuntu/Debian
sudo apt install -y curl quilt git

# 移除补丁
./tools/quilt_patch_manager_final.sh pop
# macOS
brew install quilt curl git

# 清理补丁和临时文件
./tools/quilt_patch_manager_final.sh clean
# CentOS/RHEL
sudo yum install -y curl quilt git
```

## 📖 详细文档
## 📖 文档导航

查看 `doc/DOCUMENTATION_INDEX.md` 获取完整的工具和文档索引。
| 文档类别 | 推荐阅读顺序 | 文档路径 |
|---------|-------------|----------|
| **🔰 新手入门** | 1️⃣ | [`doc/01_tool_guides/QUILT_PATCH_MANAGER_GUIDE.md`](doc/01_tool_guides/QUILT_PATCH_MANAGER_GUIDE.md) |
| **⚡ 快速上手** | 2️⃣ | [`doc/02_workflow_guides/QUILT_CVE_PATCH_CREATION_GUIDE.md`](doc/02_workflow_guides/QUILT_CVE_PATCH_CREATION_GUIDE.md) |
| **📋 标准流程** | 3️⃣ | [`doc/02_workflow_guides/CVE_PATCH_WORKFLOW.md`](doc/02_workflow_guides/CVE_PATCH_WORKFLOW.md) |
| **🔍 版本对比** | 4️⃣ | [`doc/01_tool_guides/VERSION_COMPARISON_v5.7_vs_v6.0.md`](doc/01_tool_guides/VERSION_COMPARISON_v5.7_vs_v6.0.md) |
| **📚 完整索引** | 🔗 | [`doc/DOCUMENTATION_INDEX.md`](doc/DOCUMENTATION_INDEX.md) |

## 🎯 支持平台
## 💡 使用场景

- ✅ macOS (所有版本)
- ✅ Ubuntu 20.04+
- ✅ 其他 Linux 发行版
### 场景 1: CVE 补丁制作 (最常用)
```bash
# 一键制作 CVE 补丁
./tools/quilt_patch_manager_final.sh auto-patch 1234567890abcdef CVE-2024-12345
```

## 🔧 依赖要求
### 场景 2: 企业 SVN 环境
- ✅ 无需 Git 历史依赖
- ✅ 支持多源补丁 (Linux 主线、Android、GitHub)
- ✅ 智能冲突预警

```bash
# Ubuntu/Debian
sudo apt install -y curl quilt
### 场景 3: 高版本向低版本移植
- ✅ 智能兼容性检测
- ✅ 符号变更预警
- ✅ 模糊匹配支持

# macOS
brew install quilt
```
## 🆚 版本对比

| 特性 | v5.7.0 (旧版) | v6.0.0 (当前) |
|------|---------------|---------------|
| **操作复杂度** | 多步手动操作 | 一键自动化 |
| **代码行数** | 3,535 行 | 607 行 |
| **学习成本** | 需要了解多个命令 | 只需掌握 `auto-patch` |
| **出错概率** | 高 (多步骤) | 极低 (自动化) |
| **维护难度** | 复杂 | 简单 |

## 🌟 核心优势

1. **🎯 专注性**: 专门为 OpenWrt CVE 补丁制作而设计
2. **⚡ 高效性**: 一键完成从下载到生成的全流程
3. **🛡️ 安全性**: 智能兼容性检测,避免代码损坏
4. **🔧 适应性**: 支持 SVN 环境和多源补丁场景
5. **📚 完整性**: 详尽的文档体系和实战案例

## 🤝 贡献与支持

- **📋 问题反馈**: [GitHub Issues](https://github.com/TbusOS/openwrt-tools/issues)
- **💡 功能建议**: 查看 [`suggest/`](suggest/) 目录
- **📖 文档改进**: 欢迎提交 PR 改进文档

## 📄 许可证

本项目采用 MIT 许可证 - 详见 [LICENSE](LICENSE) 文件。

---

**🎉 立即开始**: 阅读 [`doc/01_tool_guides/QUILT_PATCH_MANAGER_GUIDE.md`](doc/01_tool_guides/QUILT_PATCH_MANAGER_GUIDE.md) 开始您的 CVE 补丁制作之旅!
38 changes: 33 additions & 5 deletions doc/01_tool_guides/QUILT_PATCH_MANAGER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,39 @@
```

**工作流程详解:**
1. **兼容性测试**: 自动对指定的 `commit_id` 进行全面的兼容性分析。如果发现冲突,会给出警告并让用户确认是否继续。
2. **创建补丁**: 在内核源码目录中自动创建一个新的 quilt 补丁。
3. **添加文件**: 自动提取该 commit 涉及的所有文件,并使用 `quilt add` 将它们添加到补丁中。
4. **等待用户修改**: 脚本会在此暂停,等待您根据需要**手动修改代码**以解决冲突或进行适配。
5. **生成最终补丁**: 您修改完成后,按回车键,脚本会自动执行 `refresh-with-header`,生成包含原始作者、日期和提交信息的最终补丁文件,并将其拷贝到 `output` 目录。

#### 🔄 四步自动化流程

**步骤 1/4: 兼容性测试** (`test_patch_compatibility`)
- 📥 从 Linux 内核官方仓库 (`git.kernel.org`) 自动下载原始补丁
- 🔍 智能查找 OpenWrt 内核源码目录 (支持 `build_dir/target-*/linux-*/linux-*` 路径)
- 🧪 执行 `patch --dry-run -p1 --verbose` 进行干运行测试
- ⚠️ 如果发现冲突,显示详细的冲突分析报告并询问用户是否继续
- 📋 生成兼容性分析结果到临时目录

**步骤 2/4: 创建补丁并添加文件**
- 🆕 调用 `quilt new <patch_name>` 在内核源码目录创建新补丁
- 📄 使用 `awk '/^--- a\// {print $2}'` 从原始补丁中提取所有涉及的文件列表
- 💾 将文件列表保存到 `patch_manager_work/outputs/patch_files.txt`
- ✅ 验证每个文件的存在性,跳过不存在的文件
- ➕ 使用 `printf "%s\n" "${valid_files[@]}" | xargs quilt add` 批量添加文件到补丁

**步骤 3/4: 等待手动修改**
- ⏸️ 脚本智能暂停,进入交互模式
- 💡 提示用户当前是进行手动代码修改的最佳时机
- 🔧 用户可以:
- 解决补丁冲突
- 调整代码以适配当前内核版本
- 修改功能实现细节
- 测试修改效果
- ⏳ 等待用户按 Enter 键继续流程

**步骤 4/4: 生成带元数据的最终补丁** (`quilt_refresh_with_header`)
- 📋 使用 `awk '/^diff --git/ {exit} {print}'` 从原始补丁提取完整元数据头部
- 🔄 执行 `quilt refresh` 生成当前修改的代码差异
- 🔗 将原始元数据 (作者、日期、描述、CVE 信息) 与代码差异智能合并
- 📤 自动复制最终补丁到 `patch_manager_work/outputs/` 目录
- ✅ 补丁同时保存在内核的 `patches/` 目录和输出目录中

---

Expand Down
Loading