一. 针对单文件的patch:
我们以mkprj.sh.1和mkprj.sh两个文件为例:
[root@localhost tst]# ls
mkprj.sh.1 mkprj.sh
看两个文件的差异:
[root@localhost tst]# diff mkprj.sh mkprj.sh.1
20,21c20
< cd $workdir/fornew; mkdir crosstools kernel nfs_root uboot;
< cd $workdir/farsight; mkdir crosstools kernel nfs_root uboot;
---
> cd $workdir/farsight1; mkdir crosstools kernel nfs_root uboot;
23c22
<
---
> cd $workdir/configs2;
1. 做补丁patch
[root@localhost tst]# diff mkprj.sh mkprj.sh.1 > mk_patch
2. 打补丁patch
[root@localhost tst]# patch mkprj.sh < mk_patch
patching file mkprj.sh
观察两个文件,已经相同:
[root@localhost tst]# diff mkprj.sh mkprj.sh.1
3. 卸载补丁patch
[root@localhost tst]# patch -R mkprj.sh < mkpatch
patching file mkprj.sh
观察两个文件,mkprj.sh又变回原来的样子了.
[root@localhost tst]# diff mkprj.sh mkprj.sh.1
20,21c20
< cd $workdir/fornew; mkdir crosstools kernel nfs_root uboot;
< cd $workdir/farsight; mkdir crosstools kernel nfs_root uboot;
---
> cd $workdir/farsight1; mkdir crosstools kernel nfs_root uboot;
23c22
<
---
> cd $workdir/configs2;
二、针对目录的patch
如何制作LINUX的patch文件及如何打patch http://blog.csdn.net/zhenwenxian/article/details/8393731
#ls /work/kernel
linux-2.6.22.6 linux-2.6.22.6_jz2440
1. 做补丁patch
#diff -Naur linux-2.6.22.6/ linux-2.6.22.6_jz2440/ > linux-2.6.22.6_jz2440.patch
#ls /work/kernel
linux-2.6.22.6 linux-2.6.22.6_jz2440 linux-2.6.22.6_jz2440.patch
2. 打补丁patch
#cd /work/kernel/linux-2.6.22.6
patch -p1 < ../linux-2.6.22.6_jz2440.patch
3. 卸补丁(-R)
patch -R -p1 < ../linux-2.6.22.6_jz2440.patch