quilt - 制作patch的工具

本文介绍了一个用于管理和创建补丁的工具——Quilt。Quilt最初由内核开发者为方便Linux内核打补丁而开发,现广泛应用于各种源码管理场景。文章详细讲解了Quilt的安装过程及基本命令使用方法,并通过具体实例演示了如何利用Quilt创建和管理补丁。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

quilt - 制作patch的工具

在尝试为openwrt做一个patch时,查到这个工具。openwrt官方已经有很详细的文档对步骤进行说明了。

quilt并不是专为openwrt的开发工具。quilt最早由内核开发者Andrew Morton ,为了给Linux内核更容易的打补丁。

这里有几篇文章,可以很好的说明怎么使用quilt:

  1. quilt-doc
  2. 用quilt给openwrt制作补丁Working with patches
  3. 用quilt给linux kernel制作补丁 Managing Your Patches With quilt

当然,对于用git管理起来的linux kernel或其他source来说,git本身是更好的工具。

quilt的安装

sudo apt-get install quilt

quilt本身是一个脚本,上面这一句把它安装于/usb/bin/quilt

quilt 的执行方式是:

quilt command ...

command有如下选择:

add       fold    new       remove    top
annotate  fork    next      rename    unapplied
applied   graph   patches   revert    upgrade
delete    grep    pop       series
diff      header  previous  setup
edit      import  push      shell
files     mail    refresh   snapshot

其中每一个command都是/usr/share/quilt/目录下的一个以command命名的脚本。

quilt基本使用

  • test目录下有两个文件file1.c file1.h

  • 创建一个新patch

    quilt new 0001-test.patch

  • 把文件加入到topmost patch

    quilt add file1.c

接下来对int.c的修改都会记录到topmost patch中去。

  • 编辑文件
    使用编辑器修改源文件,也可以调用quilt的默认编译器来修改int.c。

    quilt edit file1.c

  • 更新topmost patch

    quilt refresh

使用了这条命令之后,修改才会写入到0001-test.patch中

  • 继续新建一个patch

    quilt new 0002-test.patch

此时topmost变成了0002-test.patch。
现在使用quilt files查看,此patch下没有跟踪文件

  • 添加两个文件file1.c file1.h

    quilt add file1.c file1.h

现在使用quilt files查看,此patch跟踪了两个文件。编辑它们。

  • pop/push

回退到某个patch

$ quilt pop 0001-test.patch 
Removing patch 0002-test.patch
Restoring file1.c
Restoring file1.h

Now at patch 0001-test.patch

这个命令之后,0001-test.patch将变为topmost patch。所有的修改退回到这个点上。

$ quilt push 0002-test.patch 
Applying patch 0002-test.patch
patching file file1.c
patching file file1.h

Now at patch 0002-test.patch

push命令使用0002-test.patch。

转载于:https://www.cnblogs.com/sammei/p/3991805.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值