Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to "repackage" a RPM file for example cpio2rpm without installing the RPM?

Tags:

linux

rpm

rebuild

  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.

like image 634
Dr Bob Avatar asked May 14 '12 09:05

Dr Bob


People also ask

How can I see RPM contents without installing?

Listing of the files inside an RPM package You can get a listing of the files inside an RPM by performing an RPM query and adding the “-p” switch: $ rpm -q -l -p bash-3.1-16.1. x86_64. rpm /bin/bash /bin/sh /etc/skel/.


2 Answers

You can use rpmrebuild to modify an actual rpm file (it doesn't need to be installed).

Most of the examples for this use complicated inline edit commands to modify known files in particular ways, but you can use a normal editor. I used this to fix a shell script in an rpm file that I didn't have the source for. Call the command as

rpmrebuild -ep theFileName.rpm

This puts you in an editor with the spec file for the RPM. The name of the file will be something like ~/.tmp/rpmrebuild.12839/work/spec.2. If you look in, in this example, ~/.tmp/rpmrebuild.12839/work, you will find all of the files used to make the RPM (in my case, the file was in root/usr/sbin within that directory). So, go to another window, cd to that directory, and edit any files you need to change.

When you have finished editing files, go back to the edit window with the spec file, make any changes you need to that file (I didn't have any, since I wasn't adding or deleting files), save the file, and say "y" to the "Do you want to continue" question. It will then build a new RPM file, and tell you where it has put it (in my case, in ~/rpmbuild/RPMS/x86_64/)

like image 82
simon3270 Avatar answered Oct 21 '22 20:10

simon3270


You can repackage an installed RPM (including modified files) using rpmrebuild. http://rpmrebuild.sourceforge.net/

Obviously your binaries (if any) would have to be platform/architecture independent to work on all the OS flavors you're hoping for, but it sounds like if they're just web files that shouldn't be a problem.

like image 29
JeremiahRo Avatar answered Oct 21 '22 21:10

JeremiahRo