Linux 解压 RPM 文件并重新打包

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6354782/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 04:32:06  来源:igfitidea点击:

Unpacking an RPM file and repacking It

linuxsolarisrpmbuild

提问by Monojeet

I have a RPM file. I have to make some changes to that RPM , repack it and Test. Can anyone help me?

我有一个 RPM 文件。我必须对该 RPM 进行一些更改,重新打包并测试。谁能帮我?

回答by Jasonw

I think that is a concept called patch. I started patching the first srpm using this link. But the basic idea is that, get the srpm, install the srpm, create your patch inside that build area directory and specify the patch file %patch0 -p1 in the spec file. Then do rpm build. Happy patching!

我认为这是一个叫做补丁的概念。我开始使用此链接修补第一个 srpm 。但基本思想是,获取 srpm,安装 srpm,在该构建区域目录中创建补丁并在规范文件中指定补丁文件 %patch0 -p1。然后进行 rpm 构建。快乐打补丁!

回答by Corey Henderson

The best way to modify an RPM you do not have the source for is to follow these steps:

修改没有源的 RPM 的最佳方法是执行以下步骤:

  1. Unpack the rpm into a directory with the rpm2cpiocommand
  2. Make the necessary changes inside that subdirectory
  3. Make a "dummy" spec file and build it.
  1. 使用rpm2cpio命令将 rpm 解压到一个目录中
  2. 在该子目录中进行必要的更改
  3. 制作一个“虚拟”规范文件并构建它。

That dummy spec file might look like this:

该虚拟规范文件可能如下所示:

Name: blah
Version: 1.0
Release: 1
Summary: blah
License: blah
Distribution: blah
Group: blah
Packager: me
BuildRoot: /path/to/dir/with/mods

%description
blah

%files
/path/to/dir/with/mods/*

Replace every "blah" in here with the real value (use rpm -qpi rpm fileto get the values). Replace the BuildRoot to the directory you have the modified rpm unwrapped. Then run rpmbuild -bb dummy.spec.

用实际值替换这里的每个“废话”(用于获取值)。将 BuildRoot 替换为您已解压缩修改后的 rpm 的目录。然后运行。rpm -qpi rpm filerpmbuild -bb dummy.spec

Since there are no prep/setup/build/install steps defined, it'll just take what's in the buildroot and make an RPM.

由于没有定义准备/设置/构建/安装步骤,它只会使用 buildroot 中的内容并制作 RPM。

If the rpm package has script files, you'll also have to put them in this dummy spec file. To see if the package has any scripts, run: rpm -qp --scripts rpm file. Same thing goes for dependencies, prereqs, etc.

如果 rpm 包有脚本文件,您还必须将它们放在这个虚拟规范文件中。若要查看是否包有任何脚本,运行:。依赖项、先决条件等也是如此。rpm -qp --scripts rpm file

There may be other details I'm missing, but this should be enough to get you started.

我可能还缺少其他细节,但这应该足以让您入门。

UPDATE:For what it's worth, there is also http://rpmrebuild.sourceforge.net/

更新:对于它的价值,还有http://rpmrebuild.sourceforge.net/