码迷,mamicode.com
首页 > 系统相关 > 详细

linux命令: patch

时间:2016-07-03 01:40:04      阅读:244      评论:0      收藏:0      [点我收藏+]

标签:

 

一. 针对单文件的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

 

linux命令: patch

标签:

原文地址:http://www.cnblogs.com/mylinux/p/5636393.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!