如何给OpenWrt打patch补丁
通常情况下大家习惯了使用diff工具制作工具,但是在openwrt中确使用quilt工具制作补丁
diff和quilt使用方法参考网站
https://blog.csdn.net/jasonchen_gbd/article/details/44163105
如何在openwrt中制作补丁
参考官网 https://openwrt.org/docs/guide-developer/patches
内容如下
Working with patches
OpenWrt Buildroot integrates quilt for easy patch management. This document outlines some common patching tasks like adding a new patch or editing existing ones.
Prepare quilt configuration
In order to let quilt create patches in OpenWrts preferred format, a configuration file .quiltrc
containing common diff and patch options must be created in the local home directory.
cat > ~/.quiltrc <<EOF QUILT_DIFF_ARGS="--no-timestamps --no-index -p ab --color=auto" QUILT_REFRESH_ARGS="--no-timestamps --no-index -p ab" QUILT_SERIES_ARGS="--color=auto" QUILT_PATCH_OPTS="--unified" QUILT_DIFF_OPTS="-p" EDITOR="nano" EOF
EDITOR
specifies the preferred editor for interactive patch editingThe other variables control the patch format property like a/, b/ directory names and no timestamps
FreeBSD does not support the
--color=auto
option and-pab
must be written as-p ab
“-p ab” is working with quilt 0.63 on Linux and is documented in man page.
Adding a new patch
To add a completely new patch to an existing package example start with preparing the source directory:
make package/example/{clean,prepare} V=s QUILT=1
|
For host-side packages, you may want to detail the make target:
make package/example/host/{clean,prepare} V=s QUILT=1
|
This unpacks the source tarball and prepares existing patches as quilt patch series (if any). The verbose output will show where the source got extracted.
Change to the prepared source directory.
cd build_dir/target-*/example-*
|
Note : It can happen that you need to go one level lower as the source is extracted in build_dir/target-*/BUILD_VARIANT/example-* . This happens when multiple build variants of a package are defined in the Makefile.
Apply all existing patches using quilt push.
quilt push -a
|
Create a new, empty patch file with the quilt new command:
quilt new 010-main_code_fix.patch
|
The name should start with a number, followed by a hyphen and a very short description of what is changed
The chosen number should be higher than any existing patch - use quilt series to see the list of patches
The patch file name should be short but descriptive
After creating the empty patch, files to edit must be associated with it. The quilt add command can be used for that - once the file got added it can be edited as usual.
A shortcut for both adding a file and open it in an editor is the quilt edit command:
quilt edit src/main.c
|
src/main.c
gets added to010-main_code_fix.patch
The file is opened in the editor specified with
EDITOR
in.quiltrc
Repeat that for any file that needs to be edited.
After the changes are finished, they can be reviewed with the quilt diff command.
quilt diff
|
If the diff looks okay, proceed with quilt refresh to update the 010-main_code_fix.patch
file with the changes made.
quilt refresh
|
Change back to the toplevel directory of the buildroot.
cd ../../../
|
To move the new patch file over to the buildroot, run update on the package:
make package/example/update V=s
|
Finally rebuild the package to test the changes:
make package/example/{clean,compile} package/index V=s
|
If problems occur, the patch needs to be edited again to solve the issues. Refer to the section below to learn how to edit existing patches.
Edit an existing patch
Start with preparing the source directory:
make package/example/{clean,prepare} V=s QUILT=1
|
Change to the prepared source directory.
cd build_dir/target-*/example-*
|
List the patches available:
quilt series
|
Advance to the patch that needs to be edited:
quilt push 010-main_code_fix.patch
|
When passing a valid patch filename to push, quilt will only apply the series until it reaches the specified patch
If unsure, use quilt series to see existing patches and quilt top to see the current position
If the current position is beyound the desired patch, use quilt pop to remove patches in the reverse order
You can use the “force” push option (e.g.
quilt push -f 010-main_code_fix.patch
) to interactively apply a broken (i.e. has rejects) patch
Edit the patched files using the quilt edit command, repeat for every file that needs changes.
quilt edit src/main.c
|
Check which files are to be included in the patch:
quilt files
|
Review the changes with quilt diff.
quilt diff
|
If the diff looks okay, proceed with quilt refresh to update the current patch with the changes made.
quilt refresh
|
Change back to the toplevel diretory of the buildroot.
cd ../../../
|
To move the updated patch file over to the buildroot, run update on the package:
make package/example/update V=s
|
Finally rebuild the package to test the changes:
make package/example/{clean,compile} package/index V=s
|
Adding or editing kernel patches
The process for modifying kernel patches is the same as for packages, only the make targets and directories differ.
For the kernel, an additional subdirectory for patches is used, generic/
contains patches common to all architectures and platform/
contains patches specific to the current target.
To prepare the kernel tree, use:
make target/linux/{clean,prepare} V=s QUILT=1
|
For Attitude Adjustment, the source tree is in the linux-architecture subdirectory:
cd build_dir/linux-*/linux-3.*
|
For Barrier Breaker (trunk), the source tree is in the target-architecture subdirectory (potentially with a subarch):
cd build_dir/target-*/linux-*/linux-3.*
|
Moving the changes back over to the buildroot tree from the build tree is done with ( you need to go back to trunk to do this):
make target/linux/update package/index V=s
|
( Patches should be named with the correct prefix, platform/000-abc.patch or generic/000-abc.patch. If not the update may not work correctly.)
Afterwards, if we want to verify whether our patch is applied or not, we can go to the top level directory with
cd ../../../../
|
and preparing again the linux folder for some modification with
make target/linux/{clean,prepare} V=s QUILT=1
|
During this process all the applied patched will be shown, ours being among them, preceeded by generic/ or platform/ depending on what directory we placed the patch. Another way of retrieving the applied patches is through
quilt series
|
as explained on the previous sections, after having made make target/linux/{clean,prepare} …
Adding or editing toolchain patches
For example, gcc:
To prepare the tool tree, use:
make toolchain/gcc/{clean,prepare} V=99 QUILT=1
|
The source tree depends on chosen lib and gcc :
cd build_dir/toolchain-mips_r2_gcc-4.3.3+cs_uClibc-0.9.30.1/gcc-4.3.3
|
Refreshing the patches is done with:
make toolchain/gcc/update V=99
|
Naming patches
valid for target/linux/generic and <arch>:
The patches-* subdirectories contain the kernel patches applied for every OpenWrt target. All patches should be named 'NNN-lowercase_shortname.patch' and sorted into the following categories:0xx - upstream backports 1xx - code awaiting upstream merge 2xx - kernel build / config / header patches 3xx - architecture specific patches 4xx - mtd related patches (subsystem and drivers) 5xx - filesystem related patches 6xx - generic network patches 7xx - network / phy driver patches 8xx - other drivers 9xx - uncategorized other patchesALL patches must be in a way that they are potentially upstreamable, meaning:- they must contain a proper subject - they must contain a proper commit message explaining what they change - they must contain a valid Signed-off-by line
from: PATCHES
Refreshing patches
When a patched package (or kernel) is updated to a newer version, existing patches might not apply cleanly anymore and patch will report fuzz when applying them. To rebase the whole patch series the refresh make target can be used:
make package/example/refresh V=s
|
For kernels, use:
make target/linux/refresh V=s
|
Iteratively modify patches without cleaning the source tree
When implementing new changes, it is often required to edit patches multiple times. To speed up the process, it is possible to retain the prepared source tree between edit operations.
Initially prepare the source tree as documented above
Change to the prepared source directory
Advance to the patch needing changes
Edit the files and refresh the patch
Fully apply the remaining patches using quilt push -a (if any)
From the toplevel directory, run
make package/example/{compile,install}
ormake target/linux/{compile,install}
for kernelsTest the binary
If further changes are needed, repeat from step 2.
Finally run
make package/example/update
ormake target/linux/update
for kernels to copy the changes back to buildroot
Further information
Official quilt man page
How To Survive With Many Patches - Introduction to Quilt (PDF) (read online here)
Applying patches newbie doubt
如何给OpenWrt打patch补丁相关推荐
- iOS动态部署之RSA加密传输Patch补丁
概要:这一篇博客主要说明下iOS客户端动态部署方案中,patch(补丁)是如何比较安全的加载到客户端中. 在整个过程中,需要使用RSA来加密(你可以选择其它的非对称加密算法),MD5来做校验(同样,你 ...
- nginx patch补丁方式添加 nginx_upstream_check_module 模块,并测试健康检查
原创博客地址:陈帅同学-nginx patch补丁方式添加 nginx_upstream_check_module 模块,并测试健康检查 我的测试环境 contos:6.7nginx:1.63 che ...
- buildroot patch 补丁文件使用方法
在使用 buildroot 编译内核源码时,时常会有修改驱动或第三方包的需求,直接在 output/build/ 下修改源码,make clean 修改内容就会丢失,使用打补丁方式,把补丁包放到pac ...
- Linux 内核实时补丁 PREEMPT_RT补丁 与 Linux4.1.15 + patch-4.1.15-rt18.patch 补丁,实测实时性差
Linux4.1.15 + patch-4.1.15-rt18.patch 补丁,实测实时性差 开发环境 发行环境 该环境用于发行 Linux: 4.1.15 preempt_rt: patch-4. ...
- Oracle Patch补丁体系和如何打补丁
Oracle作为大型商用关系型数据库,从其补丁体系就可以看出其考虑的全面性.首先我们看下Oracle Patch的主要类型[参考1和2]: Version/维护版本 针对前一个维护版本的所有补丁进行整 ...
- 构建patch补丁并提交git和rpm软件包验证
目录 一:建立patch补丁和提交git 二.rpm软件包验证 一:建立patch补丁和提交git 进入项目页面,复制ssh链接,git clone到本地 例如: cd ~; mkdir old; c ...
- 利用SOLR搭建企业搜索平台 之八(solr 实现去掉重复的搜索结果,打SOLR-236_collapsing.patch补丁)...
引用Bory.Chan http://blog.chenlb.com/2009/04/apply-solr-collapsing-patch-remove-duplicate-result.html ...
- Rimworld Mod制作教程3 使用Xpath制作patch(补丁)
文章目录 废话 核心内容 1 使用Xpath制作patch(补丁) 1.1 基本格式 1.2 手术类型 1.3 ~~偷窥~~ 参考他人代码 废话 rimworld在A17版本后提供了一个新的编写mod ...
- OpenWrt quilt patch 方法
转自: http://blog.csdn.net/wwx0715/article/details/25160361 一.前言 配置完Openwrt后,首次编译时会在编译过程中下载各种源码包,而且解压这 ...
最新文章
- json数据交互与@RequestBody
- 安装Mongodb并解决用户授权问题
- C#的变迁史08 - C# 5.0 之并行编程总结篇
- git head指向老版本_Git最全总结
- arm linux 交叉编译boost库
- css奇数、偶数样式
- echarts 柱状图如何不顶格_echarts柱状图如何中间对齐而不是底部对齐?
- mysql数据库存储过程异常处理
- 事实表 的指标 维度表_数据库-事实表和维度表之间的区别?
- C++验证奇偶性时求余运算%和位运算的速度比较
- 怎么在服务器上显示u盘启动,电脑服务器怎么设置U盘启动
- 第1章 Python 顺序结构
- CRISPR最新:新CRISPR技术靶向更复杂的人类基因组代码
- 配置 已完成 请勿关闭计算机,win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机”的解决方法...
- Hive DML 语句操作报错
- ROS入门——胡春旭老师《机器人开发实践》在ROS-Melodic下的编译
- SRS4.0源代码分析之RTMP拉流处理
- 10.深度学习之经典网络-1
- Python学习笔记 - Python语言概述和开发环境
- 解决网易云音乐变灰没有版权歌曲
热门文章
- Excel一个单元格中输入度分秒转换成小数(如256.3246(读256度32分46秒))
- 第10届(深圳)城市艺博会即将于12月13日开幕!
- elance相关文章
- IntelliJ IDEA - 闪退解决方案
- I/O 管理 —— I/O控制器
- 华硕A456UR7500初次非完美黑苹果安装教程
- 红米k40可以升级鸿蒙系统吗,红米k40哪个版本系统版本好
- 数字信号处理第一章:离散时间信号与离散时间系统
- matlab 四叶草,Matlab入门教程 第七章 Simulink 基础
- Linux驱动之oops错误:addr2line工具定位错误