Linux quilt 生成补丁工具

   日常开发中经常会遇到打补丁及生成补丁的问题,如果版本管理工具使用git,那么可以使用git format-patch n 为近期的n次提交生成patch。当然也可以使用diff 生成某一个文件的patch。

本文主要是使用quilt来解决没有使用git管理的场景中如何生成多个文件的patch

问题场景

     工作中不可避免的需要使用开源的一些库,由于开发环境或者需求特殊性,我们需要去修改源代码。为了后期版本的可追溯及版本的一致性,一般会将某一个版本的修改最终生成一个patch,在每次编译的时候将patch 打入即可。

quilt 安装

ubuntu20.04默认是没有安装quilt,需要自行安装

sudo apt-get install quilt

quilt help 产看支持的功能

quilt  --help 

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

Global options:

--trace
	Runs the command in bash trace mode (-x). For internal debugging.

--quiltrc file
	Use the specified configuration file instead of ~/.quiltrc (or
	/etc/quilt.quiltrc if ~/.quiltrc does not exist).  See the pdf
	documentation for details about its possible contents.  The
	special value "-" causes quilt not to read any configuration
	file.

--version
	Print the version number and exit immediately.

quilt 创建一个patch的步骤

例如r329_tina/package/libs/libgpg-error在ubunut18.04编译没有问题,但是在ubuntu20.04中编译中会报错如下,下面以ubuntu20.04生成libgpg-error的patch解决编译的问题。

gawk: ./mkerrcodes.awk:88: warning: regexp escape sequence `\#' is not a known regexp operator
rm _mkerrcodes.h
cc -I. -I. -o mkerrcodes ./mkerrcodes.c
./mkerrcodes | gawk -f ./mkerrcodes2.awk >code-from-errno.h
gawk: ./mkerrcodes2.awk:94: warning: regexp escape sequence `\#' is not a known regexp operator
gawk -f ./mkstrtable.awk -v textidx=2 -v nogettext=1 \
	./err-sources.h.in >err-sources-sym.h
gawk: ./mkstrtable.awk:113: warning: regexp escape sequence `\#' is not a known regexp operator
gawk -f ./mkstrtable.awk -v textidx=2 -v nogettext=1 \
	./err-codes.h.in >err-codes-sym.h
gawk: ./mkstrtable.awk:113: warning: regexp escape sequence `\#' is not a known regexp operator
gawk -f ./mkstrtable.awk -v textidx=2 -v nogettext=1 \
	-v prefix=GPG_ERR_ -v namespace=errnos_ \
	./errnos.in >errnos-sym.h
gawk: fatal: cannot use gawk builtin `namespace' as variable name

step1

quilt new 0001-libgpg-error-fix-gawk.patch    #create the patch

step2

quilt add $FILE_NAME #add files to be patched 
                     #-- add the file before changing it

Step 3:

   Edit files

Step 4:

quilt refresh #update the patch

最终将生成的patch文件拷贝保存patchs 的目录即可。这样就生成了libgpg-error 这个开源包基于ubuntu20.04编译的补丁包,以上只是简单介绍了解决问题的过程。

参考资源:

Quilt Patching Tips | Quilt Linux | Why Patch Open Source Packages

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值