使用模拟添加补丁 [英] Adding a patch using mock

查看:99
本文介绍了使用模拟添加补丁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用模拟创建rpm. https://fedoraproject.org/wiki/Projects/Mock

I am trying to create a rpm using mock. https://fedoraproject.org/wiki/Projects/Mock

我能够通过源rpm建立一个rpm.现在,我想为此程序包添加一个补丁,但我不知道如何继续.您能告诉我如何进行此操作吗?使用模拟修改/修补软件包的方法是什么?

I am able to build an rpm through source rpm. Now I want to add a patch to this package and I have no idea how to proceed. Can you please let me know how can I go ahead with this? What is the way to modify/patch a package using mock?

推荐答案

此处的正常方法是不使用模拟方法以任何方式修改您的程序包.模拟只是一种确保每次打包都在一个干净的环境中构建的方法(一个新的chroot),而实际上并没有做更多的事情.

The normal approach here is not to use mock to modify your package in any way. Mock is just a way to ensure that your package is built in a clean environment every time (a fresh chroot), and it's not really meant to do more than that.

那么,正常的做法是将补丁放入RPM本身的spec文件中.

The normal thing to do, then, would be to put the patch in the spec file for your RPM itself.

这需要两部分-首先,将补丁文件包含在软件包中,其次,其应用.

This requires two parts — first, the inclusion of the patch file as part of the package, and second, its application.

首先,通常在Source行(或多行)之后,紧接spec文件顶部附近列出补丁.每个补丁都有一个数字,通常的约定是从0开始计数,因此,如果只有一个,则看起来像这样:

For the first, list the patch near the top of the spec file, usually right after your Source line (or lines). Each patch gets a number, and the normal convention is to start counting with 0, so if you have just one, that will look like this:

Patch0:   packagename-version-terse_patch_description.patch

与源文件一样,剥离该文件名中最后一个/的所有内容,因此您可以根据需要使用URL.该补丁必须位于您的RPM源目录中(通常在tarball旁边).

As with source files, anything up to the last / in that filename is stripped off, so you can use a URL if you want. The patch will need to be in your RPM sources directory (usually, next to the tarball.)

这时,如果您根据修改后的规范构建源RPM,则生成的src.rpm文件将包含此补丁文件. (尝试-rpm -qlp packagename-ver-rel.src.rpm).但是,不会应用.为此,您需要使用%patch宏.

At this point, if you build a source RPM from your modified spec, the resulting src.rpm file will contain this patch file. (Try it — rpm -qlp packagename-ver-rel.src.rpm). But, it won't be applied. To do that, you need to use the %patch macro.

这放在specfile的 %prep 部分中,通常在%setup宏行之后.每个%patch宏在标头中都有一个与Patch行相对应的数字,因此对于您的Patch0,添加这样的一行:

This goes in the %prep section of the specfile, usually right after the %setup macro line. Each %patch macro has a number corresponding to the Patch line in the header, so for your Patch0, add a line like this:

%patch0 -p1 -b .bugfix

按照惯例,将RPM中使用的补丁程序向上构建一个级别,因此-p1是合适的. (方便地,这对于使用git所做的差异也是正确的.)-b .bugfix位不是必需的,但是它是调试的习惯,我想这是对该特定补丁宏的作用的一种内联注释. (将字符串"bugfix"替换为适合您实际补丁的内容.)

Again by convention, patches used in RPM are made built one level up, so -p1 is appropriate. (Conveniently, this will be correct for diffs made with git, too.) And the -b .bugfix bit isn't necessary, but it's customary for debugging, and I guess serves as a sort of inline comment for what this specific patch macro does. (Replace the string "bugfix" with something appropriate to your actual patch.)

这篇关于使用模拟添加补丁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆