简体   繁体   English

如何修改 Fedora package 并修复错误

[英]How to modify a Fedora package and fix bugs

I have an old old game from Fedora, in a package named six.我有一个来自 Fedora 的旧游戏,名为 6 的 package。 It has a bug and I want to add a couple of simple features.它有一个错误,我想添加几个简单的功能。 I asked here about one part of the process, (see How to deal with build dependencies in source RPM? ) got some answers, and find that the learning curve is just too much for my old brain.我在这里询问了过程的一部分,(请参阅如何处理源 RPM 中的构建依赖性? )得到了一些答案,并发现学习曲线对我的旧大脑来说太过分了。 Documentation tends to want to cover everything a package can do and it's hard for me to pick out the pieces I need.文档往往想要涵盖 package 可以做的所有事情,我很难挑选出我需要的部分。

What I am really hoping for is a complete workflow (hopefully just a list of commands and a mention of the directories involved).我真正希望的是一个完整的工作流程(希望只是一个命令列表和提及的目录)。

It would start with this (it works and may even be standard):它将以此开始(它可以工作,甚至可能是标准的):

  • Find the SRPM with rpm -qi six |使用 rpm -qi 6 | 查找 SRPM grep Source grep 来源
  • Fetch with rpm -i six-0.5.3-38.fc35.src.rpm使用 rpm -i six-0.5.3-38.fc35.src.rpm 获取

result: sources and spec files in ~/rpmbuild结果:~/rpmbuild 中的源文件和规范文件

What I need filled in are the following steps after I modify and test the new version:我需要填写的是我修改和测试新版本后的以下步骤:

  • build new SRPM (can mock do this?)构建新的 SRPM(模拟可以做到这一点吗?)
  • build new RPMs and install them locally (I will test and repeat as needed)构建新的 RPM 并在本地安装它们(我将根据需要进行测试和重复)
  • report bug and fixes, possibly as a pull request报告错误和修复,可能作为拉取请求

The steps may be reorganized if needed.如果需要,可以重新组织这些步骤。 I know mock can build RPMs from a SRPM, but I did not see how to go direct from sources to installation, and building fails outside of mock (some problem with qt-mt).我知道 mock 可以从 SRPM 构建 RPM,但我没有看到如何 go 直接从源代码到安装,并且在 mock 之外构建失败(qt-mt 的一些问题)。

I'm hoping for a list of commands that will work together to do these things.我希望有一个命令列表可以协同工作来完成这些事情。 I've done what I could short of spending a week understanding the terminology mismatches between the various man pages.除了花一周的时间来理解各种手册页之间的术语不匹配外,我已经完成了所有工作。 Or just odd usages (why does a REbuild of a SRPM build binary RPMS but not an SRPM?)或者只是奇怪的用法(为什么 SRPM 的重建构建二进制 RPMS 而不是 SRPM?)

BTW if you want to see the bug I mentioned,顺便说一句,如果您想查看我提到的错误,

  • install six安装六
  • start it启动它
  • set Black to human将黑色设置为人类
  • set White to expert置白为专家
  • set Swap enabled设置交换启用
  • click on any hex in the top (or bottom) row and watch six report a crash and quit.单击顶部(或底部)行中的任何十六进制并观察六个报告崩溃并退出。

You can try again, clicking in the middle of the board and notice it does not crash.您可以再试一次,单击板的中间并注意它没有崩溃。

I'm not all that surprised the bug hasn't been noticed before.我对之前没有注意到这个错误并不感到惊讶。 Swap is usually only enabled between experienced players.交换通常只在有经验的玩家之间启用。 I doubt an experienced player would make the first move in the top or bottom row against another.我怀疑一个有经验的玩家会在顶排或底排对付另一个人时迈出第一步。

I had fun getting auto-player to build today.今天让自动播放器构建起来让我很开心。 My work on SentryPeer has paid off: :-)我在 SentryPeer 上的工作得到了回报::-)

How to explain.如何解释。 I needed to patch some code and autoconf/automake links: Here goes:我需要修补一些代码和 autoconf/automake 链接:这里是:

Get the src rpm:获取 src rpm:

sudo dnf download --source six -y

Install rpm-build:安装 rpm-build:

sudo dnf install rpm-build
mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}

Install the src rpm (it will be in the directory you ran step 1.):安装 src rpm(它将在您运行步骤 1 的目录中):

rpm -ivh six-0.5.3-38.fc35.src.rpm

Install the build requirements as per https://src.fedoraproject.org/rpms/six/blob/rawhide/f/six.spec eg it needs:按照https://src.fedoraproject.org/rpms/six/blob/rawhide/f/six.spec安装构建要求,例如它需要:

BuildRequires: make
BuildRequires:  gcc
BuildRequires:  kdelibs3-devel
BuildRequires:  desktop-file-utils

so do:所以这样做:

sudo dnf install make gcc kdelibs3-devel desktop-file-utils

run the rpmbuild command so it applies all the patches etc. as the src rpm comes with six-0.5.3.tar.gz (which is not the same as the code on github at - https://github.com/melisgl/six which I could not get compiled):运行 rpmbuild 命令以应用所有补丁等,因为 src rpm 附带 six-0.5.3.tar.gz(与 github 上的代码不同,地址为 - https://github.com/melisgl/六个我无法编译):

These files I mean:这些文件我的意思是:

localhost ~/rpmbuild/BUILD/six-0.5.3/tests $ ls ../../../SOURCES/
six-gcc43.patch
six-0.5.3.tar.gz
six-fix-DSO.patch

Run:跑步:

rpmbuild -ba ~/rpmbuild/SPECS/six.spec

rpms should be built, but auto-player is an extra program not built by default, as you know. rpms 应该构建,但如您所知,自动播放器是一个默认情况下未构建的额外程序。

This creates a BUILD folder.这将创建一个 BUILD 文件夹。

cd ~/rpmbuild/BUILD/six-0.5.3/tests

edit Makefile.am line 84 and add this to the bit after $(LIB_KFILE):编辑 Makefile.am 第 84 行并将其添加到 $(LIB_KFILE) 之后的位:

-lqt-mt

so it looks like:所以它看起来像:

-lm $(LIB_KFILE) -lqt-mt

and do the same on line 374 of Makefile.in并在 Makefile.in 的第 374 行做同样的事情

By default it wasn't linking to libqt-mt默认情况下它没有链接到 libqt-mt

Go into top level and run configure again to re-generate the Makefile: Go 进入顶层并再次运行配置以重新生成 Makefile:

cd ~/rpmbuild/BUILD/six-0.5.3
./configure
make clean
make
make check

These should all be good这些应该都不错

Go back into tests folder: Go 回到测试文件夹:

cd ~/rpmbuild/BUILD/six-0.5.3/tests

Open auto-player.cpp and add this at line 6 (was missing this, so not sure how it ever compiled):打开 auto-player.cpp 并在第 6 行添加它(缺少它,所以不确定它是如何编译的):

#include <stdlib.h>

save the file.保存文件。

Build the program:构建程序:

make auto-player

Run it:运行:

./auto-player filename player1 player2

as per the code is runs like:根据代码运行如下:

void play(char *filename, Poi<HexPlayer> vert, Poi<HexPlayer> hori)

Let me know how you get on!让我知道你是怎么办的!

Thanks!谢谢!

-- https://sentrypeer.org -- https://sentrypeer.org

You handle it very well.你处理得很好。 You are actually missing only one thing.你实际上只缺少一件事。 After you install the src.rpm with:安装 src.rpm 后:

rpm -i six-0.5.3-38.fc35.src.rpm rpm -i 6-0.5.3-38.fc35.src.rpm

You have six.spec in ~/rpmbuild/SPECS and six-SOMETHING.tar.gz in ~/rpmbuild/SOURCES您在~/rpmbuild/SPECS中有六个.spec,在~/rpmbuild/SOURCES中有six-SOMETHING.tar.gz six.spec

The quick and dirty way is to unpack that six-SOMETHING.tar.gz .快速而肮脏的方法是解压缩该six-SOMETHING.tar.gz Modify the the file and pack it back.修改文件并将其打包回来。 Into the same structure as had the original tar ball.进入与原来的 tar 球相同的结构。

And then just:然后只是:

rpmbuild -bs ~/rpmbuild/SPECS/six.spec rpmbuild -bs ~/rpmbuild/SPECS/six.spec

this will produce the src.rpm and you can then build it using mock:这将生成 src.rpm,然后您可以使用 mock 构建它:

mock six.src.rpm模拟六.src.rpm

(an even quicker and dirtier way is to call rpmbuild -ba which builds the rpm directly, but mock is a cleaner way). (一种更快更脏的方法是调用rpmbuild -ba直接构建 rpm,但 mock 是一种更清洁的方法)。

The standard way of handling fixes in packages is to add a patch.处理包中修复的标准方法是添加补丁。 https://rpm-packaging-guide.github.io/#patching-software But if you do not care about sustainability and long-term security, then the path above is just fine. https://rpm-packaging-guide.github.io/#patching-software但是如果您不关心可持续性和长期安全性,那么上面的路径就可以了。

If you want to file a bug against fedora six's package you can do it here https://bugz.fedoraproject.org/six如果你想提交一个针对 fedora 6 的 package 的错误,你可以在这里https://bugz.fedoraproject.org/six

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM