quilt

参考自:

http://blog.csdn.net/fmddlmyy/article/details/2140064

man -t quilt | ps2pdf - quilt.pdf | evince quilt.pdf

 

 

 

All commands print some help text with:

quilt cmd -h.

 

By default, most commands apply to the topmost patch on the stack.

A file called series contains a list of patch file names that defines the order in which patches are applied. Lines in the series file that start with a hash character (#) are ignored. You can also add a comment after each patch file name, introduced by a space followed by a hash character. When quilt adds, removes, or renames patches, it automatically updates the series file.

 

Before a patch is applied (or ‘‘pushed on the stack’’), copies of all files the patch modifies are saved to the .pc/patch directory. The patch is added to the list of currently applied patches (.pc/applied-patches). Later when a patch is regenerated (quilt refresh), the backup copies in .pc/ patch are compared with the current versions of the files in the source tree using GNU diff.

由上可以看出,其使用 diff 命令生成patch,那么如何添加 comment呢?如下:

Documentation related to a patch can be put at the beginning of a patch file. Quilt is careful to preserve all text that precedes the actual patch when doing a refresh.

 

 一个大项目可能由不同开发者提供很多补丁,这些补丁可能还存在依赖关系,例如补丁B必须打在补丁A上。由于补丁之间存在了依赖关系,因此不便于使用patch工具管理,此时需要一个工具quilt。

 

quilt是一个帮助我们管理补丁的程序。
只要我们在源代码树里使用了quilt命令,quilt就会在源代码树的根目录建立两个特殊目录:patches和.pc。quilt在patches目录保存它管理的所有补丁。quilt用.pc目录保存自己的内部工作状态,用户不需要了解这个目录。
patches/series文件记录了quilt当前管理的补丁。补丁按照加入的顺序排列,早加入的补丁在前。quilt用堆栈的概念管理补丁的应用。

 

在应用补丁A前,必须先应用所有早于补丁A的补丁。所以,patches/series中的补丁总是从上向下应用。例如:上图中,补丁1到补丁5是已经应用的补丁。我们可以将已应用的补丁想象成一个向下生长的堆栈,栈顶就是已应用的最新补丁。应用补丁就是将补丁入栈,撤销补丁就是将补丁出栈。

 

 

 

在源代码树中作任何修改前,必须用"quilt add"命令将要修改的文件与一个补丁联系起来(一个补丁可以同多个文件关联,一个文件也可以关联多个补丁)。在完成修改后,用"quilt refresh"命令将修改保存到已联系的补丁(对于补丁涉及到的文件,将其在变化做成补丁的形式)。

 

如果当前目录下没有patches文件夹,那么有三种方法:
1) 直接拷贝别人的(主开发版本不在本机)
2) quilt new file.patch (如果当前目录下没有patches目录,则会生成,并执行其它相关动作)
3) mkdir patches; touch ./patches/series 

 

基础:
1.查看当前已应用的补丁
quilt applied

 

quilt applied patch_file.patch

查看从series文件开头指定的patch,到patch_file.patch之间所有应用的patch

 

2.查看当前还没有被应用的补丁
quilt unapplied

 

3.查询栈顶补丁,即查询应用的最新补丁
quilt top

 

4. 应用补丁
1)quilt push -a
应用所有补丁。
在使用push命令后,prj目录会多了一个叫 .pc 的隐含文件夹。quilt用该目录保存内部状态。
应用补丁后,可以使用applied、unapplied 和 top 命令查看。

2)quilt push patch_file.patch
将从上到下依次应用所有早于补丁patch_file.patch的补丁,最后应用补丁patch_file.patch

相应的,可以使用pop命令撤销补丁:
1)1)quilt pop -a
撤销所有补丁。

 

5. 显示可以应用的下一个补丁
quilt next

相应的,采用下命令显示上一条应用过的补丁:
quilt previous


6. 查看 文件变化
quilt diff -z [-P patch_file.patch] [patch_related.files]
可以查看指定补丁& 指定文件的当前改动。
省略参数-P 表示查看栈顶补丁涉及文件的改动,
省略文件名表示查看所有改动。
只要文件已经与保存的补丁联系过了,就可以多次修改文件。

另:quilt diff -z 命令不会显示已保存的差异; quilt diff显示所有的差异,不管是否保存过。

 

7. 查找与补丁关联的文件名
quilt files [patch_file.patch]
省略 补丁名,表示查看与栈顶补丁关联的文件名。

quilt files -val
用于查看所有补丁联系的所有文件。
"-v"参数表示更友好地显示;
"-a"参数表示显示所有补丁;
"-l"参数表示显示补丁名

相应的,可以查看修改了指定文件的所有补丁:
quilt patches file_look_for.file

另外:
quilt annotate file_look_for.file
该命令,显示指定文件的修改情况,并指出哪个补丁修改了哪一行。

quilt annotate -P patch_file.patch  file_look_for.file

该命令,显示指定文件的修改情况,但是只包含series文件开头的patch到 patch_file.patch这些patch所做的修改。

 

8. 断开补丁与文件间的关联
quilt remove [-P patch_file.patch] patch_related.files
省略参数-P说明当前作用的是栈顶补丁;
断开补丁patch_file.patch与文件patch_related.files间的关联。

 

9. quilt edit regular_file.file
quilt edit 命令启动后自动调用quilt add,将regular_file.file与栈顶patch关联起来,
并启动编辑器。

 

 

 

修改文件:
1.必须将对当前源代码所做的任何改动都和一个补丁联系起来。add命令将文件的当前状态与补丁联系起来。
add命令的格式为:
quilt add [-P patch_file.patch] patch_related.files
如果没有 指定 patch_file.patch,则 patch_related.files文件就与栈顶补丁联系起来。

 

2. 新建一个补丁
quilt new patch_file_one.patch
然后用add命令向栈顶补丁(当前即为 patch_file_one.patch)添加一个准备修改的文件。
add 命令为指定补丁保存了指定文件的当前快照,当执行refresh命令时,quilt就会检查文件的变化,将差异保存到指定的补丁中。

 

3. 将文件变化保存到补丁
quilt refresh [patch_file.patch]
刷新补丁,即将指定补丁的文件变化保存到补丁。
省略文件名表示刷新栈顶补丁。

 

 


管理patch:
1. 查看series文件中的补丁列表
quilt series

 

 


发布patch:
将patches目录打包发布就可以了。其它用户可以先下载、解压补丁包到适当的版本源码,在应用即可

 

 

 

其它:
1. quilt graph -all
可以为栈顶补丁的依赖关系生成dot文件。Graphviz的dot可以根据dot文件产生图片,例如:
quilt graph --all > ../test.dot
cd ../; dot -Tpng more_p2.dot -o test.png; eog test.png

 

2.

delete [-r] [--backup] [patch|-n]
Remove the specified or topmost patch from the series file. If the patch is applied, quilt will attempt to remove it first. (Only the topmost patch can be removed right now.)
-n Delete the next patch after topmost, rather than the specified or topmost patch.
-r Remove the deleted patch file from the patches directory as well.
--backup Rename the patch file to patch˜ rather than deleting it. Ignored if not used with ‘-r’.

 

3.

diff [-p n|-p ab] [-u|-U num|-c|-C num] [--combine patch|-z] [-R] [-P patch] [--snapshot] [--diff=utility][--no-timestamps] [--no-index] [--sort] [--color] [file ...]
Produces a diff of the specified file(s) in the topmost or specified patch. If no files are specified, all files that are modified are included.
-p n Create a -p n style patch (-p0 or -p1 are supported).
-p ab Create a -p1 style patch, but use a/file and b/file as the original and new filenames instead of the default dir.orig/file and dir/file names.
-u, -U num, -c, -C num Create a unified diff (-u, -U) with num lines of context. Create a context diff (-c, -C) with num lines of context. The number of context lines defaults to 3.
--no-timestamps Do not include file timestamps in patch headers.
--no-index Do not output Index: lines.
-z Write to standard output the changes that have been made relative to the topmost or specified patch.
-R Create a reverse diff.
-P patch Create a diff for the specified patch. (Defaults to the topmost patch.)
--combine patch Create a combined diff for all patches between this patch and the patch specified with -P. A patch name of ‘-’ is equivalent to specifying the first applied patch.
--snapshot Diff against snapshot (see ‘quilt snapshot -h’).
--diff=utility Use the specified utility for generating the diff. The utility is invoked with the original and new file name as arguments.
--color[=always|auto|never] Use syntax coloring.
--sort Sort files by their name instead of preserving the original order.

 

4.

grep [-h|options] {pattern}
Grep through the source files, recursively, skipping patches and quilt meta-information. If no filename argument is given, the whole source tree is searched.

 

5.

quilt header [patch_file.patch]
显示相应 patch的头

quilt header -e [patch_file.patch]
编辑相应patch的头

 

6.

import [-p num] [-R] [-P patch] [-f] [-d {o|a|n}] patchfile ...
Import external patches. The patches will be inserted following the current top patch, and must be pushed after import to apply them.(说明只是写入了series文件,还没有push)
-p num Number of directory levels to strip when applying (default=1)
-R Apply patch in reverse.
-P patch Patch filename to use inside quilt. This option can only be used when importing a single patch.
-f Overwrite/update existing patches.
-d {o|a|n} When overwriting in existing patch, keep the old (o), all (a), or new (n) patch header. If both patches include headers, this option must be specified. This option is only effective when -f is used.

 

7.

new [-p n|-p ab] {patchname}
Create a new patch with the specified file name, and insert it after the topmost patch.
-p n Create a -p n style patch (-p0 or -p1 are supported).
-p ab Create a -p1 style patch, but use a/file and b/file as the original and new filenames instead of the default dir.orig/file and dir/file names.

 

8.

rename [-P patch] new_name
Rename the topmost or named patch.
-P patch Patch to rename.

 

9. 这个命令的作用?

setup [-d path-prefix] [-v] [--sourcedir dir] [--fuzz=N] {specfile|seriesfile}
Initializes a source tree from an rpm spec file or a quilt series file.
-d Optional path prefix for the resulting source tree.
--sourcedir Directory that contains the package sources. Defaults to ‘.’.
-v Verbose debug output.
--fuzz=N Set the maximum fuzz factor (needs rpm 4.6 or later).

 

posted on 2014-09-21 14:51  阿加  阅读(2173)  评论(0编辑  收藏  举报

导航