首页 > 其他分享 >quilt命令详解

quilt命令详解

时间:2024-11-14 22:57:32浏览次数:1  
标签:4.1 quilt 补丁 patch 命令 详解 test bash

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

相关文章

  • gRPC cmake Visual Studio编译安装 (全命令行)
    gRPCcmake编译安装(全命令行)重要前言:所有在引用框中的命令都不要输入!!cmake--install. #在引用框中的不要输入到命令行cmake--install.--configDebug #命令没有被引用框包裹,需要输入到命令行中0x00环境配置vs2022,git,cmake,Powershell7<管理员......
  • uniapp路由与页面跳转详解:API调用与Navigator组件实战
    UniApp路由与页面跳转详解:API调用与Navigator组件实战路由uniapp页面路由为框架统一管理,开发者需要在page.json里面配置每个路由页面的路径及页面样式。路由跳转uniapp有两种页面路由跳转方式,调用API跳转和navigator组件跳转。调用API跳转navTo(){ /*跳转到非tabbar......
  • Java常见排序算法详解:快速排序、插入排序与冒泡排序
    在程序设计中,排序是最基本的操作之一。Java提供了多种排序算法,今天我们将介绍三种常见的排序方法:快速排序、插入排序和冒泡排序。我们不仅会分析它们的基本原理,还会提供实际的代码实现,帮助大家更好地理解并应用这些排序算法。一、快速排序(QuickSort)快速排序是一种分治法的排......
  • shell 命令
      read:https://www.cnblogs.com/f-ck-need-u/p/7402149.html如果没有指定任何var_name,则分割后的所有字段都存储在特定变量REPLY中。选项说明:-a:将分裂后的字段依次存储到指定的数组中,存储的起始位置从数组的index=0开始。-d:指定读取行的结束符号。默认结束符号为换行符......
  • 用两行命令快速搭建深度学习环境(Docker/torch2.5.1+cu118/命令行美化+插件),包含完整的
    深度学习环境的配置过于繁琐,所以我制作了两个基础的镜像,希望可以帮助大家节省时间,你可以选择其中一种进行安装,版本说明:base版本基于pytorch/pytorch:2.5.1-cuda11.8-cudnn9-devel,默认python版本为3.11.10,可以通过condainstallpython==版本号直接修改版本。dl版......
  • linux开机自启运行命令
    1、授权chmoda+x/etc/rc.d/rc.local2、编辑文件输入需要开机自启的命令vim/etc/rc.d/rc.local#格式是/usr/bin/nohup运行命令&#这种方式可以不用担心运行的命令是前台进程还是后台进程/usr/bin/nohup/usr/bin/java-jar/data/rocketmq-dashboard-1.0.1-SNAPSH......
  • 【MYSQL】锁详解(全局锁、表级锁、行级锁)【快速理解】
    目录一、全局锁二、表级锁    1.表锁    2.元数据锁    3.意向锁三、行级锁    1.行锁        2.间隙锁        3.临建锁锁是处理并发情况下,对数据的一致性的关键因素,也是并发情况下对效率影响非常大的。1、......
  • 【MYSQL】InoDB引擎以及MVCC多版本并发控制【详解】
    一、逻辑存储架构        一个表空间对应的一个ibd文件,里面有许多段,其中包括数据段和索引段还有回滚段,在数据存储模型中的B+树中,叶子节点就是数据段进行存储的,非叶子节点就是索引段进行存储的,回滚段里存储了undolog日志。然后里面还分为区->页->行二、架构......
  • MySQL 数据库操作详解:DDL、DML、DQL 和 DCL
    MySQL数据库操作详解:DDL、DML、DQL和DCL在MySQL数据库中,数据定义语言(DDL)、数据操作语言(DML)、数据查询语言(DQL)和数据控制语言(DCL)是四种基本的数据库操作语言。本文将详细介绍这些语言的定义、常用命令以及如何使用它们来管理和操作数据库。1.数据定义语言(DDL)定义:DDL(DataD......
  • HDMI规范-第十二章 HEAC 设备能力发现和控制协议详解
    HEAC设备能力发现与控制英文全称是CapabilityDiscoveryandControl,简称CDC。为了使用HEAC的HDMI以太网通道功能,需要发现并控制相应路径上设备的功能而诞生。通过CEC承载的CDC消息完成的。具有HDMI以太网通道功能的设备应支持CDC。HEAC协议通用规则CDC设备应符合CEC......