一. 针对单文件的patch:
我们以mkprj.sh.1和mkprj.sh两个文件为例:
[[email protected] tst]# ls
mkprj.sh.1 mkprj.sh
看两个文件的差异:
[[email protected] 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
[[email protected] tst]# diff mkprj.sh mkprj.sh.1 > mk_patch
2. 打补丁patch
[[email protected] tst]# patch mkprj.sh < mk_patch
patching file mkprj.sh
观察两个文件,已经相同:
[[email protected] tst]# diff mkprj.sh mkprj.sh.1
3. 卸载补丁patch
[[email protected] tst]# patch -R mkprj.sh < mkpatch
patching file mkprj.sh
观察两个文件,mkprj.sh又变回原来的样子了.
[[email protected] 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