patch命令用来打补丁,可以打*.patch文件。
如:
$ cd linux-2.6.22.6
$ patch -p1 < ../ *.patch
$ cd linux-2.6.22.6
$ patch -p1 < ../ *.patch
patch -p0 < lcd.patch
通常补丁中会指明要修改文件的路径,参数-pn ,表示忽略路径中第n个斜线之前的目录。
如下,假设*.patch中有如下几行。
--- u-boot-sh4-1.3.1_stm23_0042/cpu/sh/stx7105/stx7105.c 2008-10-15 00:09:42.000000000 +0100
+++ u-boot-sh4-1.3.1_stm23_0042-mb680/cpu/sh/stx7105/stx7105.c 2009-03-23 13:47:15.000000000 +0000
+++ u-boot-sh4-1.3.1_stm23_0042-mb680/cpu/sh/stx7105/stx7105.c 2009-03-23 13:47:15.000000000 +0000
patch 命令根据u-boot-sh4-1.3.1_stm23_0042/cpu/sh/stx7105/stx7105.c 寻找源文件。
-p1,表示忽略第一个斜线之前的目录,要修改的源文件是当前目录下的cpu/sh/stx7105/stx7105.c。
提取*.patch命令:
svn diff > *.patch
提取不同SVN版本间的patch:
svn diff -r1:2 > *.patch2. patch 的另一种用法:
patch -Np1 -i xxx.patch