quilt命令详解
简介
quilt是ubuntu系统帮助我们管理patch的一个工具,具体参数及实例如下:
Usage: quilt [--trace[=verbose]] [--quiltrc=XX] command [-h] ...
quilt --version
Commands are:
add fold mail refresh snapshot
annotate fork new remove top
applied graph next rename unapplied
delete grep patches revert upgrade
diff header pop series
edit import previous setup
files init push shell
原理
掌握quilt的关键是了解使用quilt的流程。使用quilt时,我们会在一个完整的源代码树里工作。只要我们在源代码树里使用了quilt命令,quilt就会在源代码树的根目录建立两个特殊目录:patches和.pc。quilt在patches目录保存它管理的所有补丁。quilt用.pc目录保存自己的内部工作状态,用户不需要了解这个目录。patches/series文件记录了quilt当前管理的补丁。补丁按照加入的顺序排列,早加入的补丁在前。quilt用堆栈的概念管理补丁的应用。
我们在应用补丁A前,必须先应用所有早于补丁A的补丁。所以,patches/series中的补丁总是从上向下应用。
我们在源代码树中作任何修改前,必须用"quilt add"命令将要修改的文件与一个补丁联系起来。在完成修改后,用"quilt refresh"命令将修改保存到已联系的补丁。
#查询已应用/未应用的patch
quilt applied/unapplied
#生成一个新的patch
quilt new patch_name
#添加patch关联的文件(如果没有指定patch,文件就和栈顶的patch关联起来)
quilt add [ -P patch_name ] file_name
# 刷新补丁
quilt refresh [patch_name]
#即将指定补丁的文件变化保存到补丁。省略文件名表示刷新栈顶补丁,修改完成后生成最终patch,在关联文件后可以直接修改文件,也可以使用quilt edit修改文件,只能对栈顶patch进行操作,不能制定patch
quilt refresh
#查看已修改的文件,可以使用 quilt files [patch_name] 查看与指定patch相关联的文件, quilt files -val 查看所有补丁联系的所有文件,"-v"参数表示更友好的显示,"-a"参数表示显示所有补丁,"-l"参数显示补丁名
quilt files
#显示修改了指定文件的所有补丁
quilt patches file_name
quilt annotate file_name #会指出哪个补丁修改了哪一行
#对比修改的文件,使用 quilt diff -z 命令不会显示已经保存的差异。 quilt diff 显示所有的差异,不管是否保存过
quilt diff
quilt diff -z [-P patch_name] [file_name]
#可以查看指定补丁指定文件的当前改动。省略-P参数表示查看当前补丁的改动,省略文件名表示查看所有改动。
#查看所有的patch
quilt series
#查看最上层的patch
quilt top
quilt next #显示下一个可以应用的补丁
quilt previous #显示上一条应用过的补丁
#导入patch
quilt import patch_name
#回退到上一个patch
quilt pop
quilt pop -a #撤销所有应用的patch
#重新添加刚刚回退的patch
quilt push
#删除已有的patch
quilt delete filename.patch
常用命令说明
生成一个新的空patch文件
[root@localhost /]# qulit test.patch
将要修改的文件关联patch
[root@localhost /]# quilt add {files}
//files=*,则是当前目录下所用文件,不包含子目录,如果需要子目录则subdir/*即可
取消文件对patch的关联,是与add相反的操作
[root@localhost /]# quilt remove filename
修改文件完后更新patch
[root@localhost /]# quilt refresh
查看对比修改的patch内容
[root@localhost /]# quilt diff
从源代码找与之关联的patch
[root@localhost /]# quilt patches test.txt
查看当前patch关联的文件
[root@localhost /]# quilt files
回退刚才的改动 (注:只回退文件的改动,对当前的patch文件没有回退,applied->unapplied)
[root@localhost /]# quilt pop
重新应用刚才的改动(注:添加文件的改动,对当前的patch文件没有回退,unapplied->applied)
[root@localhost /]# quilt push
导入patch文件
[root@localhost /]# quilt import path/files //patch绝对路径
删除已有的test.patch
[root@localhost /]# quilt delete test.patch
查看所有Patches
[root@localhost /]# quilt series
应用所有patches
[root@localhost /]# quilt push -a
取消所有以应用的patch
[root@localhost /]# quilt pop -a
查看当前已应用的Patch
[`root@localhost /]# quilt applied`
查看当前未应用的Patches
[root@localhost /]# quilt unapplied
修改已经存在的patch:
1.导入filename文件:
[root@localhost /]# quilt import filename
2.推送filename文件
[root@localhost /]# quilt push filename
3.关联filename文件
[root@localhost /]# quilt add filename
4.重新更新filename文件
[root@localhost /]# quilt refresh filename
实例: 导入补丁
-bash-4.1$ pwd
/extra/chkq76/DEV_telia42_overblue/applications/3pp/ekioh-webkit/opensource
我们可以用applied命令查询当前已应用的补丁。
-bash-4.1$ quilt applied
No patches applied
unapplied命令查询当前还没有应用的补丁,
-bash-4.1$ quilt unapplied
patches/host_build_fixes.patch
patches/comment_away_dead_code.patch
top命令查询栈顶补丁,即已应用的最新补丁:
-bash-4.1$ quilt top
No patches applied
我们可以使用push命令应用补丁,例如:
$ quilt push -a
push的"-a"参数表示应用所有补丁。
在使用push命令后,prj 目录会多了一个叫.pc的隐含子目录。quilt用这个目录保存内部状态,用户不需要了解这个目录。应用补丁后,我们再使用applied、unapplied和top命令查看:
实例: 修改文件
我们必须将对源代码树所作的任何改动都和一个补丁联系起来。add命令将文件的当前状态与补丁联系起来。add命令的格式为:
quilt add [-P 补丁名] 文件名
如果未指定补丁名,文件就与栈顶补丁联系起来。目前,我们的栈顶补丁是官方补丁。我们不想修改这个补丁,可以用new命令新建一个补丁:
-bash-4.1$ quilt new merge_test.patch
Patch patches/merge_test.patch is now on top
-bash-4.1$quilt top
patches/merge_test.patch
现在多了一个.pc文件夹与两个文件
-bash-4.1$ cd .pc/
-bash-4.1$ ll
total 8
-rw-r--r--. 1 chkq76 512 17 Sep 1 17:16 applied-patches
drwxr-xr-x. 2 chkq76 512 4096 Sep 1 17:16 merge_test.patch
-bash-4.1$ cat applied-patches
merge_test.patch
-bash-4.1$ quilt applied
patches/merge_test.patch
然后用add命令向栈顶补丁添加一个准备修改的文件:
-bash-4.1$quilt addsrc/3rdParty/webkit/work/WebCore/page/FocusController.h
File src/3rdParty/webkit/work/WebCore/page/FocusController.h added to patch patches/merge_test.patch
-bash-4.1$ls -la .pc/merge_test.patch/src/3rdParty/webkit/work/WebCore/page/FocusController.h
-rw-r--r--. 1 chkq76 512 2387 Jan 29 2010 .pc/merge_test.patch/src/3rdParty/webkit/work/WebCore/page/FocusController.h
add命令为指定补丁保存了指定文件的当前快照,当我们执行refresh命令时,quilt就会检查文件的变化,将差异保存到指定补丁中。使用"quilt diff -z [-P 补丁名] [文件名]"可以查看指定补丁指定文件的当前改动。省略-P参数表示查看当前补丁的改动,省略文件名表示查看所有改动。我们修改drv2.h后,执行diff命令:
-bash-4.1$ quilt diff -z
-bash-4.1$ quilt diff
-bash-4.1$ vim src/3rdParty/webkit/work/WebCore/page/FocusController.h
-bash-4.1$ quilt diff
Index: opensource/src/3rdParty/webkit/work/WebCore/page/FocusController.h
===================================================================
--- opensource.orig/src/3rdParty/webkit/work/WebCore/page/FocusController.h
+++ opensource/src/3rdParty/webkit/work/WebCore/page/FocusController.h
@@ -55,7 +55,7 @@ namespace WebCore {
void setFocused(bool);
bool isFocused() const { return m_isFocused; }
-
+leosu test!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! quilt test
private:
Page* m_page;
RefPtr<Frame> m_focusedFrame;
只要文件已经与我们希望保存改动的补丁联系过了,我们就可以多次修改文件。
使用"quilt files [补丁名]"命令可以查看与指定补丁关联的文件。使用"quilt files -val"可以查看所有补丁联系的所有文件。"-v"参数表示更友好的显示,"-a"参数表示显示所有补丁,"-l"参数显示补丁名。例如:
-bash-4.1$ quilt files
src/3rdParty/webkit/work/WebCore/page/FocusController.h
"quilt refresh [补丁名]"刷新补丁,即将指定补丁的文件变化保存到补丁。省略文件名表示刷新栈顶补丁。我们refresh后,查看补丁文件:
-bash-4.1$ quilt refresh
Refreshed patch patches/merge_test.patch
-bash-4.1$ cat patches/merge_test.patch
Index: opensource/src/3rdParty/webkit/work/WebCore/page/FocusController.h
===================================================================
--- opensource.orig/src/3rdParty/webkit/work/WebCore/page/FocusController.h
+++ opensource/src/3rdParty/webkit/work/WebCore/page/FocusController.h
@@ -55,7 +55,7 @@ namespace WebCore {
void setFocused(bool);
bool isFocused() const { return m_isFocused; }
-
+leosu test!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! quilt test
private:
Page* m_page;
RefPtr<Frame> m_focusedFrame;
"quilt diff -z"命令不会显示已经保存的差异。"quilt diff"显示所有的差异,不管是否保存过。
-bash-4.1$ quilt diff
Index: opensource/src/3rdParty/webkit/work/WebCore/page/FocusController.h
===================================================================
--- opensource.orig/src/3rdParty/webkit/work/WebCore/page/FocusController.h
+++ opensource/src/3rdParty/webkit/work/WebCore/page/FocusController.h
@@ -55,7 +55,7 @@ namespace WebCore {
void setFocused(bool);
bool isFocused() const { return m_isFocused; }
-
+leosu test!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! quilt test
private:
Page* m_page;
RefPtr<Frame> m_focusedFrame;
-bash-4.1$ quilt diff -z
-bash-4.1$
实例: 添加/删除文件
-bash-4.1$quilt add src/3rdParty/webkit/work/WebCore/page/FocusController.h___bak
File src/3rdParty/webkit/work/WebCore/page/FocusController.h___bak added to patch patches/merge_test.patch
-bash-4.1$ll .pc/merge_test.patch/src/3rdParty/webkit/work/WebCore/page/FocusController.*
-rw-r--r--. 1 chkq76 512 2387 Jan 29 2010 .pc/merge_test.patch/src/3rdParty/webkit/work/WebCore/page/FocusController.h
----------. 1 chkq76 512 0 Sep 1 17:33 .pc/merge_test.patch/src/3rdParty/webkit/work/WebCore/page/FocusController.h___bak //new add file
-bash-4.1$ quilt files
src/3rdParty/webkit/work/WebCore/page/FocusController.h
src/3rdParty/webkit/work/WebCore/page/FocusController.h___bak //new add file
-bash-4.1$ vim src/3rdParty/webkit/work/WebCore/page/FocusController.h___bak
-bash-4.1$ quilt refresh
Refreshed patch patches/merge_test.patch
再次编辑文件
-bash-4.1$ quilt edit src/3rdParty/webkit/work/WebCore/page/FocusController.h___bak
File src/3rdParty/webkit/work/WebCore/page/FocusController.h___bak is already in patch patches/merge_test.patch
-bash-4.1$ quilt refresh
哎呀,文件名写错了。我们可以用"remove"命令从补丁中删除关联文件:
【注意,没有remove文件】,如果不小心多quilt add添加了一个文件,如果没有变化,用quilt refresh的时候,则此内容不会出现在patchs/***里面; 所以remove 命令没有必要;
实例: 管理补丁
quilt series 查看所有series里面的文件内容
$ quilt series
"quilt patches 文件名"显示修改了指定文件的所有补丁,例如:
-bash-4.1$ quilt patches src/3rdParty/webkit/work/WebCore/page/FocusController.h
patches/merge_test.patch
"quilt annotate 文件名"显示指定文件的修改情况,它会指出哪个补丁修改了哪一行。例如:
-bash-4.1$ quilt annotate src/3rdParty/webkit/work/WebCore/page/FocusController.h
1 leosu test!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! quilt test
private:
Page* m_page;
RefPtr<Frame> m_focusedFrame;
bool m_isActive;
bool m_isFocused;
};
} // namespace WebCore
#endif // FocusController_h
1 patches/merge_test.patch
我们可以使用push和pop命令应用补丁或撤销补丁,例如:
$ quilt pop -a
-bash-4.1$ quilt top
patches/merge_test.patch
"quilt pop -a"撤销所有补丁。
top命令显示栈顶命令,即当前应用的最新的补丁。
next命令显示下一个可以应用的补丁。
previous显示上一条应用过的补丁。
"push 补丁A"将从上到下依次应用所有早于补丁A的补丁,最后应用补丁A。
-bash-4.1$ quilt top
patches/merge_test.patch
-bash-4.1$ quilt pop -a #########此时补丁文件patches/merge_test.patch还是存在的!!!!! 只不过不在 .pc 文件夹里面了!!
Removing patch patches/merge_test.patch
Removing src/3rdParty/webkit/work/WebCore/page/FocusController.h___bak
Restoring src/3rdParty/webkit/work/WebCore/page/FocusController.h
No patches applied
-bash-4.1$quilt top
No patches applied
-bash-4.1$ quilt next
patches/merge_test.patch
-bash-4.1$ quilt previous
No patches applied
bash-4.1$ quilt push patches/merge_test.patch
Applying patch patches/merge_test.patch
patching file src/3rdParty/webkit/work/WebCore/page/FocusController.h
patching file src/3rdParty/webkit/work/WebCore/page/FocusController.h___bak
Now at patch patches/merge_test.patch
-bash-4.1$ quilt top
patches/merge_test.patch
删除补丁:
-bash-4.1$ quilt delete
Removing patch patches/merge_test.patch
No patches applied
Removed patch patches/merge_test.patch
-bash-4.1$ quilt top
No patches applied
-bash-4.1$ quilt files
No patches applied
revert 某个修改的文件(包括所有patch里面的此文件的变更):
-bash-4.1$ quilt revert src/3rdParty/webkit/work/JavaScriptCore/interpreter/Interpre999999999999.txt
Changes to src/3rdParty/webkit/work/JavaScriptCore/interpreter/Interpre999999999999.txt in patch patches/testttttttttttt.patch reverted
revert某个patch的某个文件:
-bash-4.1$ quilt revert -P patches/testttttttttttt.patch src/3rdParty/webkit/work/JavaScriptCore/interpreter/Interpre999999999999.txt
File src/3rdParty/webkit/work/JavaScriptCore/interpreter/Interpre999999999999.txt is unchanged
========= End
标签:4.1,quilt,补丁,patch,命令,详解,test,bash From: https://www.cnblogs.com/lsgxeva/p/18547044