PDA

View Full Version : How to "repackage" a binary .RPM file for example cpio2rpm without installing the RPM



drcool
14th May 2012, 12:00 PM
1. I'm able to extract files from a RPM file, but how do I "rebuild" it, for example cpio2rpm?
2. I have extracted RPM file using following command.
rpm2cpio theFileName.rpm | cpio –idmv
3. I have to modify the few web application files like *.php, *.html or .js. These files don’t require any source recompilation. So I would like to replaces or change these files with modification without rebuilding rpm. Since, I need to do this for multiple platforms like Redhat Linux and SUSE, and multiple architecture like 32 and 64 bit OS.
4. I am expecting to do these changes on only on system and without rebuild rpm and there would not be have target system architecture dependency (like i386, 64).
5. I am not looking like command rpmbuild –rebuild the.src.rpm since, I don’t have source. I need to be rebuild binary .RPM file(not source .rpm)
6. I want to do this without source and platform or architecture independent and without using spec file if possible.
Any buddy, could you please suggest any solution or any free tools.
Thank you to all whoever spends time to read and reply to my thread.

srs5694
14th May 2012, 05:41 PM
It's probably not optimal, but one way might be to use "alien", which is a program to convert between package formats. Importantly, it supports both tarballs and RPMs. Thus, you could:


Do an RPM-to-tarball conversion with alien
Unpack the tarball
Make any changes you want
Pack a new tarball from the changed files
Do a tarball-to-RPM conversion with alien


One drawback to this is that, since the tarball format doesn't provide some of RPM's metadata (such as flagging configuration files as such), you'll lose that information.

quickbrownfox
14th May 2012, 06:35 PM
It's probably not optimal, but one way might be to use "alien", which is a program to convert between package formats. Importantly, it supports both tarballs and RPMs. Thus, you could:


Do an RPM-to-tarball conversion with alien
Unpack the tarball
Make any changes you want
Pack a new tarball from the changed files
Do a tarball-to-RPM conversion with alien


One drawback to this is that, since the tarball format doesn't provide some of RPM's metadata (such as flagging configuration files as such), you'll lose that information.

This is such a nice idea, but unfortunately that final step doesn't seem to work, because it attempts to rebuild the entire package when you try to convert from tarball to RPM. So unless you have all your dependencies in place, it can't be done. Is there some way to reverse the cpio process.

beaker_
14th May 2012, 10:46 PM
This is such a nice idea, but unfortunately that final step doesn't seem to work, because it attempts to rebuild the entire package when you try to convert from tarball to RPM. So unless you have all your dependencies in place, it can't be done. Is there some way to reverse the cpio process.

Hmmm.., you want to rebuild an RPM but you don't want to install the dependancies? How about mock then.
http://fedoraproject.org/wiki/Projects/Mock

mschwendt
16th May 2012, 12:12 PM
A reverse rpm2cpio with the possibility to insert file modifications is not a good idea, IMO.

I second parts of the suggestion made by srs5694. Except that I find it more convenient to repack installed files using a very basic "dummy" RPM .spec file in order to be create a ".nosrc.rpm" package. That gives more control over increasing the "Release" value properly, perhaps adding "Obsoletes" tags and renaming the package so it doesn't get replaced again by a normal update. In the spec file %prep section, installed files from the system are copied into the builddir or are extracted from an archive file or a pristine .rpm file using rpm2cpio. Then they get patched and installed into the buildroot. The %files list for that buildroot can be very simple one-liner (to include a full tree), if possible, but may need to explicitly specify special file %attr-ibutes if necessary.