Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unpacking an RPM file and repacking It

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

like image 905
Monojeet Avatar asked Jun 15 '11 08:06

Monojeet


People also ask

How do I look inside an RPM?

You can use rpm command (rpm command) itself to list the files inside a RPM package. rpm is a powerful Package Manager, which can be used to build, install, query, verify, update, and erase individual software packages.


1 Answers

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

  1. Unpack the rpm into a directory with the rpm2cpio command
  2. Make the necessary changes inside that subdirectory
  3. 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/

like image 164
Corey Henderson Avatar answered Nov 06 '22 02:11

Corey Henderson