I have a RPM file. I have to make some changes to that RPM , repack it and Test. Can anyone help me?
2 Answers
The best way to modify an RPM you do not have the source for is to follow these steps:
- Unpack the rpm into a directory with the rpm2cpio command
- Make the necessary changes inside that subdirectory
- Make a "dummy" spec file and build it.
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 file
to get the values). Replace the BuildRoot to the directory you have the modified rpm unwrapped. Then run rpmbuild -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.
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.
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/

- 5,699
- 7
- 38
- 49

- 7,239
- 1
- 39
- 43
-
1This doesn't work without specifying/modifying `rpmbuild`'s `BUILDROOT` setting. – jmtd Feb 15 '13 at 08:03
-
I think `%files` should be relative to `BuildRoot`. – dma_k May 27 '13 at 09:49
-
A piece of step is missing, you also need to extract `cpio` archive. The step1 should be: `rpm2cpio pkg_name.rpm | cpio -idmv`. – Hi-Angel Oct 15 '22 at 09:57
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!

- 5,054
- 7
- 43
- 48
-
The main problem i am facing is i do not have a source RPM. I just have the RPM build. – Monojeet Jun 15 '11 at 08:30
-
@Monojeet, then find out the source rpm? It is only logical why srpm is there because when patching, we would need the *source* rpm and not the built rpm. – Jasonw Jun 15 '11 at 08:38
-
-
It is a Propietory App Build RPM. Jsut want to make sure that its not at all possible to edit the RPM without SRPM – Monojeet Jun 15 '11 at 11:04
-
aha..another question. If you want to protect integrity of your rpm, probably you should sign your rpm package. http://magazine.redhat.com/2007/12/04/hacking-rpms-with-rpmrebuild/ you can probably read this link for rpmrebuild. – Jasonw Jun 16 '11 at 05:56