打补丁patch 命令使用

http://www.cnblogs.com/huanghuang/archive/2011/07/14/2106402.html

patch 命令用于打补丁,补丁文件是使用diff产生的
patch 命令语法

patch [ -b [ -B Prefix ] ] [ -f ] [ -l ] [ -N ] [ -R ] [ -s ] [ -v ] [ -c | -e | -n ] [ -d Directory ] [ -D Define ] [ -F Number ] [ -i PatchFile ] [ -o OutFile ] [ -p Number ] [  -r RejectFile ] [ -x Number ] [ File ]

patch 命令失败或拒绝接受补丁时,会产生一个和原文件同名,以".rej"为后缀的差异文件。    
使用 -b 时,会产生一个和原文件同名,以".orig"为后缀的备份文件。

常使用的 patch 参数:
-p: 指定目录级别(从路径全称中除去几层目录)如,如果补丁文件包含路径名称 /curds/whey/src/blurfl/blurfl.c
那么:-p 0 使用完整路径名 -p 1 除去前导斜杠,留下 curds/whey/src/blurfl/blurfl.c。 -p 4 除去前导斜杠和前三个目录,留下 blurfl/blurfl.c。

-d :Directory 打补丁前,更改当前目录到指定目录
-i :PatchFile 指定补丁文件,而不是从标准输入中读取补丁信息
-R :逆向补丁,这个选项在防止打错补丁很有用处

补丁的产生一般用 diff命令比较a文件和b文件

diff -Nrua a b > c.patch

如:

diff -Nrua linux-2.6./Makefile linux-2.6./Makefile >c.patch
cat c.patch

--- linux-2.6.14/Makefile 2008-07-30 16:54:20.000000000 +0800 +++ linux-2.6.26/Makefile 2008-07-14 05:51:29.000000000 +0800 @@ -1,8 +1,8 @@ VERSION = 2 PATCHLEVEL = 6 -SUBLEVEL = 14 +SUBLEVEL = 26 EXTRAVERSION = -NAME=Affluent Albatross +NAME = Rotary Wombat # *DOCUMENTATION* # To see a list of typical targets execute "make help"

--- 的文件表示将被打补丁的文件 如:linux-2.6.14/Makefile +++ 的文件表示补丁来源文件   如:linux-2.6.26/Makefile

应用

ls c.patch linux-2.6. linux-2.6.
cd linux-2.6.
patch -p1 <../c.patch

如果有多个补丁要打,则应该注意打补丁的顺序!

摘自:http://blog.ednchina.com/mcu_study/146725/message.aspx

最新文章

  1. MySQL表名和数据库关键字相同解决办法
  2. ios系统(苹果手机)按钮显示为圆角和渐变的问题
  3. Scanner概述
  4. 图片流Base64编码 转图片
  5. 对于jfinal中java.lang.Long cannot be cast to java.lang.Integer的解决方法
  6. ArcMap - 分割.
  7. Objective-C 协议(接口)
  8. linux 让root用户可以telnet
  9. nginx在window上无法启动的问题
  10. 系统学习java高并发系列三
  11. ViewDragHelper实战 自己打造Drawerlayout
  12. 奇怪,Linux下find找不到文件了
  13. call,apply,bind——js权威指南函数属性和方法章节读书笔记
  14. Spring配置表友好性优化思路
  15. 162. Find Peak Element (Array; Divide-and-Conquer)
  16. postgresql-distinct on理解
  17. Mockito单测,mock service层的mapper
  18. 读《锋利的jQuery》中first-child时的一个细节
  19. 5.Appium+真机Demo
  20. ASP.NET Core 返回文件、用户下载文件,从网站下载文件,动态下载文件

热门文章

  1. sql2005 全文索引
  2. style在进行图形绘制前,要设置好绘图的样式
  3. 在client类中设置访问属性 address,business和individua
  4. PHP对于Session漏洞的防范
  5. [转]Net 下采用GET/POST/SOAP方式动态调用WebService C#实现
  6. yii2 debug工具条不出现
  7. Maven学习记录
  8. XMLHttpRequest函数
  9. SQLServer2008:助您轻松编写T-SQL存储过程(原创)【转】
  10. 非模态对话框的PreTranslateMessage() 没有用,无法进去